pentoo-overlay/sys-kernel/genkernel/files/aufs-new.patch

975 lines
36 KiB
Diff
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

diff --git a/defaults/initrd.defaults b/defaults/initrd.defaults
index cbf18f3..94b45cc 100755
--- a/defaults/initrd.defaults
+++ b/defaults/initrd.defaults
@@ -12,6 +12,8 @@ BAD="\033[31;1m"
BOLD="\033[1m"
GOOD="\033[32;1m"
+# Sets the default collation order
+LC_COLLATE=C
# From KNOPPIX LINUXRC
# Reset fb color mode
RESET="]R"
@@ -58,6 +60,7 @@ KSUFF='.ko'
REAL_ROOT=''
CONSOLE='/dev/console'
NEW_ROOT='/newroot'
+RC_NO_UMOUNTS='/newroot|/mnt/aufs-dev|/mnt/aufs-rw-branch|/mnt/livecd|/mnt/cdrom|/.unions/memory|/.unions/memory/xino'
CDROOT='0'
CDROOT_DEV=''
CDROOT_TYPE='auto'
@@ -66,6 +69,10 @@ CDROOT_PATH='/mnt/cdrom'
# marker. It must exist RELATIVE to the cdroot.
CDROOT_MARKER='/livecd'
+# AUFS variables
+aufs=0
+aufs_union_file=/livecd.aufs
+
LOOPS='/livecd.loop /zisofs /livecd.squashfs /image.squashfs /livecd.gcloop'
DEFAULT_NFSOPTIONS="ro,nolock,rsize=1024,wsize=1024"
diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts
index 5ef5d0b..5a01986 100644
--- a/defaults/initrd.scripts
+++ b/defaults/initrd.scripts
@@ -177,6 +177,52 @@ devicelist(){
echo ${DEVICES}
}
+bootstrapFS() {
+ if [ 1 = "$aufs" ]; then
+ # Directories used for rw aufs mount filesystem
+ aufs_union=/union aufs_memory=/memory
+
+ # Mountpoint for the aufs dev
+ aufs_dev_mnt=/mnt/aufs-dev
+
+ if [ -z "$aufs_dev_uid" ]; then
+ aufs_branch=$aufs_memory/aufs-branch/default
+ else
+ aufs_branch=$aufs_memory/aufs-branch/$aufs_dev_uid
+ fi
+
+ mkdir -p $aufs_memory $aufs_union $aufs_dev_mnt
+ else
+ # Legacy SquashFS implementation
+ good_msg "Making tmpfs for ${NEW_ROOT}"
+ mount -n -t tmpfs tmpfs ${NEW_ROOT}
+ fi
+
+ # Setup the filesystem nodes and directories
+ for i in ${CDROOT_PATH} /mnt/livecd /mnt/key /mnt/gentoo /tmp /tmp/.initrd /dev /proc /run /sys; do
+ mkdir -p "${NEW_ROOT}${i}"
+ chmod 755 "${NEW_ROOT}${i}"
+ done
+
+ [ ! -d "${CDROOT_PATH}" ] && mkdir -p "${CDROOT_PATH}"
+ [ ! -e "${NEW_ROOT}/dev/null" ] && mknod -m 666 "${NEW_ROOT}"/dev/null c 1 3
+ [ ! -e "${NEW_ROOT}/dev/zero" ] && mknod -m 666 "${NEW_ROOT}"/dev/zero c 1 5
+ [ ! -e "${NEW_ROOT}/dev/console" ] && mknod -m 600 "${NEW_ROOT}"/dev/console c 5 1
+ [ ! -e "${NEW_ROOT}/dev/ttyS0" ] && mknod -m 660 "${NEW_ROOT}"/dev/ttyS0 c 4 64
+
+ # For SGI LiveCDs
+ if [ "${LOOPTYPE}" = "sgimips" ]; then
+ [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0
+ [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0
+ fi
+
+ # Required for splash to work. Not an issue with the initrd as this
+ # device isn't created there and is not needed.
+ for minor in 0 1 ; do
+ [ ! -e "${NEW_ROOT}/dev/$minor" ] && mknod -m 600 "${NEW_ROOT}/dev/tty$minor" c 4 $minor
+ done
+}
+
bootstrapCD() {
local DEVICES=
@@ -234,6 +280,219 @@ mount_sysfs() {
[ ${ret} -eq 0 ] || bad_msg "Failed to mount /sys!"
}
+# Insert a directory tree $2 to an union specified by $1
+# Top-level read-write branch is specified by it's index 0
+# $1 = union absolute path (starting with /)
+# $2 = path to data directory
+#
+union_insert_dir() {
+ # Always mount it over the precedent (add:1:)
+ if mount -n -o "remount,add:1:$2=rr" aufs "$1"; then
+ good_msg "Addition of $2 to $1 successful"
+ fi
+}
+
+# Insert all modules found in $1, usually $CDROOT_PATH
+# added to allow users to add their own apps.
+union_insert_modules() {
+ local module
+
+ for module in "$NEW_ROOT/$1/modules/"*.mo; do
+ union_mod "$module" || bad_msg "Unable to load module: '$module'"
+ done
+
+ for module in "$NEW_ROOT/$1/modules/"*.lzm; do
+ union_mod "$module" lzm || bad_msg "Unable to load module: '$module'"
+ done
+}
+
+# Helper function for union_insert_modules()
+union_mod() {
+ [ -e "$1" ] || return 0
+
+ local mod
+
+ mod=${1##*/}
+ mod=${mod%.*}
+
+ mkdir -p "$aufs_memory/modules/$mod" || return
+
+ if [ lzm = "$2" ]; then
+ mount -o loop,ro "$1" "$aufs_memory/modules/$mod"
+ fi
+
+ union_insert_dir "$aufs_union" "$aufs_memory/modules/$mod"
+}
+
+# Implements RC_NO_UMOUNTS variable into $CHROOT/etc/rc.conf for a cleaner shutdown process
+# This should really go into /etc/init.d/localmounts but until then we manually set this here
+conf_rc_no_umounts() {
+ local conf nomount fnd
+ conf=$CHROOT/etc/rc.conf fnd=0
+
+ if nomount=$(grep -n '^[[:blank:]]*RC_NO_UMOUNTS=' $conf); then
+ local i n data cmd IFS
+ IFS='
+'
+ set -- $nomount
+ unset IFS
+
+ for i; do
+ n=${i%%:*}; i=${i#"$n"}
+ data=${i#*=}
+
+ case $data in
+ "\"$RC_NO_UMOUNTS\""|"'$RC_NO_UMOUNTS'") fnd=1;;
+ *) cmd="$cmd$n d;"
+ esac
+ done
+
+ if [ -n "$cmd" ]; then
+ sed -i "${cmd%;}" $conf
+ test_success "Unable to edit rc.conf"
+ fi
+ fi
+
+ if [ 0 -eq "$fnd" ]; then
+ printf 'RC_NO_UMOUNTS="%s"\n' "$RC_NO_UMOUNTS" >> $conf
+ test_success "Unable to write to rc.conf"
+ fi
+}
+
+# is_int "$A" ["$B"..]
+# NOTE we consider a leading 0 false as it would be interpreted as octal
+is_int(){
+ local i
+ for i; do
+ case $i in
+ ''|*[!0-9]*|0?*) return 1 ;;
+ *) :
+ esac
+ done
+}
+
+# Function to create an ext2 fs on $aufs_dev, $aufs_dev_mnt mountpoint
+create_changefs() {
+ local size
+
+ while :; do
+ read -p '<< Size of file (Press Enter for default 256 MB): ' size
+
+ size=${size:-256}
+
+ if ! is_int $size; then
+ bad_msg "Non numeric value given for size, try again"
+ continue
+ elif [ 15 -ge "$size" ]; then
+ bad_msg "Please give a size of at least 16 Megabytes"
+ else
+ if dd if=/dev/zero "of=$aufs_dev_mnt$aufs_union_file" bs=1 seek="$size"M count=0 &>/dev/null; then
+ good_msg "Creation of $aufs_union_file, ${size}MB on $aufs_dev successful, formatting it ext2"
+ mke2fs -F "$aufs_dev_mnt$aufs_union_file" &>/dev/null
+ break
+ else
+ rm "$aufs_dev_mnt$aufs_union_file"
+ bad_msg "Unable to create ${aufs_union_file#*/} on $aufs_dev of ${size}MB"
+ bad_msg "Ensure your disk is not full or read-only"
+
+ read -p '<< Type "a" to abort, anything else to continue : ' doabort
+ if [ a = "$doabort" ]; then
+ bad_msg "Aborting creation of $aufs_union_file!"
+ umount "$aufs_dev" && rmdir "$aufs_dev_mnt"
+ return 1
+ fi
+ fi
+ fi
+ done
+ return $?
+}
+
+setup_aufs() {
+ bootstrapCD
+
+ if [ -n "$aufs_dev" ]; then
+ if [ ! -b $aufs_dev ]; then
+ bad_msg "$aufs_dev is not a valid block device"
+ local invalidblk=1
+ unset aufs_dev
+ else
+ good_msg "Mounting $aufs_dev to $aufs_memory for aufs support"
+
+ if ! mount -t auto "$aufs_dev" "$aufs_dev_mnt" &>/dev/null; then
+ bad_msg "Mount of $aufs_dev failed, falling back to ramdisk based aufs"
+ unset aufs_dev
+ fi
+ fi
+
+ # Check and attempt to create the AUFS union file
+ if [ ! -e $aufs_dev_mnt$aufs_union_file ] && [ -n "$aufs_dev" ]; then
+ create_changefs && mount -t auto "$aufs_dev_mnt$aufs_union_file" "$aufs_memory"
+ elif [ -n "$aufs_dev" ]; then
+ while :; do
+ if mount -t auto "$aufs_dev_mnt$aufs_union_file" "$aufs_memory" &>/dev/null; then
+ break
+ else
+ bad_msg "Mounting of changes file failed, Running e2fsck"
+
+ if ! hash e2fsck &>/dev/null; then
+ bad_msg "/sbin/e2fsck not found! aborting filesystem check"
+ bad_msg "Moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad"
+
+ mv "$aufs_dev_mnt$aufs_union_file" "$aufs_dev_mnt$aufs_union_file.bad"
+ break
+ fi
+
+ if e2fsck "$aufs_dev_mnt$aufs_union_file" &>/dev/null; then
+ good_msg "e2fsck ran successfully. Please verify data after bootup"
+ else
+ bad_msg "Your ${aufs_union_file#*/} image might be corrupted"
+ bad_msg "moving ${aufs_union_file#*/} to ${aufs_union_file#*/}.bad"
+
+ mv "$aufs_dev_mnt$aufs_union_file" "$aufs_dev_mnt$aufs_union_file.bad"
+ break
+ fi
+ fi
+ done
+ fi
+
+ # Mount tmpfs only in the case when aufs= boot parameter was
+ # empty or we were not able to mount the storage device
+ if [ 1 = "$CDROOT" ] && [ ! -f "$aufs_dev_mnt$aufs_union_file" ]; then
+ aufs_xino=$aufs_memory
+ umount "$aufs_memory" &>/dev/null
+
+ if [ 1 = "$invalidblk" ]; then
+ bad_msg "Verify that you've entered a valid device path"
+ else
+ bad_msg "Create an extfs ${aufs_union_file#*/} file on this device"
+ fi
+
+ bad_msg "if you wish to have aufs data persistency on reboots"
+ bad_msg "Falling back to ramdisk based aufs"
+ good_msg "Mounting ramdisk to $aufs_memory for aufs support"
+
+ mount -t tmpfs tmpfs "$aufs_memory"
+ else
+ aufs_xino=$aufs_memory/xino
+
+ mkdir -p "$aufs_xino"
+ mount -t tmpfs aufs-xino "$aufs_xino"
+ fi
+ else
+ aufs_xino=$aufs_memory
+
+ good_msg "Mounting ramdisk to $aufs_memory for aufs support"
+ mount -t tmpfs tmpfs "$aufs_memory"
+ fi
+
+ mkdir -p "$aufs_branch"
+ if ! mount -t aufs -n -o "nowarn_perm,udba=none,xino=$aufs_xino/.aufs.xino,br:$aufs_branch=rw" aufs "$aufs_union"; then
+ bad_msg "Can't setup union $aufs_union in directory!"
+ aufs=0
+ fi
+}
+
+
findnfsmount() {
if [ "${IP}" != '' ] || busybox udhcpc -n -T 15 -q
then
@@ -1181,31 +1440,19 @@ getdvhoff() {
}
setup_squashfs_aufs() {
- (
# Setup aufs directories and vars
- local overlay=/mnt/overlay
- local static=/mnt/livecd
+ aufs_rw_branch=/mnt/aufs-rw-branch aufs_ro_branch=/mnt/livecd
- for i in "${overlay}" "${static}"; do
- [ ! -d "${i}" ] && mkdir -p "${i}"
+ for dir in $aufs_rw_branch $aufs_ro_branch; do
+ [ ! -d $dir ] && mkdir -p "$dir"
done
- good_msg "Loading aufs"
- modprobe aufs > /dev/null 2>&1
-
- mount -t squashfs -o loop,ro "${CDROOT_PATH}/${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 (CDROOT_PATH) as well
- local new_cdroot="${NEW_ROOT}${CDROOT_PATH}"
- [ ! -d "${new_cdroot}" ] && mkdir -p "${new_cdroot}"
- mount --bind "${CDROOT_PATH}" "${new_cdroot}"
- )
+
+ good_msg "Loading aufs module ..."
+ modprobe aufs &>/dev/null
+
+ mount -t squashfs -o loop,ro "$CDROOT_PATH/$LOOPEXT$LOOP" "$aufs_ro_branch"
+ mount -t tmpfs none "$aufs_rw_branch"
+ mount -t aufs -o "br:$aufs_rw_branch:$aufs_ro_branch" aufs "$NEW_ROOT"
}
setup_unionfs() {
diff --git a/defaults/linuxrc b/defaults/linuxrc
index 6401614..3098866 100644
--- a/defaults/linuxrc
+++ b/defaults/linuxrc
@@ -251,7 +251,22 @@ do
keymap=${x#*=}
;;
aufs)
- USE_AUFS_NORMAL=1
+ aufs=1
+ ;;
+ aufs\=*)
+ aufs=1
+
+ if echo "${x#*=}" | grep , &>/dev/null; then
+ aufs_dev_uid=${x#*,}
+ aufs_dev=${x%,*}
+ else
+ aufs_dev=${x#*=}
+ fi
+ ;;
+ # Allow user to specify the modules location
+ aufs.modules\=*)
+ aufs_modules_dev=${x#*=}
+ aufs_modules=1
;;
unionfs)
if [ ! -x /sbin/unionfs ]
@@ -425,35 +440,17 @@ rundebugshell "before setting up the root filesystem"
if [ "${CDROOT}" = '1' ]
then
- good_msg "Making tmpfs for ${NEW_ROOT}"
- mount -n -t tmpfs tmpfs "${NEW_ROOT}"
+ # Setup the root filesystem
+ bootstrapFS
- for i in dev mnt proc run sys tmp mnt/livecd mnt/key tmp/.initrd mnt/gentoo
- do
- mkdir -p "${NEW_ROOT}/${i}"
- chmod 755 "${NEW_ROOT}/${i}"
- done
- [ ! -d "${CDROOT_PATH}" ] && mkdir -p "${CDROOT_PATH}"
- [ ! -e "${NEW_ROOT}/dev/null" ] && mknod -m 660 "${NEW_ROOT}"/dev/null c 1 3
- [ ! -e "${NEW_ROOT}/dev/zero" ] && mknod -m 660 "${NEW_ROOT}"/dev/zero c 1 5
- [ ! -e "${NEW_ROOT}/dev/console" ] && mknod -m 660 "${NEW_ROOT}"/dev/console c 5 1
- [ ! -e "${NEW_ROOT}/dev/ttyS0" ] && mknod -m 600 "${NEW_ROOT}"/dev/ttyS0 c 4 64
-
- # For SGI LiveCDs ...
- if [ "${LOOPTYPE}" = "sgimips" ]
- then
- [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0
- [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0
+ if [ 1 = "$aufs" ]; then
+ setup_aufs
+ CHROOT=$aufs_union
+ else
+ CHROOT=${NEW_ROOT}
fi
- # Required for splash to work. Not an issue with the initrd as this
- # device isn't created there and is not needed.
- for minor in 0 1 ; do
- [ ! -e "${NEW_ROOT}/dev/$minor" ] && mknod -m 600 "${NEW_ROOT}/dev/tty$minor" c 4 $minor
- done
-
- if [ "${REAL_ROOT}" != "/dev/nfs" ] && [ "${LOOPTYPE}" != "sgimips" ]
- then
+ if [ /dev/nfs != "$REAL_ROOT" ] && [ sgimips != "$LOOPTYPE" ] && [ 1 != "$aufs" ]; then
bootstrapCD
fi
@@ -485,7 +482,7 @@ then
fi
# Determine root device
-good_msg 'Determining root device...'
+good_msg 'Determining root device ...'
while true
do
while [ "${got_good_root}" != '1' ]
@@ -694,7 +691,7 @@ then
test_success 'Mount filesystem'
FS_LOCATION='mnt/livecd'
# Setup the loopback mounts, if unencrypted
- else
+ else # if [ -n "${CRYPT_ROOT}" ]
if [ "${LOOPTYPE}" = 'normal' ]
then
good_msg 'Mounting loop filesystem'
@@ -703,7 +700,7 @@ then
FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'squashfs' ]
then
- if [ "${USE_AUFS_NORMAL}" != '1' ]; then
+ if [ 1 != "$aufs" ]; then
good_msg 'Mounting squashfs filesystem'
_CACHED_SQUASHFS_PATH="${NEW_ROOT}/mnt/${LOOP}"
_squashfs_path="${CDROOT_PATH}/${LOOPEXT}${LOOP}" # Default to uncached
@@ -719,9 +716,10 @@ then
do_rundebugshell
}
else
- good_msg 'Mounting squashfs & aufs filesystems'
+ good_msg 'Mounting squashfs filesystem'
+
setup_squashfs_aufs
- test_success 'Mount filesystem'
+ test_success 'Mount aufs filesystem'
fi
FS_LOCATION='mnt/livecd'
elif [ "${LOOPTYPE}" = 'gcloop' ]
@@ -762,10 +760,61 @@ then
test_success 'mount /dev/loop0 /'
FS_LOCATION='mnt/livecd'
fi
+ fi # if [ -n "${CRYPT_ROOT}" ]
+
+ if [ 1 = "$aufs" ]; then
+ union_insert_dir "$CHROOT" "$aufs_ro_branch"
+
+ # Function to handle the RC_NO_UMOUNTS variable in $CHROOT/etc/rc.conf
+ conf_rc_no_umounts
+
+ # Fstab changes for aufs
+ if ! grep -q '^aufs' "$CHROOT/etc/fstab" 2>/dev/null; then
+ for dir in /var/tmp /tmp /usr/portage/distfiles; do
+ [ ! -d $CHROOT$dir ] && mkdir -p "$CHROOT$dir"
+ done
+
+ cat > "$CHROOT/etc/fstab" << FSTAB
+####################################################
+## ATTENTION: THIS IS THE FSTAB ON THE LIVECD ##
+## PLEASE EDIT THE FSTAB at /mnt/gentoo/etc/fstab ##
+####################################################
+aufs / aufs defaults 0 0
+vartmp /var/tmp tmpfs defaults 0 0
+tmp /tmp tmpfs defaults 0 0
+distfiles /usr/portage/distfiles tmpfs defaults 0 0
+FSTAB
+ fi
+
+ # When aufs.modules= is used
+ if [ 1 = "$aufs_modules" ]; then
+ warn_msg "Adding all modules in $aufs_modules_dev/modules/"
+
+ if [ -z "$aufs_modules_dev" ]; then
+ union_insert_modules "$CDROOT_PATH"
+ else
+ mkdir "$NEW_ROOT/mnt/modulesd"
+ mount "$aufs_modules_dev" "$NEW_ROOT/mnt/modulesd"
+ union_insert_modules "$NEW_ROOT/mnt/modulesd"
+ fi
+ fi
+
+ # Copy user keymap file
+ if [ -e /etc/sysconfig/keyboard ]; then
+ [ ! -d $CHROOT/etc/sysconfig ] && mkdir -p "$CHROOT/etc/sysconfig"
+ cp /etc/sysconfig/keyboard "$CHROOT/etc/sysconfig/"
+ fi
+
+ # Create the directories for our new union mounts
+ [ ! -d $CHROOT$NEW_ROOT ] && mkdir -p "$CHROOT$NEW_ROOT"
+
+ # Check to see if we successfully mounted $aufs_dev
+ if [ -n "$aufs_dev" ] && grep $aufs_dev /etc/mtab 1>/dev/null; then
+ [ ! -d $CHROOT$aufs_dev_mnt ] && mkdir -p "$CHROOT$aufs_dev_mnt"
+ mount --move "$aufs_dev_mnt" "$CHROOT$aufs_dev_mnt"
+ fi
fi
-
-
# Unpacking additional packages from NFS mount
# This is useful for adding kernel modules to /lib
# We do this now, so that additional packages can add whereever they want.
@@ -783,67 +832,70 @@ then
fi
- if [ "${USE_UNIONFS_NORMAL}" = '1' ]
- then
+ if [ "${USE_UNIONFS_NORMAL}" = '1' ]; then
setup_unionfs ${NEW_ROOT} /${FS_LOCATION}
CHROOT=/union
- elif [ "${USE_AUFS_NORMAL}" != '1' ]; then
-
- good_msg "Copying read-write image contents to tmpfs"
- # Copy over stuff that should be writable
- (cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a ${ROOT_TREES} "${NEW_ROOT}") || {
- bad_msg "Copying failed, dropping into a shell."
- do_rundebugshell
- }
-
- # Now we do the links.
- for x in ${ROOT_LINKS}
- do
- if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
- then
- ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
- else
- # List all subdirectories of x
- find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
- do
- # Strip the prefix of the FS_LOCATION
- directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
-
- # Skip this directory if we already linked a parent directory
- if [ "${current_parent}" != '' ]; then
- var=$(echo "${directory}" | grep "^${current_parent}")
- if [ "${var}" != '' ]; then
- continue
- fi
- fi
- # Test if the directory exists already
- if [ -e "/${NEW_ROOT}/${directory}" ]
- then
- # It does exist, link all the individual files
- for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory})
- do
- if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
- ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
- fi
- done
- else
- # It does not exist, make a link to the livecd
- ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
- current_parent="${directory}"
- fi
- done
- fi
- done
-
- mkdir initramfs proc tmp sys run 2>/dev/null
- chmod 1777 tmp
-
- # have handy /mnt/cdrom (CDROOT_PATH) as well
- _new_cdroot="${NEW_ROOT}${CDROOT_PATH}"
- [ ! -d "${_new_cdroot}" ] && mkdir -p "${_new_cdroot}"
- mount --bind "${CDROOT_PATH}" "${_new_cdroot}"
-
- fi
+ elif [ 1 != "$aufs" ]; then
+ good_msg "Copying read-write image contents to tmpfs"
+
+ # Copy over stuff that should be writable
+ (
+ cd "${NEW_ROOT}/${FS_LOCATION}"
+ cp -a ${ROOT_TREES} "${NEW_ROOT}"
+ ) ||
+ {
+ bad_msg "Copying failed, dropping into a shell."
+ do_rundebugshell
+ }
+
+ # Now we do the links.
+ for x in ${ROOT_LINKS}; do
+ if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]; then
+ ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
+ else
+ # List all subdirectories of x
+ find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null |
+ while read directory; do
+ # Strip the prefix of the FS_LOCATION
+ directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
+
+ # Skip this directory if we already linked a parent directory
+ if [ "${current_parent}" != '' ]; then
+ var=$(echo "${directory}" | grep "^${current_parent}")
+ if [ "${var}" != '' ]; then
+ continue
+ fi
+ fi
+ # Test if the directory exists already
+ if [ -e "/${NEW_ROOT}/${directory}" ]; then
+ # It does exist, link all the individual files
+ for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory}); do
+ if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
+ ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
+ fi
+ done
+ else
+ # It does not exist, make a link to the livecd
+ ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
+ current_parent="${directory}"
+ fi
+ done
+ fi
+ done
+
+ mkdir -p initramfs proc tmp run sys 2>/dev/null
+ chmod 1777 tmp
+
+ fi
+
+ # Have handy /mnt/cdrom (CDROOT_PATH) as well
+ if [ 1 = "$aufs" ]; then
+ [ ! -d "$CHROOT$CDROOT_PATH" ] && mkdir "$CHROOT$CDROOT_PATH"
+ mount --move "$CDROOT_PATH" "$CHROOT$CDROOT_PATH"
+ else
+ [ ! -d "$NEW_ROOT$CDROOT_PATH" ] && mkdir -p "$NEW_ROOT$CDROOT_PATH"
+ mount --move "$CDROOT_PATH" "$NEW_ROOT$CDROOT_PATH"
+ fi
#UML=$(cat /proc/cpuinfo|grep UML|sed -e 's|model name.*: ||')
#if [ "${UML}" = 'UML' ]
@@ -862,8 +914,12 @@ else
mount -t tmpfs tmpfs /union_changes
setup_unionfs /union_changes ${NEW_ROOT}
mkdir -p ${UNION}/tmp/.initrd
+ elif [ 1 = "$aufs" ]; then
+ union_insert_dir "$aufs_union" "$NEW_ROOT"
+ mkdir -p "$aufs_union/tmp/.initrd"
fi
-fi
+
+fi # if [ "${CDROOT}" = '1' ]
# Mount the additional things as required by udev & systemd
if [ -f ${NEW_ROOT}/etc/initramfs.mounts ]; then
@@ -894,7 +950,7 @@ for fs in $fslist; do
if ! $cmd; then
bad_msg "Unable to mount $dev for $fs"
fi
-done
+done # for fs in $fslist; do
# Execute script on the cdrom just before boot to update things if necessary
cdupdate
@@ -907,6 +963,23 @@ fi
verbose_kmsg
+if [ 1 = "$aufs" ]; then
+ aufs_union_memory=$CHROOT/.unions/memory
+
+ mkdir -p "$aufs_union_memory"
+ mount --move "$aufs_memory" "$aufs_union_memory"
+ test_success "Failed to move aufs $aufs_memory into the system root"
+
+ for dir in /mnt/gentoo $aufs_rw_branch $aufs_ro_branch; do
+ mkdir -p "$CHROOT$dir"
+ chmod 755 "$CHROOT$dir"
+ done
+
+ for mount in $aufs_rw_branch $aufs_ro_branch; do
+ mount --move "$mount" "$CHROOT$mount"
+ done
+fi
+
good_msg "Booting (initramfs)"
cd "${CHROOT}"
diff --git a/gen_cmdline.sh b/gen_cmdline.sh
index 7bee618..6ef6ae0 100755
--- a/gen_cmdline.sh
+++ b/gen_cmdline.sh
@@ -77,7 +77,7 @@ longusage() {
echo " autodetect."
echo " --makeopts=<makeopts> Make options such as -j2, etc..."
echo " --mountboot Mount BOOTDIR automatically if mountable"
- echo " --no-mountboot Don't mount BOOTDIR automatically"
+ echo " --no-mountboot Don't mount BOOTDIR automatically"
echo " --bootdir=<dir> Set the location of the boot-directory, default is /boot"
echo " --modprobedir=<dir> Set the location of the modprobe.d-directory, default is /etc/modprobe.d"
echo " Initialization"
@@ -501,14 +501,17 @@ parse_cmdline() {
;;
--minkernpackage=*)
CMD_MINKERNPACKAGE=`parse_opt "$*"`
+ [ ${CMD_MINKERNPACKAGE:0:1} != / ] && CMD_MINKERNPACKAGE=$PWD/$CMD_MINKERNPACKAGE
print_info 2 "MINKERNPACKAGE: ${CMD_MINKERNPACKAGE}"
;;
--modulespackage=*)
CMD_MODULESPACKAGE=`parse_opt "$*"`
+ [ ${CMD_MODULESPACKAGE:0:1} != / ] && CMD_MODULESPACKAGE=$PWD/$CMD_MODULESPACKAGE
print_info 2 "MODULESPACKAGE: ${CMD_MODULESPACKAGE}"
;;
--kerncache=*)
CMD_KERNCACHE=`parse_opt "$*"`
+ [ ${CMD_KERNCACHE:0:1} != / ] && CMD_KERNCACHE=$PWD/$CMD_KERNCACHE
print_info 2 "KERNCACHE: ${CMD_KERNCACHE}"
;;
--kernname=*)
diff --git a/gen_configkernel.sh b/gen_configkernel.sh
index a69c713..b935de8 100755
--- a/gen_configkernel.sh
+++ b/gen_configkernel.sh
@@ -118,12 +118,12 @@ config_kernel() {
fi
# Multipath
- if isTrue ${CMD_MULTIPATH}
- then
- sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
- sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MULTIPATH is.*/CONFIG_DM_MULTIPATH=m/g'
- sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MULTIPATH_RDAC is.*/CONFIG_DM_MULTIPATH_RDAC=m/g'
- fi
+ if isTrue ${CMD_MULTIPATH}
+ then
+ sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_BLK_DEV_DM is.*/CONFIG_BLK_DEV_DM=m/g'
+ sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MULTIPATH is.*/CONFIG_DM_MULTIPATH=m/g'
+ sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_DM_MULTIPATH_RDAC is.*/CONFIG_DM_MULTIPATH_RDAC=m/g'
+ fi
# Make sure dmraid modules are on if --dmraid
if isTrue ${CMD_DMRAID}
@@ -147,10 +147,10 @@ config_kernel() {
then
sed -i ${KERNEL_OUTPUTDIR}/.config -e 's/#\? \?CONFIG_FB_SPLASH is.*/CONFIG_FB_SPLASH=y/g'
fi
-
+
# VirtIO
- if isTrue ${CMD_VIRTIO}
- then
+ if isTrue ${CMD_VIRTIO}
+ then
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_PARAVIRT_GUEST.*/CONFIG_PARAVIRT_GUEST=y/g'
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_VIRTIO_PCI.*/CONFIG_VIRTIO_PCI=y/g'
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_VIRTIO_BALLOON.*/CONFIG_VIRTIO_BALLOON=y/g'
@@ -159,5 +159,5 @@ config_kernel() {
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_SCSI_VIRTIO.*/CONFIG_SCSI_VIRTIO=y/g'
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_VIRTIO_NET.*/CONFIG_VIRTIO_NET=y/g'
sed -i ${KERNEL_DIR}/.config -e 's/#\? \?CONFIG_VHOST_NET.*/CONFIG_VHOST_NET=y/g'
- fi
+ fi
}
diff --git a/gen_determineargs.sh b/gen_determineargs.sh
index 615f274..dc6b2c4 100755
--- a/gen_determineargs.sh
+++ b/gen_determineargs.sh
@@ -4,7 +4,7 @@
get_KV() {
if [ "${KERNEL_SOURCES}" = '0' -a -e "${KERNCACHE}" ]
then
- /bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config
+ /bin/tar -xj -C ${TEMP} -f ${KERNCACHE} kerncache.config
if [ -e ${TEMP}/kerncache.config ]
then
VER=`grep ^VERSION\ \= ${TEMP}/kerncache.config | awk '{ print $3 };'`
diff --git a/gen_initramfs.sh b/gen_initramfs.sh
index d5ee5f6..90a6547 100755
--- a/gen_initramfs.sh
+++ b/gen_initramfs.sh
@@ -15,7 +15,7 @@ CPIO_ARGS="--quiet -o -H newc --owner root:root --force-local"
# CC0 are compatible with the GNU GPL."
# (from https://www.gnu.org/licenses/license-list.html#CC0)
#
-# Written by:
+# Written by:
# - Sebastian Pipping <sebastian@pipping.org> (error checking)
# - Robin H. Johnson <robbat2@gentoo.org> (complete rewrite)
# - Richard Yao <ryao@cs.stonybrook.edu> (original concept)
@@ -942,7 +942,7 @@ create_initramfs() {
gzip) compress_ext='.gz' compress_cmd="${cmd_gzip} -f -9" ;;
lzop) compress_ext='.lzo' compress_cmd="${cmd_lzop} -f -9" ;;
esac
-
+
if [ -n "${compression}" ]; then
print_info 1 " >> Compressing cpio data (${compress_ext})..."
${compress_cmd} "${CPIO}" || gen_die "Compression (${compress_cmd}) failed"
diff --git a/gen_package.sh b/gen_package.sh
index 520d771..9dd166b 100755
--- a/gen_package.sh
+++ b/gen_package.sh
@@ -8,10 +8,18 @@ gen_minkernpackage() {
if [ "${KERNCACHE}" != "" ]
then
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernel-${ARCH}-${KV}
+ mv minkernpackage/{kernel-${ARCH}-${KV},kernel-${KNAME}-${ARCH}-${KV}}
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} config-${ARCH}-${KV}
+ mv minkernpackage/{config-${ARCH}-${KV},config-${KNAME}-${ARCH}-${KV}}
if isTrue "${GENZIMAGE}"
then
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} kernelz-${ARCH}-${KV}
+ mv minkernpackage/{kernelz-${ARCH}-${KV},kernelz-${KNAME}-${ARCH}-${KV}}
+ fi
+ if [ ! -f minkernpackage/kernel-${KNAME}-${ARCH}-${KV} \
+ -o ! -f minkernpackage/config-${KNAME}-${ARCH}-${KV} ];
+ then
+ gen_die "Cannot locate kernel binary"
fi
else
local tmp_kernel_binary=$(find_kernel_binary ${KERNEL_BINARY})
@@ -21,28 +29,34 @@ gen_minkernpackage() {
gen_die "Cannot locate kernel binary"
fi
cd "${KERNEL_OUTPUTDIR}"
- cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
- cp ".config" "${TEMP}/minkernpackage/config-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
+ cp "${tmp_kernel_binary}" "${TEMP}/minkernpackage/kernel-${KNAME}-${ARCH}-${KV}" || gen_die 'Could not the copy kernel for the min kernel package!'
+ cp ".config" "${TEMP}/minkernpackage/config-${KNAME}-${ARCH}-${KV}" || gen_die 'Could not the copy kernel config for the min kernel package!'
if isTrue "${GENZIMAGE}"
then
- cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KV}" || gen_die "Could not copy the kernelz for the min kernel package"
+ cp "${tmp_kernel_binary2}" "${TEMP}/minkernpackage/kernelz-${KNAME}-${ARCH}-${KV}" || gen_die "Could not copy the kernelz for the min kernel package"
fi
fi
if ! isTrue "${INTEGRATED_INITRAMFS}"
then
- [ "${BUILD_RAMDISK}" != '0' ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
+ [ "${BUILD_RAMDISK}" != '0' ] && { cp "${TMPDIR}/initramfs-${KV}" "${TEMP}/minkernpackage/initramfs-${KNAME}-${ARCH}-${KV}" || gen_die 'Could not copy the initramfs for the kernel package!'; }
fi
if [ "${KERNCACHE}" != "" ]
then
/bin/tar -xj -C ${TEMP}/minkernpackage -f ${KERNCACHE} System.map-${ARCH}-${KV}
+ mv minkernpackage/{System.map-${ARCH}-${KV},System.map-${KNAME}-${ARCH}-${KV}}
+ if [ ! -f System.map-${KNAME}-${ARCH}-${KV} ]
+ then
+ gen_die 'Could not copy System.map from kerncache for the kernel package!'
+ fi
else
- cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/minkernpackage/System.map-${ARCH}-${KV}" || gen_die 'Could not copy System.map for the kernel package!';
+ cp "${KERNEL_OUTPUTDIR}/System.map" "${TEMP}/minkernpackage/System.map-${KNAME}-${ARCH}-${KV}" || gen_die 'Could not copy System.map for the kernel package!';
fi
cd "${TEMP}/minkernpackage"
/bin/tar -jcpf ${MINKERNPACKAGE} * || gen_die 'Could not compress the kernel package!'
+ print_info 3 "Created minimal kernel package: $(readlink -f ${MINKERNPACKAGE})"
cd "${TEMP}" && rm -rf "${TEMP}/minkernpackage" > /dev/null 2>&1
}
@@ -55,11 +69,12 @@ gen_modulespackage() {
then
mkdir -p ${TEMP}/modulespackage/lib/modules
cp -r "${INSTALL_MOD_PATH}/lib/modules/${KV}" "${TEMP}/modulespackage/lib/modules"
- cd "${TEMP}/modulespackage"
+ cd "${TEMP}/modulespackage"
/bin/tar -jcpf ${MODULESPACKAGE} * || gen_die 'Could not compress the modules package!'
else
print_info 1 "Could not create a modules package ${INSTALL_MOD_PATH}/lib/modules/${KV} was not found"
fi
+ print_info 3 "Created modules package: $(readlink -f ${MODULESPACKAGE})"
cd "${TEMP}" && rm -rf "${TEMP}/modulespackage" > /dev/null 2>&1
}
gen_kerncache()
@@ -105,6 +120,7 @@ gen_kerncache()
cd "${TEMP}/kerncache"
/bin/tar -jcpf ${KERNCACHE} * || gen_die 'Could not compress the kernel package!'
+ print_info 3 "Created kernel cache: $(readlink -f ${KERNCACHE})"
cd "${TEMP}" && rm -rf "${TEMP}/kerncache" > /dev/null 2>&1
}
diff --git a/genkernel b/genkernel
index e6c7520..8b01662 100755
--- a/genkernel
+++ b/genkernel
@@ -2,7 +2,7 @@
# $Id$
PATH="${PATH}:/sbin:/usr/sbin"
-GK_V='3.4.49.2'
+GK_V='3.4.50'
# Set the default for TMPDIR. May be modified by genkernel.conf or the
# --tempdir command line option.
@@ -156,7 +156,7 @@ then
isTrue ${MOUNTBOOT} && print_info 2 'Skipping automatic mount of boot'
else
[[ -d ${BOOTDIR} ]] || gen_die "${BOOTDIR} is not a directory"
-
+
if ! egrep -q "[[:space:]]${BOOTDIR}[[:space:]]" /proc/mounts
then
if egrep -q "^[^#].+[[:space:]]${BOOTDIR}[[:space:]]" /etc/fstab
@@ -215,7 +215,7 @@ fi
#fi
KERNCACHE_IS_VALID=0
-if [ "${KERNCACHE}" != "" ]
+if [ "${KERNCACHE}" != "" ]
then
gen_kerncache_is_valid
fi
@@ -224,13 +224,13 @@ if [ ${BUILD_KERNEL} = '1' -a "${KERNCACHE_IS_VALID}" = '0' ]
then
# Configure kernel
config_kernel
-
+
# Make prepare
if [ "${ARCH_HAVENOPREPARE}" = '' ]
then
compile_generic prepare kernel
fi
-
+
# KV may have changed due to the configuration
get_KV
@@ -254,13 +254,13 @@ fi
if isTrue "${CMD_INSTALL}"
then
- if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
+ if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
then
gen_kerncache_extract_kernel
fi
fi
-if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
+if [ "${KERNCACHE}" != "" -a "${KERNCACHE_IS_VALID}" != "0" ]
then
[ "${BUILD_STATIC}" = '0' ] && gen_kerncache_extract_modules
gen_kerncache_extract_config
diff --git a/genkernel.conf b/genkernel.conf
index 09a7fcc..ad5750e 100644
--- a/genkernel.conf
+++ b/genkernel.conf
@@ -191,7 +191,7 @@ GK_SHARE="${GK_SHARE:-/usr/share/genkernel}"
# Location of the default cache
CACHE_DIR="/var/cache/genkernel"
# Location of DISTDIR, where our source tarballs are stored
-DISTDIR="${CACHE_DIR}/src"
+DISTDIR="${GK_SHARE}/distfiles"
# Log output file
LOGFILE="/var/log/genkernel.log"
# Debug Level