Squashfs Root on USB Flash drive. Need help with init
My goal is to get a semi-persistent Debian install booted from a USB flash drive using squashfs for the root filesystem. It's semi-persistent because I should be able to rerun mksquashfs to update the image, otherwise it's read only but the os thinks it's read-write because of unionfs.
I've read a few guides to creating this kind of setup and none seem to fit very well. I'm using the amd64 architecture, debian etch. I presently have a full-blown install to the USB drive that boots and works fine - this is the fully-persistent install I want to make semi-persistent, for privacy (in case someone steals the drive, they won't get my identity from web browser history etc.) and other reasons. I've installed squashfs-tools, squashfs-modules, unionfs-modules, and I've added squashfs and unionfs to /etc/modules. They modprobe just fine. I also installed initramfs-tools and casper if needed. I need an init script to mount the squashfs image and set it as the root filesystem, with unionfs making it appear read-write. I'm not yet comfortable with my ability to write an init. One problem I've run into in the past on other distros is that the init script does not wait for the usb drive to be recognized and added to /dev, and it panics because it couldn't find the root filesystem. Debian's init works fine in this regard. Because it DOESN'T have this common issue, I'd like to modify this script instead of creating a new one. I have other linux installs that I can mount the drive in if something needs to be performed not on the running system. |
I might be able to help, a little bit. I recently figured out how to do what I call "RAMboot", where the entire OS gets copied into a tmpfs ramdisk (not compressed). The result is just insanely fast.
In order to do it, I (temporarily) modified /usr/share/initramfs-tools/scripts/local. There's a line in this script where the root partition is mounted. I commented out that line, and replaced it with my custom script code to create the tmpfs root partition and untar an OS image into it. After modifying /usr/share/initramfs-tools/scripts/local, I created the custom initrd.img with: mkinitramfs -o /boot/initrd.img-2.6.18-6-686.ramboot And then I copied back the original /usr/share/initramfs-tools/scripts/local. It's important to copy back the original, because if you don't then it will be used the next time the kernel is updated. In GRUB, I created an entry based on the normal hard drive boot entry for "RAMboot". This custom entry used my custom initrd.img. Thus, I have the option to either boot up into my normal hard drive install, or I can boot up into the "RAMboot" OS. I boot into the normal hard drive install in order to add/remove software, configure things, and then create a new OS image based on it. Here are my modifications to /usr/share/initramfs-tools/scripts/local: Code:
[...] For your purposes, the OS image will be a squashfs file. You'll want to mount the "host" file system, perhaps /mnt/sda5, which contains the squashfs file. Then you'll mount the squashfs file system, and then merge it in (with what?) using unionfs. Hopefully, I've given you some ideas of how to go about implementing your concept. The basic idea is to modify the initramdisk image with your own custom script for mounting the root partition. |
That does help a bit.
I also found a guide with an init script at http://electronjunkie.wordpress.com/squashfs_script/ and a howto at http://www.ibiblio.org/pub/Linux/doc...shFS-HOWTO.pdf As I said, I'm no shell/init scripting expert, but it looks like what I would have to do is something like this: Code:
[...] |
Quote:
|
All times are GMT -5. The time now is 02:53 PM. |