DSL Tips and Tricks :: unionfs examples



I am going to look into this as it relates to UCI type extensions and how much integration into core is possible given the size limitation.
I know I could make it work like dsl-n. But size constraints will prevent that level.



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.

Given the fact that DSL targers low(er) ram, old(er) machines.
My interest is more in the area of easily deploying uci type extenions. Using unionfs to avoid the library and binary pathing issues.  Also trying to achieve that mkwriteable is not necessary. That only mountpoints are used in the union.  This would be a watershed for our target base of less capable machines. For example, I just made an abiword.uuci.
I could certainly make dsl like dsl-n and have the entire fs writeable via a boot option in linuxrc. But then it would be easily overrun on trying to install every conceivable type of extension or package. I am not sure of proceeding in that direction.
Of course anyone can always write code to do what they want. Just wanted to share my thoughts and direction in this area.

Quote
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.


There are two levels of such a file.

/usr/local/bin/exitcheck is when just before X is stopped.
This will allow X type messages and prompts to still function before shutdown of X

/opt/powerdown.sh is the system wide power down script.
This is where I clean up dynamic icons and menus,unmount uci's etc.

Hello clacker!

Very nice work! Thanks for explaining some of the use of unionfs.dsl as well. It might come in handy for me since I'm making remasters quite frequently. Thanks again!

Have fun all you guys,
regards meo

Next Page...
original here.