Created
December 17, 2008 07:06
-
-
Save yoshimov/36981 to your computer and use it in GitHub Desktop.
Move live usb persistent files into compressed squashfs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z `which mksquashfs` ]; then | |
sudo aptitude update | |
sudo aptitude install squashfs-tools | |
fi | |
sudo mount /cdrom -o remount,rw | |
EXCLUDES='.wh* cdrom etc home lost+found medoa rofs root tmp* var/backups var/cache var/crash var/log var/run var/spool var/tmp' | |
if [ -e /cdrom/casper/update.squashfs ]; then | |
if [ -z `which mount.aufs` ]; then | |
# sudo aptitude update | |
sudo aptitude install aufs-tools | |
fi | |
echo mounting existing image. | |
cd / | |
sudo mkdir /tmpsqfs /tmprwfs | |
sudo mount -t squashfs -o loop /cdrom/casper/update.squashfs /tmpsqfs | |
sudo mount -t ext3 -o loop /cdrom/casper-rw /tmprwfs | |
sudo mount -t aufs -o br:/tmprwfs=rw:/tmpsqfs=ro none /mnt | |
sudo mksquashfs /mnt /cdrom/casper/update-new.squashfs -info -noappend -wildcards -e ${EXCLUDES} | |
if [ -e /cdrom/casper/update-new.squashfs ]; then | |
cd /cdrom/casper | |
echo renaming new squashfs image. | |
sudo mv update.squashfs update.squashfs.old | |
sudo mv update-new.squashfs update.squashfs | |
echo deleting moved files. | |
cd /tmprwfs | |
sudo rm -rf bin sbin usr lib var/lib | |
cd / | |
sudo sync | |
fi | |
sudo umount /mnt | |
sudo umount /tmpsqfs | |
sudo umount /tmprwfs | |
sudo rmdir /tmpsqfs /tmprwfs | |
else | |
echo mounting existing image. | |
cd / | |
sudo mount -t ext3 -o loop /cdrom/casper-rw /mnt | |
sudo mksquashfs /mnt /cdrom/casper/update.squashfs -info -noappend -wildcards -e ${EXCLUDES} | |
if [ -e /cdrom/casper/update.squashfs ]; then | |
echo deleting moved files. | |
cd /mnt | |
sudo rm -rf bin sbin usr lib var/lib | |
cd / | |
sudo sync | |
fi | |
sudo umount /mnt | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment