clacker
Group: Members
Posts: 570
Joined: June 2004 |
|
Posted: April 30 2006,22:15 |
|
I tried making a version of mkwriteable for unionfs but I ran into a few snags. Most of the directories were easy to handle: I created two new directories in /ramdisk for each one, the first using the base name (for the new mount point) and the second with "_holder" added to the name (for the writeable area). Then I used the /KNOPPIX/whatever directory in the unions.
for example, for the bin directory I might do:
Code Sample | mkdir /ramdisk/bin mkdir /ramdisk/bin_holder mount -t unionfs -o dirs=/ramdisk/bin_holder=rw:/KNOPPIX/bin=ro unionfs /ramdisk/bin ln -sf /ramdisk/bin / |
Then I tried to streamline this for all of the directories I needed. The /etc and /var directories were harder, and require some care at shutdown. For /etc I had to make a copy of the existing /etc directory and copy the /etc/mtab into it. For whatever reason I wasn't able to overwrite the link from /var -> /ramdisk/var. I don't know why that happened either but I did work around it.
Code Sample | #!/bin/bash
#first handle the easy directories for i in bin boot lib sbin usr do mkdir /ramdisk/$i mkdir /ramdisk/${i}_holder mount -t unionfs -o dirs=/ramdisk/${i}_holder=rw:/KNOPPIX/$i=ro unionfs /ramdisk/$i ln -sf /ramdisk/$i / done
# Then take care of /etc by making a copy of it mkdir /ramdisk/etc_holder mkdir /ramdisk/etc cp -rp /etc /ramdisk/etc_copy mount -t unionfs -o dirs=/ramdisk/etc_holder=rw:/ramdisk/etc_copy=ro unionfs /ramdisk/etc # copy mtab or their may be problems since there is another entry in the current one cp /etc/mtab /ramdisk/etc/mtab rm -rf /etc ln -sf /ramdisk/etc /
# to undo the above section you need the following: # rm /etc # cp -r /ramdisk/etc_copy /etc # umount /ramdisk/etc
# now handle the /var directory mkdir /ramdisk/var mkdir /ramdisk/var_holder mv /ramdisk/var /ramdisk/var_old mount -t unionfs -o dirs=/ramdisk/var_holder=rw:/KNOPPIX/var=ro:/ramdisk/var_old=ro unionfs /ramdisk/var
# to undo the above section you need the following: # umount /ramdisk/var # rm -r /ramdisk/var # mv /ramdisk/var_old /ramdisk/var
|
It's a lot like mkwriteable, using links to unionfs mounted directories in the /ramdisk directory. Once you have the /ramdisk/bin mounted, you can use unionctl to meld more /opt/whatever/bin directories with it.
Is there a file that gets run at shutdown, before anything is unmounted automatically? If so I could add the lines I nned to unmount the /ramdisk/etc and /ramdisk/var direstories. The other directories work fine.
I didn't think it was as easy as mounting / as a union as read/write because /ramdisk is under / and there would be a nasty loop with the writeable part of the mount then.
|