From 4d54e7d0984dfdfe09b121dd845f6131c5b715d5 Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 28 Aug 2011 11:23:03 +0200 Subject: [PATCH] aufs: add basic support to AUFS2, requires kernel with aufs module or built-in --- ChangeLog | 4 ++++ defaults/initrd.scripts | 35 +++++++++++++++++++++++++++++++++++ defaults/linuxrc | 16 ++++++++++++---- doc/genkernel.8.txt | 3 +++ 4 files changed, 54 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index fdba306..0f04500 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ # Distributed under the GPL v2 # $Id$ + 28 Aug 2011; Fabio Erculiani 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 gen_compile.sh: gen_compile: correct MAKEOPTS usage on utils task diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 51ebcce..32e3417 100755 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -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 diff --git a/defaults/linuxrc b/defaults/linuxrc index 0843f5d..7aa11e3 100755 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -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 diff --git a/doc/genkernel.8.txt b/doc/genkernel.8.txt index 21c7919..bf621ce 100644 --- a/doc/genkernel.8.txt +++ b/doc/genkernel.8.txt @@ -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".