Files
sablink-distro/sys-kernel/genkernel/files/3.4.14/0005-add-AUFS-support-inside-linuxrc-and-initramfs.patch
T

114 lines
3.1 KiB
Diff

From d5bc0dbaca0a0952e080634d1dfdb1dda64ba5fe Mon Sep 17 00:00:00 2001
From: Fabio Erculiani <lxnay@sabayon.org>
Date: Tue, 4 Jan 2011 23:45:40 +0100
Subject: [PATCH 5/5] add AUFS support inside linuxrc and initramfs.
If kernel is compiled with aufs support (which is not in the kernel
as of today) or aufs module is available, and cmdline contains "aufs"
the live system will boot using aufs.
This is just minimal support and requires to have aufs inside the
running kernel. Aufs module compilation might be added to the ebuild
in future.
---
defaults/initrd.scripts | 35 +++++++++++++++++++++++++++++++++++
defaults/linuxrc | 14 +++++++++++++-
2 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 447d632..7d2781a 100755
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -215,6 +215,13 @@ mount_sysfs() {
[ "$ret" -eq '0' ] || bad_msg "Failed to mount /sys!"
}
+aufs_setup_dir() {
+ mount -t aufs -o "br:$OVERLAY=rw:$2=ro" -- aufs $1
+ if [ "$?" -eq '0' ]; then
+ good_msg "Addition of $2 to $OVERLAY merged into $1"
+ fi
+}
+
findnfsmount() {
if [ "${IP}" != '' ] || busybox udhcpc -n -T 15 -q
then
@@ -1048,6 +1055,34 @@ getdvhoff() {
echo $(( $(hexdump -n 4 -s $((316 + 12 * $2)) -e '"%i"' $1) * 512))
}
+setup_aufs() {
+
+ # Directory used for rw changes in union mount filesystem
+ UNION=/aufs
+ OVERLAY=/overlay
+
+ mkdir -p "${UNION}"
+ mkdir -p "${OVERLAY}"
+ mount -t tmpfs none "${OVERLAY}"
+ good_msg "Loading aufs module (if module)"
+ modprobe aufs > /dev/null 2>&1
+
+ aufs_setup_dir "${UNION}" "${NEW_ROOT}/${FS_LOCATION}"
+
+ # setup internal mounts
+ mkdir -p "${UNION}/mnt/livecd"
+ if [ ! -e "${UNION}/mnt/cdrom" ]; then
+ mkdir "${UNION}/mnt/cdrom" -p
+ fi
+ mount --bind "${NEW_ROOT}/${FS_LOCATION}" "${UNION}/mnt/livecd"
+ mount --bind "${NEW_ROOT}/mnt/cdrom" "${UNION}/mnt/cdrom"
+
+ # Make sure fstab notes livecd is mounted ro. Makes system skip remount which fails on aufs
+ sed -e 's|\(.*\s/\s*tmpfs\s*\)defaults\(.*\)|\1defaults,ro\2|' "/${UNION}/etc/fstab" > "/${UNION}/etc/fstab.new"
+ mv "/${UNION}/etc/fstab.new" "/${UNION}/etc/fstab"
+
+}
+
setup_unionfs() {
local rw_dir=$1
local ro_dir=$2
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 59f1ea5..69c0d84 100755
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -218,6 +218,9 @@ do
keymap\=*)
keymap=`parse_opt "${x}"`
;;
+ aufs)
+ USE_AUFS_NORMAL=1
+ ;;
unionfs)
if [ ! -x /sbin/unionfs ]
then
@@ -630,7 +632,12 @@ then
fi
- if [ "${USE_UNIONFS_NORMAL}" = '1' ]
+ if [ "${USE_AUFS_NORMAL}" -eq '1' ]
+ then
+ good_msg 'Setting up aufs mounts'
+ setup_aufs
+ CHROOT="${UNION}"
+ elif [ "${USE_UNIONFS_NORMAL}" = '1' ]
then
setup_unionfs ${NEW_ROOT} ${NEW_ROOT}/${FS_LOCATION}
CHROOT=/union
@@ -707,6 +714,11 @@ else
setup_unionfs /union_changes ${NEW_ROOT}
mkdir -p ${UNION}/tmp/.initrd
fi
+ if [ "${USE_AUFS_NORMAL}" = '1' ]
+ then
+ setup_aufs
+ mkdir -p ${UNION}/tmp/.initrd
+ fi
fi
# Execute script on the cdrom just before boot to update things if necessary
--
1.7.3.2