aufs: add basic support to AUFS2, requires kernel with aufs module or built-in
authorFabio Erculiani <lxnay@sabayon.org>
Sun, 28 Aug 2011 09:23:03 +0000 (11:23 +0200)
committerFabio Erculiani <lxnay@sabayon.org>
Sun, 28 Aug 2011 09:23:03 +0000 (11:23 +0200)
ChangeLog
defaults/initrd.scripts
defaults/linuxrc
doc/genkernel.8.txt

index fdba306ed9df0e7aad75627400adc5dd82264017..0f04500fe107af32c1e5932b517431633843670e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,10 @@
 # Distributed under the GPL v2
 # $Id$
 
+  28 Aug 2011; Fabio Erculiani <lxnay@gentoo.org> defaults/initrd.scripts,
+  defaults/linuxrc, doc/genkernel.8.txt:
+  Add basic support to AUFS2, requires kernel with aufs module or built-in
+
   16 Aug 2011; Fabio Erculiani <lxnay@gentoo.org> gen_compile.sh:
   gen_compile: correct MAKEOPTS usage on utils task
 
index 51ebcce776616db93928184ae5d9eec7ff62fc37..32e3417f3ba2bfddf793ebc673bcf8f59e5102d3 100755 (executable)
@@ -924,6 +924,13 @@ sdelay() {
        then
                good_msg "Waiting ${SDELAY} seconds..."
                sleep ${SDELAY}
+       elif [ "${CDROOT}" = '1' ]
+       then
+               # many CD/DVD drives require extra sleep, especially when
+               # connected via USB. Many people reported that 1 second sleep
+               # is not enough on their notebooks, that's why sleep 3, when booting
+               # off a livecd is a better default.
+               sleep 3
        else
                good_msg 'Hint: Use parameter scandelay[=seconds] if you need waiting here'
        fi
@@ -1082,6 +1089,34 @@ getdvhoff() {
        echo $(( $(hexdump -n 4 -s $((316 + 12 * $2)) -e '"%i"' $1) * 512))
 }
 
+setup_squashfs_aufs() {
+       (
+       # Setup aufs directories and vars
+       local overlay=/mnt/overlay
+       local static=/mnt/livecd
+
+       for i in "${overlay}" "${static}"; do
+               [ ! -d "${i}" ] && mkdir -p "${i}"
+       done
+       good_msg "Loading aufs"
+       modprobe aufs > /dev/null 2>&1
+
+       cd "${NEW_ROOT}"
+       mount -t squashfs -o loop,ro "mnt/cdrom${LOOPEXT}${LOOP}" "${static}"
+       mount -t tmpfs none "${overlay}"
+       mount -t aufs -o br:${overlay}:${static} aufs "${NEW_ROOT}"
+
+       [ ! -d "${NEW_ROOT}${overlay}" ] && mkdir -p "${NEW_ROOT}${overlay}"
+       [ ! -d "${NEW_ROOT}${static}" ] && mkdir -p "${NEW_ROOT}${static}"
+       echo "aufs / aufs defaults 0 0" > "${NEW_ROOT}"/etc/fstab
+       for i in "${overlay}" "${static}"; do mount --move "${i}" "${NEW_ROOT}${i}"; done
+
+       # have handy /mnt/cdrom as well
+       [ ! -d "${NEW_ROOT}/mnt/cdrom" ] && mkdir -p "${NEW_ROOT}/mnt/cdrom"
+       mount --bind mnt/cdrom "${NEW_ROOT}/mnt/cdrom"
+       )
+}
+
 setup_unionfs() {
        local rw_dir=$1
        local ro_dir=$2
index 0843f5d8d4439e35646bc0c982a9614f0ef75778..7aa11e3923e6420955b378cabbb5a32c9f47cca8 100755 (executable)
@@ -213,6 +213,9 @@ do
                keymap\=*)
                        keymap=`parse_opt "${x}"`
                ;;
+               aufs)
+                       USE_AUFS_NORMAL=1
+               ;;
                unionfs)
                        if [ ! -x /sbin/unionfs ]
                        then
@@ -569,9 +572,14 @@ then
                        FS_LOCATION='mnt/livecd'
                elif [ "${LOOPTYPE}" = 'squashfs' ]
                then
-                       good_msg 'Mounting squashfs filesystem'
-                       mount -t squashfs -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
-                       test_success 'Mount filesystem'
+                       if [ "${USE_AUFS_NORMAL}" != '1' ]; then
+                               good_msg 'Mounting squashfs filesystem'
+                               mount -t squashfs -o loop,ro "${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
+                       else
+                               good_msg 'Mounting squashfs & aufs filesystems'
+                               setup_squashfs_aufs
+                               test_success 'Mount filesystem'
+                       fi
                        FS_LOCATION='mnt/livecd'
                elif [ "${LOOPTYPE}" = 'gcloop' ]
                then
@@ -636,7 +644,7 @@ then
        then
                setup_unionfs ${NEW_ROOT} ${NEW_ROOT}/${FS_LOCATION}
                CHROOT=/union
-       else
+       elif [ "${USE_AUFS_NORMAL}" != '1' ]; then
        
        good_msg "Copying read-write image contents to tmpfs"
        # Copy over stuff that should be writable
index 21c7919c3d2c75284a4b540491fb1861c5946c6e..bf621ce953d9b95ba4e0886041755415fed28846 100644 (file)
@@ -511,6 +511,9 @@ which the ramdisk scripts would recognize.
 *nounionfs*::
     Enables/disables UnionFS.
 
+*aufs*::
+    Enables support for AUFS2 (if available in the kernel).
+
 *real_rootflags*=<...>::
     Additional flags to mount the real root system with.
     For example *real_rootflags*=noatime would make "-o ro,noatime".