Mounting Filesystem over existing directory

Sameer Naik sameer.subscriptions at damagehead.com
Wed May 30 11:58:57 UTC 2012


Hello Laurent,

The techniques you have mentioned are definitely an option. I will
give aufs a honest try and fallback to whatever to you have mentioned
if turns out to too much of a hassle :)

Regards
~Sameer

On Wed, May 30, 2012 at 11:54 AM, Laurent Bercot
<ska-dietlibc at skarnet.org> wrote:
>> Consider that i have a readonly filesystem mounted at / and that the
>> /etc folder consists of some files. Is is possible to mount a ramfs
>> filesystem at /etc such that the existing files in the /etc partition
>> are still accessible and any new files written to the /etc partition
>> are saved in the ramfs (which will be lost upon reboot).
>
>  It *might* be possible with some funky Linux mount option I can't
> remember. But you don't actually *need* that, since what you want can
> be achieved in a portable way with just a tiny bit of scripting.
>
>  * Have /img/etc (or whatever directory you want in your root
> filesystem) contain your original /etc files.
>  * Have your original /etc be a set of symlinks to /img/etc. For instance,
> /etc/fstab is a symlink to /img/etc/fstab.
>  * When you create your tmpfs, also copy all of /img/etc to your new tmpfs.
>
>  mount -t tmpfs -o mode=0755 tmpfs /etc
>  cp -a /img/etc/* /etc/
>
>  Of course, that operation must be done atomically, i.e. no other
> process should be running when you're performing the mount+cp.
>
>  * That's it.
>
>  You'll probably want a writable filesystem for more than /etc though,
> so if you want to avoid multiplicating tmpfs mounts, adjust and adapt
> so that your new /etc is a subdirectory of your tmpfs.
>
> --
>  Laurent
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://lists.busybox.net/mailman/listinfo/busybox


More information about the busybox mailing list