Donate Share

aufs

Email Archive: aufs-users (read-only)

2006:
Jan
   
Feb
   
Mar
   
Apr
   
May
   
Jun
(1)
Jul
   
Aug
(9)
Sep
(6)
Oct
(5)
Nov
(6)
Dec
(16)
2007:
Jan
(37)
Feb
(138)
Mar
(102)
Apr
(62)
May
(31)
Jun
(92)
Jul
(71)
Aug
(16)
Sep
(103)
Oct
(76)
Nov
(50)
Dec
(47)
2008:
Jan
(56)
Feb
(58)
Mar
(100)
Apr
(101)
May
(89)
Jun
(32)
Jul
(57)
Aug
(73)
Sep
(40)
Oct
(72)
Nov
(96)
Dec
(31)
2009:
Jan
(43)
Feb
(130)
Mar
(130)
Apr
(120)
May
(68)
Jun
(31)
Jul
(63)
Aug
(39)
Sep
(30)
Oct
(48)
Nov
(22)
Dec
   
From: Philipp Wehrheim <flipstar@gm...> - 2007-10-19 15:39
Hey List,


I'm trying to use aufs in combination with initramfs and a mtd-flash
device but I can't really figure out how to do it.

What I want is:

- boot the kernel that starts the initramfs.
- the initramfs init checks if it can find a partition on the hd via
findfs
- and if it finds the partition mounts a squashfs(ro) and the hd
partition (rw) to /newroot
mount <hd> /aufs
cat <mtd> > /squashfs.img
mount -n /squashfs.img /squash
mount -n -t aufs -o br=/aufs:/squash none /newroot

- if the partition is not found it mounts some tmpfs and the squashfs
mount -n -t tmpfs /aufs
mount -n <mtd> /squash
mount -n -t aufs -o br=/aufs:/squash none /newroot

- in the end init calls
exec switch_root /newroot /sbin/init

Can this work?
Because there are some active mount when I call switchroot?

Can anybody share some experience please.

