[arch-releng] [PATCH] Mount tmpfs filesystems with mode=0755

Gerardo Exequiel Pozzi vmlinuz386 at yahoo.com.ar
Thu Jul 8 19:49:13 EDT 2010

  On 07/08/2010 04:51 AM, Thomas Bächler wrote:
> Am 06.07.2010 20:02, schrieb Gerardo Exequiel Pozzi:
>> the other fix a directory that is unreacheable outside initramfs (is not needed but fixed anyway).
> There's something I've been meaning to do for a while, but my time is
> very short recently. I'm telling you this, because I have the feeling if
> I do, there'll be a patch for it tomorrow :)
hehe :P
> I don't want to leave dangling mounts in initramfs that are invisible
> from the system. This would involve the following:
> 1) Don't bind /bootmnt into the root, but mount --move it there.
> 2) Don't bind _mnt_bind file systems into the root, but also mount
> --move (or mount them there directly)
> 3) After mounting, mount --move all aufs branches into a directory in
> the root.
> This way, nothing will be left in rootfs and invisible for us. I don't
> know a good name for a directory, so I'll stick to /bootmnt. A layout
> could be like:
> /bootmnt/
> /bootmnt/image (move the image here)
> /bootmnt/isomounts
> /bootmnt/isomounts/loop0 (move /mnt/loop0 here)
> /bootmnt/isomounts/loop1
> etc. What do you think?
If I understand corretly, please fix me if I am wrong, but.the problem 
is that mounts will be overlapped(*) with aufs mount stack, so at least 
one mountpoint must be unreacheable, this is where sqfs images are 
mounted /tmpfs (and /tmpfs.sqfs if copytoram is used).
(*) http://bugs.archlinux.org/task/17182
"Aufs rejects the branch which is an ancestor or a descendant of another 
branch. It is called overlapped. When the branch is loopback-mounted 
directory, aufs also checks the source fs-image file of loopback device. 
If the source file is a descendant of another branch, it will be 
rejected too" http://aufs.sourceforge.net/aufs2/man.html

Currently this is what commands are executed on normal boot (mkdir steps 

1) mount -t tmpfs -o size=75%,mode=0755 tmpfs /tmpfs
2) mount -r -t udf /dev/disk/by-label/ARCH_201007 /bootmnt
3) mount -t aufs -o dirs=/tmpfs=rw none /new_root
4) mount -r -t squashfs /bootmnt/overlay.sqfs /tmpfs/mnt/overlay
5) mount -t aufs -o remount,append:/tmpfs/mnt/overlay=ro none /new_root
6) mount -r -t squashfs /bootmnt/root-image.sqfs /tmpfs/mnt/root-image
7) mount -t aufs -o remount,append:/tmpfs/mnt/root-image=ro none /new_root
8) mount -o bind /bootmnt /new_root/bootmnt

What thing that may be improved here is:
* steps 4 and 6 instead of mounting on /tmpfs/mnt/imagename mount under 
    currently an ls /new_root/mnt will display empty dirs "overlay" and 
    Now looks like a bit recursive.
* execute 3) then 2) so medium will me mounted directly to /new_root/bootmnt

Doing that dirs that will be unreachable are:
/tmpfs that is needed for aufs writeable branch, maybe can be renamed to 
better named than tmpfs something like /rw_branch
/mnt/X where sqfs are mounted

when copytoram=y (steps for mkdir and cp to /tmpfs.sqfs skipped)

1) mount -t tmpfs -o size=75%,mode=0755 tmpfs /tmpfs
2) mount -r -t udf /dev/disk/by-label/ARCH_201007 /bootmnt
3) mount -t aufs -o dirs=/tmpfs=rw none /new_root
4) mount -t tmpfs -o size=75%,mode=0755 tmpfs /tmpfs.sqfs
5) mount -r -t squashfs /tmpfs.sqfs/overlay.sqfs /tmpfs/mnt/overlay
6) mount -t aufs -o remount,append:/tmpfs/mnt/overlay=ro none /new_root
7) mount -r -t squashfs /tmpfs.sqfs/overlay.sqfs /tmpfs/mnt/overlay
8) mount -t aufs -o remount,append:/tmpfs/mnt/overlay=ro none /new_root
9) umount /bootmnt

Same commands except that sqfs images are mounted from /tmpfs.sqfs 
directory on ram instead from /bootmnt (the boot medium)

- Same improvements here
- Same dirs unreachable plus /tmpfs.sqfs

_mnt_bind function can be replaced with _mnt_move or removed, since all 
things can be appended as aufs branch.

Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1

More information about the arch-releng mailing list