I am not sure whether it is a really good idea to rely on unionfs/aufs for such critical parts of the system as long as these modules are not part of the kernel - if something goes wrong with a new kernel, you won't be able to boot!
I use kamikaze sources which has unionfs in the kernel... so even if I mess something up, i'll still be able to mount it. Also, the directories in /var/run are not so critical as to make the system completely unbootable, it just makes it so many programs cannot start. That is still very fixable. Lastly, I could always just revert to my old kernel, fix whatever I did wrong and boot into the new one again =).
Moreover, you will not waste a loop device this way!
When I noticed the fact that it was unable to release the loop devices after unmounting, I increased the number of loop devices to 64... so I don't think wasting loop devices should be worried about.
Concerning /var/log, I have even more doubts, because if your system crashes you would probably like to be able to read its last words...
This is true, and is the one big drawback to having /var/log mounted in this way, I think the benefit of not having the disk spin up *almost* randomly to write the logs outweighs the potential loss of data. Also, if you crashed due to a reproduceable error, you could always just disable the init script and reproduce the error, then you'd be able to read the logs.
This has the disadvantage that all your squashfs images must remain on the same partition and that this partition is not necessarily the same as that of the original directory.
I see the problem of having all of them on one partition, but I prefer to have them in one easily manageable, central location. I don't see fact that the partition is not necessarily the same as that of the original directory as a disadvantage... am I missing something significant?
Last thing i've noticed is that when stopping and starting the initscript, it is not correctly releasing the loop device and when I try to manually do it, it gives me an error.
Upon (re)investigating this problem, it turns out that a loop device is only locked indefinitely if a new squashfs image is created. As an example, if I recently emerge --sync'ed, and I then re-squash the tree, I then notice that losetup -a has two /usr/portage devices, but mount only reports one as in use.
Code: Select all
kiki init.d # losetup -a
*snip*
/dev/loop/5: [0803]:2409097 (/var/squashfs/images/portage.sqfs)
/dev/loop/6: [0803]:1440 (/var/squashfs/images/portage.sqfs)
Code: Select all
kiki init.d # mount
*snip*
/var/squashfs/images/portage.sqfs on /var/squashfs/mnt/portage type squashfs (ro,loop=/dev/loop6)
unionfs on /usr/portage type unionfs (rw,dirs=/var/squashfs/tmp/portage=rw:/var/squashfs/mnt/portage=ro)
So I then do losetup -d /dev/loop/5 to try to get rid of the unused one, and I get this:
Code: Select all
kiki init.d # losetup -d /dev/loop/5
ioctl: LOOP_CLR_FD: Device or resource busy
Also,
fuser /dev/loop/5 and
lsof | grep /dev/loop/5 produce no output (nothing is using it).
Is this the problem you were having?
The usage of loop devices is the most serious drawback of the whole approach anyway, because it limits the number of directories which you can manage in this way dramatically.
Like I began to say earlier, I have max_loop=64 on my kernel line in grub which gives me 64 loop devices to play with... so I don't think i'll be running out any time soon, and if I do I can just increase it again.
But I would like to keep one init-script for each squashfs-mounted directory, so that you can easily force compression of a certain directory with
(e.g. for backup purposes which is particularly useful for the kernel). As I understand, you do not mind having separate /etc/init.d/squash* files, but you want only one /etc/init.d/squash_dir file. I am not convinced that this is a clearer configuration, because then in this file each variable would need an additional index to determine the name.
I was suggesting one squash_dir script in /etc/init.d which the initscripts you use is symlinked off of that (which you do) and one config file for all squash_* in /etc/conf.d (like /etc/conf.d/squash_unionfs or something) much like how /etc/conf.d/net works.
Do you know which mechanism is used in /etc/init.d/net.lo to read /etc/conf.d/net and to determine "lo"? When I glanced through it, it seems to make use of undocumented features (e.g. ${svclib}) so I am afraid such an initscript won't work after the next baselayout update.
I just had a look at the net.lo script and it does seem to use those undocumented features
Code: Select all
*snip*
local iface="${SVCNAME#*.}"
*snip*
So if you are afraid of using these which probably won't go away, but may, you could do some sed or awk magic in the file, parsing one line at a time and use a configuration like
Code: Select all
linux directory /usr/src/linux
linux order unionfs
This way is easier to manage config files for multiple squashfs images, and most importantly provides the potential for global variables such as
P.S. One more feature i'd like to request: The ability to add stuff to the depend() function w/o having to change the initscript. The net.lo script provides this functionality (although it does depend on undocumented features). See the net.lo script for an example.
P.P.S. My apologies for the long post.