--
flip


    From: Michael Towers <mt.42@we...> - 2007-10-19 16:49
    Hi Philipp,

    Yes, something like that should work - it's more or less how most live
    CDs do it (though I can't speak for the details, I haven't used this
    method for a while - I am now using klibc instead of busybox and
    mounting aufs later).

    If you need example scripts you could look at linux-live, for example.

    As to the active mounts, so long as you don't want to manipulate them
    afterwards, that seems to be no big problem.

    Best wishes,
    mt

    Philipp Wehrheim wrote:
    > Hey List,
    >
    >
    > I'm trying to use aufs in combination with initramfs and a mtd-flash
    > device but I can't really figure out how to do it.
    >
    > What I want is:
    >
    > - boot the kernel that starts the initramfs.
    > - the initramfs init checks if it can find a partition on the hd via
    > findfs
    > - and if it finds the partition mounts a squashfs(ro) and the hd
    > partition (rw) to /newroot
    > mount <hd> /aufs
    > cat <mtd> > /squashfs.img
    > mount -n /squashfs.img /squash
    > mount -n -t aufs -o br=/aufs:/squash none /newroot
    >
    > - if the partition is not found it mounts some tmpfs and the squashfs
    > mount -n -t tmpfs /aufs
    > mount -n <mtd> /squash
    > mount -n -t aufs -o br=/aufs:/squash none /newroot
    >
    > - in the end init calls
    > exec switch_root /newroot /sbin/init
    >
    > Can this work?
    > Because there are some active mount when I call switchroot?
    >
    > Can anybody share some experience please.
    >
    > --
    > flip
    >
    >
    > -------------------------------------------------------------------------
    > This SF.net email is sponsored by: Splunk Inc.
    > Still grepping through log files to find problems? Stop.
    > Now Search log events and configuration files using AJAX and a browser.
    > Download your FREE copy of Splunk now >> http://get.splunk.com/
    >

    From: <flipstar@gm...> - 2007-10-19 18:44
    Hey Michael,

    thanks for your quick reply.

    > Hi Philipp,
    >
    > Yes, something like that should work - it's more or less how most live
    > CDs do it (though I can't speak for the details, I haven't used this
    > method for a while - I am now using klibc instead of busybox and
    > mounting aufs later).
    >
    > If you need example scripts you could look at linux-live, for example.
    >
    > As to the active mounts, so long as you don't want to manipulate them
    > afterwards, that seems to be no big problem.

    Yes I will have to manipulate the mountpoints I guess.
    It is possible that I'll have to unmount aufs, which will
    be "one layer below".
    Do you/anybody see a way how this could be achieved?

    --
    flip

    >
    > Best wishes,
    > mt
    >
    > Philipp Wehrheim wrote:
    > > Hey List,
    > >
    > >
    > > I'm trying to use aufs in combination with initramfs and a mtd-flash
    > > device but I can't really figure out how to do it.
    > >
    > > What I want is:
    > >
    > > - boot the kernel that starts the initramfs.
    > > - the initramfs init checks if it can find a partition on the hd via
    > > findfs
    > > - and if it finds the partition mounts a squashfs(ro) and the hd
    > > partition (rw) to /newroot
    > > mount <hd> /aufs
    > > cat <mtd> > /squashfs.img
    > > mount -n /squashfs.img /squash
    > > mount -n -t aufs -o br=/aufs:/squash none /newroot
    > >
    > > - if the partition is not found it mounts some tmpfs and the squashfs
    > > mount -n -t tmpfs /aufs
    > > mount -n <mtd> /squash
    > > mount -n -t aufs -o br=/aufs:/squash none /newroot
    > >
    > > - in the end init calls
    > > exec switch_root /newroot /sbin/init
    > >
    > > Can this work?
    > > Because there are some active mount when I call switchroot?
    > >
    > > Can anybody share some experience please.
    > >
    > > --
    > > flip
    > >
    > >
    > >
    > -------------------------------------------------------------------------
    > > This SF.net email is sponsored by: Splunk Inc.
    > > Still grepping through log files to find problems? Stop.
    > > Now Search log events and configuration files using AJAX and a browser.
    > > Download your FREE copy of Splunk now >> http://get.splunk.com/
    > >
    >
    >
    > -------------------------------------------------------------------------
    > This SF.net email is sponsored by: Splunk Inc.
    > Still grepping through log files to find problems? Stop.
    > Now Search log events and configuration files using AJAX and a browser.
    > Download your FREE copy of Splunk now >> http://get.splunk.com/

    --
    Psssst! Schon vom neuen GMX MultiMessenger gehört?
    Der kanns mit allen: http://www.gmx.net/de/go/multimessenger

    From: Michael Towers <mt.42@we...> - 2007-10-19 20:12
    flipstar@gm... wrote:
    > Hey Michael,
    >
    > thanks for your quick reply.
    >
    >> Hi Philipp,
    >>
    >> Yes, something like that should work - it's more or less how most live
    >> CDs do it (though I can't speak for the details, I haven't used this
    >> method for a while - I am now using klibc instead of busybox and
    >> mounting aufs later).
    >>
    >> If you need example scripts you could look at linux-live, for example.
    >>
    >> As to the active mounts, so long as you don't want to manipulate them
    >> afterwards, that seems to be no big problem.
    >
    > Yes I will have to manipulate the mountpoints I guess.
    > It is possible that I'll have to unmount aufs, which will
    > be "one layer below".
    > Do you/anybody see a way how this could be achieved?
    >

    I think here you need to consider very carefully what you want to
    achieve. Your situation as I understand it is that you intend to make
    the aufs your root filesystem (that's what the switch_root does). As far
    as I know (which, I admit, is not very far!) there is no way back to the
    initramfs root. But why would you want to get out of the aufs?

    I did consider several variations on the theme while working on a live
    CD construction kit (larch) for Archlinux. The current version doesn't
    use an aufs root but uses separate aufs mounts for all the root
    directories (/bin, /etc, /usr, and so on). It's quite a bit more
    complicated than the basic approach, using multistage system
    initialization and shutdown, but it does allow the aufs mounts to be
    unmounted in a fairly orderly manner at shutdown.

    This allows me to add sessions to the boot CD/DVD at shutdown, but -
    especially in view of the fact that many computers can't boot from
    multisession CD - I'm not completely convinced that the extra complexity
    is justified.

    There may of course be simpler ways to achieve this sort of thing. I,
    too, would be glad to hear of them!


    >> Philipp Wehrheim wrote:
    >>> Hey List,
    >>>
    >>>
    >>> I'm trying to use aufs in combination with initramfs and a mtd-flash
    >>> device but I can't really figure out how to do it.
    >>>
    >>> What I want is:
    >>>
    >>> - boot the kernel that starts the initramfs.
    >>> - the initramfs init checks if it can find a partition on the hd via
    >>> findfs
    >>> - and if it finds the partition mounts a squashfs(ro) and the hd
    >>> partition (rw) to /newroot
    >>> mount <hd> /aufs
    >>> cat <mtd> > /squashfs.img
    >>> mount -n /squashfs.img /squash
    >>> mount -n -t aufs -o br=/aufs:/squash none /newroot
    >>>
    >>> - if the partition is not found it mounts some tmpfs and the squashfs
    >>> mount -n -t tmpfs /aufs
    >>> mount -n <mtd> /squash
    >>> mount -n -t aufs -o br=/aufs:/squash none /newroot
    >>>
    >>> - in the end init calls
    >>> exec switch_root /newroot /sbin/init
    >>>
    >>> Can this work?
    >>> Because there are some active mount when I call switchroot?
    >>>
    >>> Can anybody share some experience please.
    >>>
    >>> --
    >>> flip
    >>>

    From: <sfjro@us...> - 2007-10-20 03:33
    Michael Towers:
    > flipstar@gm... wrote:
    :::
    > > Yes I will have to manipulate the mountpoints I guess.
    > > It is possible that I'll have to unmount aufs, which will
    > > be "one layer below".
    > > Do you/anybody see a way how this could be achieved?
    :::
    > initramfs root. But why would you want to get out of the aufs?

    The same question came to my mind.
    But I think what you need is 'mount --move' before switch_root.
    See also CVS_TREE/aufs/sample/diskless/linuxrc.

    When you use aufs as a root filesystem, you need to pay attention at
    shutdown. Generally the shutdown script remount the root filesystem as
    readonly because it cannot be unmounted.
    In aufs world, you also need to remount your writable branch filesystem
    as readonly, in order to flush/write-back to the branch.

    (from the aufs manual)
    ----------------------------------------------------------------------
    When your aufs is the root directory of your system, and your system
    tells you some of the filesystem were not unmounted cleanly, try these
    procedure when you shutdown your system.
    .nf
    # mount -no remount,ro /
    # for i in $writable_branches
    # do mount -no remount,ro $i
    # done
    .fi
    If your xino file is on a hard drive, you also need to specify
    `noxino' option or `xino=/your/tmpfs/xino' at remounting root
    directory.
    ----------------------------------------------------------------------


    Junjiro Okajima

    From: Michael Towers <mt.42@we...> - 2007-10-20 05:03
    sfjro@us... wrote:
    > Michael Towers:
    >> flipstar@gm... wrote:
    > :::
    >>> Yes I will have to manipulate the mountpoints I guess.
    >>> It is possible that I'll have to unmount aufs, which will
    >>> be "one layer below".
    >>> Do you/anybody see a way how this could be achieved?
    > :::
    >> initramfs root. But why would you want to get out of the aufs?
    >
    > The same question came to my mind.
    > But I think what you need is 'mount --move' before switch_root.
    > See also CVS_TREE/aufs/sample/diskless/linuxrc.
    >

    I see you are using initrd there. I am not at all sure about this, but I
    think the situation is a bit different with initramfs because it's not a
    'real' filesystem. I could even imagine it's possible to return to the
    initrd at shutdown, but I think with initramfs this won't work. Please
    correct me if I am wrong.

    Regards,
    mt

    > When you use aufs as a root filesystem, you need to pay attention at
    > shutdown. Generally the shutdown script remount the root filesystem as
    > readonly because it cannot be unmounted.
    > In aufs world, you also need to remount your writable branch filesystem
    > as readonly, in order to flush/write-back to the branch.
    >
    > (from the aufs manual)
    > ----------------------------------------------------------------------
    > When your aufs is the root directory of your system, and your system
    > tells you some of the filesystem were not unmounted cleanly, try these
    > procedure when you shutdown your system.
    > .nf
    > # mount -no remount,ro /
    > # for i in $writable_branches
    > # do mount -no remount,ro $i
    > # done
    > .fi
    > If your xino file is on a hard drive, you also need to specify
    > `noxino' option or `xino=/your/tmpfs/xino' at remounting root
    > directory.
    > ----------------------------------------------------------------------
    >
    >
    > Junjiro Okajima
    >

    From: <sfjro@us...> - 2007-10-20 05:05
    Michael Towers:
    > I see you are using initrd there. I am not at all sure about this, but I
    :::

    The sample in aufs cvs tree supports initramfs too.


    Junjiro Okajima

    From: Michael Towers <mt.42@we...> - 2007-10-20 05:17
    sfjro@us... wrote:
    > Michael Towers:
    >> I see you are using initrd there. I am not at all sure about this, but I
    > :::
    >
    > The sample in aufs cvs tree supports initramfs too.
    >
    >
    > Junjiro Okajima
    >

    Could it be that there is a difference in regard to this in pivot_root
    and switch_root? I haven't used root aufs for a while so I'm not sure
    exactly what code I used but I don't remember using mount --move and I
    don't remember any problems.

    Regards,
    mt

    From: <sfjro@us...> - 2007-10-20 05:27
    Michael Towers:
    > Could it be that there is a difference in regard to this in pivot_root
    > and switch_root? I haven't used root aufs for a while so I'm not sure
    > exactly what code I used but I don't remember using mount --move and I
    > don't remember any problems.

    In the case of pivot_root, you can still see the contents of old root
    which is the second parameter of pivot_root.
    In switch_root, which is basically equivalent to
    mount(".", "/", NULL, MS_MOVE, NULL)
    chroot(".")
    you can't see the contents of old root dir unless you move or copy them
    before switch_root. You can access the aufs branch filesystems if you
    mount --move them into under new root.
    If you don't need accessing branches manually after switch_root, you
    don't have move them. Aufs can access them if you don't move.


    Junjiro Okajima

    From: <flipstar@gm...> - 2007-10-20 10:21
    Hey everybody,

    thanks for your suggestions!

    I'll try on monday (when I have access to the SOC).

    To be more presiese of my setup:
    Im talking about a NAS that my or may not have a HD installd.
    The situation when I have to umount the HD (aufs) is when
    the user decides to reformat the hd or even change the partition layout.

    Mount move sounds promissing and I'll report if and how it works for me.

    Im now also thinking about exchanging the squash image with
    a ro jffs(2?) partition to save some space/ram.

    Have a nice weekend.

    --
    flip

    >
    > Michael Towers:
    > > Could it be that there is a difference in regard to this in pivot_root
    > > and switch_root? I haven't used root aufs for a while so I'm not sure
    > > exactly what code I used but I don't remember using mount --move and I
    > > don't remember any problems.
    >
    > In the case of pivot_root, you can still see the contents of old root
    > which is the second parameter of pivot_root.
    > In switch_root, which is basically equivalent to
    > mount(".", "/", NULL, MS_MOVE, NULL)
    > chroot(".")
    > you can't see the contents of old root dir unless you move or copy them
    > before switch_root. You can access the aufs branch filesystems if you
    > mount --move them into under new root.
    > If you don't need accessing branches manually after switch_root, you
    > don't have move them. Aufs can access them if you don't move.
    >
    >
    > Junjiro Okajima
    >
    > -------------------------------------------------------------------------
    > This SF.net email is sponsored by: Splunk Inc.
    > Still grepping through log files to find problems? Stop.
    > Now Search log events and configuration files using AJAX and a browser.
    > Download your FREE copy of Splunk now >> http://get.splunk.com/

    --
    Psssst! Schon vom neuen GMX MultiMessenger gehört?
    Der kanns mit allen: http://www.gmx.net/de/go/multimessenger

    From: Philipp Wehrheim <flipstar@gm...> - 2007-10-23 11:44
    Hey everybody,

    I just want to share my expirences with initramfs and aufs.
    Again I have to say that the kind manner in this list
    is something I really like.

    my initramfs structur looks like this:

    ./
    |-- aufs
    |-- bin
    | |-- busybox
    | |-- cat -> busybox
    | |-- cut -> busybox
    | |-- echo -> busybox
    | |-- findfs -> busybox
    | |-- grep -> busybox
    | |-- ls -> busybox
    | |-- mdev -> busybox
    | |-- mkdir -> busybox
    | |-- mount -> busybox
    | |-- msh -> busybox
    | |-- sh -> busybox
    | |-- switch_root -> busybox
    | |-- test -> busybox
    | `-- umount -> busybox
    |-- dev
    | `-- console
    |-- flashroot
    |-- init
    |-- newroot
    |-- proc
    `-- sys


    stuffed in a initramfs_data.cpio.gz its about 334K.


    The init script can be found below.

    --
    flip



    cat init
    #!/bin/sh
    #
    # simple phase 1 init script
    #
    # by: Philipp Wehrheim 20071023
    #
    # This file is released under the GPLv2.
    #
    export PATH="/bin"
    #
    # OVERLAYLABEL is the filesystem lable
    # of the overlay partition
    OVERLAYLABEL="Overlay"
    #
    # mount
    mount -n -t proc proc /proc
    mount -n -t sysfs sysfs /sys
    mount -n -t tmpfs tmpfs /dev
    #
    # mdev create devices
    mdev -s

    #
    # find mtd Ramdisk
    MTDRAMDISK=`cat /proc/mtd | grep Ramdisk | cut -d':' -f1`

    #
    # find the overlay partition
    #
    # WARNING: What happens if more than one Devices with the label is fond?
    echo "searching for filesystem $OVERLAYLABEL"
    PARTITION=`findfs LABEL=$OVERLAYLABEL 2>/dev/null`

    echo "PARTITION: $PARTITION"

    # if findfs found a partition try to mount it
    if test $? -eq 0 ; then
    echo "mounting /aufs partition"
    mount $PARTITION /aufs >/dev/null 2>&1
    fi

    # if the mount did not succeed
    if test $? -ne 0 ; then
    echo "mounting /aufs with tmpfs"
    mount -t tmpfs tmpfs -o size=10m /aufs >/dev/null 2>&1
    fi

    # extract squash image from flash
    cat /dev/$MTDRAMDISK > /squash.img

    # mount the squash.img
    mount -n -t squashfs -o loop /squash.img /flashroot

    # mount aufs and squash.img to newroot
    mount -n -t aufs -o br=/aufs:/flashroot none /newroot

    # create mountpoints for mount move
    mkdir /newroot/system/aufs
    mkdir /newroot/system/flashroot

    # move the mountpoints
    # into the new root
    mount --move /aufs /newroot/system/aufs
    mount --move /flashroot /newroot/system/flashroot

    # clean up
    umount -l /proc /sys /dev

    # switch root
    exec switch_root /newroot /sbin/init