Skip to content

Instantly share code, notes, and snippets.

@SaicharanKandukuri
Last active June 10, 2023 09:12
Show Gist options
  • Save SaicharanKandukuri/2c9927cdb8017ce730f73f70eaa33c4f to your computer and use it in GitHub Desktop.
Save SaicharanKandukuri/2c9927cdb8017ce730f73f70eaa33c4f to your computer and use it in GitHub Desktop.
tarball linux from with tar ( proot & chroot )

inside a chroot

using tar with arguments -cvpzf where

  • c for compress
  • v user verbose ( it basically prints out all files to console thar are being compressed )
  • z use gzip as compression format
  • f file were all compression should go

we need to say tar not to compress any device specific directories like /dev, /sys,/proc & /run we can use --exclude for that

and also need to exlude file name where all gets compressed ( if you miss this tar may go forever loop and swallow all your storage )

then so command looks like this

sudo tar -cvpzf /target.tar.gz \
		 --exclude={/dev,/proc,/sys,/tmp,/run,/target.tar.gz} \
		 --exclude-caches-all \
		 --one-file-system \
		 -C /*

PROTIP using --exclude-caches-all decreases size also use --one-file-system for less errors


inside android proot

proot is same as chroot except it is in android we need to take care of more excludes or take gig's for device files

for average proot-distro user

  • after logging to your distro ( like after doing proot-distro login ubuntu )
sudo tar -cvpzf /target.tar.gz \
		 --exclude={/dev,/proc,/sys,/tmp,/run,/target.tar.gz} \
		 --exclude={/data,/apex,/vendor,/system,/sdcard} \
		 --exclude-caches-all \
		 --one-file-system \
		 -C /*

here why i excluded /data and others in line 3:

  • /data contains all user/app data which android wont led normal user to read or write
  • /apex ( android pony express ) which is used for low level system module installer also not allowed to normal user
  • /vendor contains device specific libraries it is allowed to read but compressing is it no use cause you can't write it back
  • /system system directory is same as /vendor in permissions
  • /sdcard is your internal storage ( you know why it is not recommended )

it is recommend to use this command after logging in cause permissions may differ before that cause error after restoring your distro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment