The persistant usb drive uses a compressed read-only filesystem (squashfs) and overlays a writable filesystem layer on top that stores changed files. The writable filesystem is stored in a single file (like a zip file, but without the compression - it is actually ext3, but that is unimportant)
To put everything 'back together':
- Create the locations where things will go.
- Make the filesystems look like whole filesystems and not files (like they do at the moment.
- Join the filesystems together.
- Play around with the filesystem, like like chrooting
- Clean-up
I am assuming the usb drive is mounted on
/media/usb/
Change this to the directory that contains your persistant installation when you follow these instructions.
You need to be root, or prepend sudo
to every command
1. Creating stuff
Some directories need to be created:
/media/rootfs
- Location where we will put the read-only filesystem
/media/cow
- The location of the writable overlay
/media/persist_usb
- The location where the two filesystems will be joined
this can be done with
mkdir /media/{rootfs,cow,persist_usb}
2. Make files look like filesystems
First the compressed filesystem
mount -t squashfs -o loop,ro /media/usb/casper/filesystem.squashfs /media/rootfs
(Description: Mount the filesystem.squashfs
file on /media/rootfs
using squashfs)
Next the writable filesystem
mount -o loop,rw /media/usb/casper-rw /media/cow
(Description: Mount the file casper-rw' on '/media/cow
using a loop device)
3. Join the filesystems together
Now we are ready to join the two directories together
mount -t aufs -o dirs=/media/cow=rw:/media/rootfs=ro unionfs /media/persist_usb
(Description: Mount the union of the two directories using aufs (see unionfs) onto /media/persist_usb
with /media/cow
as writable and /media/rootfs
as readonly)
4. Play around
I'll leave that step up to you.
5. Cleanup
Once you have finished having fun with the installation (like chrooting) you need to get rid of the stuff that was created.
First to undo step 3:
umount /media/persist_usb
Next to undo step 2. We can do both filesystem together:
umount /media/{rootfs,cow}
(Description: unmount /media/rootfs
and /media/cow
)
Finally, to undo step 1:
rmdir /media/{rootfs,cow,persist_usb}
The changes you have made to the filesystem have been kept and you can now unmount the USB drive (if you want to).