[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#652459: marked as done (initramfs-tools: [patch] Please support mounting of /usr in the initramfs)



Your message dated Thu, 25 Sep 2014 09:19:44 +0000
with message-id <E1XX5DE-00081F-Bz@franck.debian.org>
and subject line Bug#652459: fixed in initramfs-tools 0.117
has caused the Debian Bug report #652459,
regarding initramfs-tools: [patch] Please support mounting of /usr in the initramfs
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
652459: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=652459
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: initramfs-tools
Version: 0.99
Severity: normal
Tags: patch

Hi,

In order to make the libraries and binaries in /usr available during
early boot, it would be desirable to be able to mount /usr in addition
to the rootfs inside the initramfs.

This patch implements a generic solution into two parts
1) Generation of /etc/fstab in the initramfs, including the rootfs
   and all the filesystems desired to be mounted
2) In local mountroot(), rather than just mounting the rootfs, loop
   over all mountpoints in /etc/fstab and mount them.

Note that this can replace the ROOT= option with the fstab entry alone,
though if set, ROOT= supercedes the root entry.  If the host /etc/fstab
does not contain a root entry, a dummy one is generated to ensure that
the rootfs is always the first entry in the initramfs fstab.  This
also means that the rootfs may be mounted with the options in
/etc/fstab.

This isn't intended to apply directly--it's more of a proof of concept.
I've tested the fstab generator; I haven't yet tested local mountroot().
Not being totally familiar with the initramfs internals, it might also
need:

- inclusion of modules for the additional filesystems
- ability to NFS mount filesystems other than the rootfs, i.e.
  it might need nfsmount for local (not that this is a useful use
  case)

Also note that the initramfs mount option (patch sent upstream) is not
yet in mount(8), and it would need to be before the option could be
used.


Regards,
Roger
>From 77ff35762d8038a546c342e5c2fb46dca5977db1 Mon Sep 17 00:00:00 2001
From: Roger Leigh <Roger Leigh rleigh@debian.org>
Date: Sat, 17 Dec 2011 11:47:59 +0000
Subject: [PATCH 1/2] Create /etc/fstab in the initramfs

Known special mounts (/, /etc, /usr), and those marked with the
"initramfs" option are added to /etc/fstab in the initramfs.
This means that it becomes possible to mount filesystems in
addition to root in the initramfs.

The primary motivation for this change is to permit /usr to be
mounted early, thus guaranteeing the presence of programs and
libraries from /usr during early boot, solving a long-standing
problem of needing to move an increasing number of libraries
and other files to the root filesystem.  It additionally permits
mounting of /etc separately, thereby permitting it to be
encrypted and/or writable while the root filesystem is
unencrypted and/or read-only.

Note that mount(8) breaks due to the new initramfs option being
unrecognised.  A patch to add this option has been submitted
upstream.  The option is filtered out in the generated fstab to
avoid breaking mount in the initramfs.
---
 mkinitramfs       |    3 ++
 scripts/functions |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)

diff --git a/mkinitramfs b/mkinitramfs
index 039eb81..8196b58 100755
--- a/mkinitramfs
+++ b/mkinitramfs
@@ -268,6 +268,9 @@ if [ -n "${ROOT:-}" ]; then
 	echo "ROOT=${ROOT}" > ${DESTDIR}/conf/conf.d/root
 fi
 
+# fstab creation
+create_initramfs_fstab > ${DESTDIR}/etc/fstab
+
 if ! command -v ldd >/dev/null 2>&1 ; then
 	echo "WARNING: no ldd around - install libc-bin" >&2
 	exit 1
diff --git a/scripts/functions b/scripts/functions
index 765802f..43c6adf 100644
--- a/scripts/functions
+++ b/scripts/functions
@@ -295,6 +295,84 @@ parse_numeric() {
 	fi
 }
 
+# Search for filesystems needed for mounting in the initramfs.  These
+# may be required filesystems such as the rootfs, or have initramfs in
+# the options.  Strip initramfs option from the generated fstab, in
+# case the initramfs mount chokes on it.  If no root filesystem exists
+# in /etc/fstab, create a dummy entry (needed so that the local mount
+# can fill in the missing parts from the command-line etc.).
+# Echos fstab format to stdout
+parse_initramfs_fstab () {
+	local rootfound copy file MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK
+	rootfound="no"
+	for file in /etc/fstab /etc/fstab.d/*.fstab; do
+		if [ -f "${file}" ]; then
+			while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK
+			do
+				case "${MNT_FSNAME}" in
+				    ""|\#*)
+					continue;;
+				esac
+
+				copy="no"
+
+				case "${MNT_DIR}" in
+				    /)
+					copy="yes"
+					rootfound="yes"
+					;;
+				    /etc|/usr)
+					copy="yes"
+					;;
+				esac
+
+				case "${MNT_OPTS}" in
+				    initramfs)
+					copy="yes"
+					MNT_OPTS="defaults"
+					;;
+				    initramfs,*)
+					copy="yes"
+					MNT_OPTS="${MNT_OPTS#initramfs,}"
+					;;
+				    *,initramfs)
+					copy="yes"
+					MNT_OPTS="${MNT_OPTS%,initramfs}"
+;;
+				    *,initramfs,*)
+					copy="yes"
+					MNT_OPTS="${MNT_OPTS/,initramfs,/,}"
+					;;
+				esac
+
+				if [ "${copy}" != "yes" ]; then
+				    continue;
+				fi
+
+				echo "${MNT_FSNAME} ${MNT_DIR} ${MNT_TYPE} ${MNT_OPTS} ${MNT_FREQ} ${MNT_PASS}"
+		done < "${file}"
+	fi
+	done
+
+	if [ "${rootfound}" = "no" ]; then
+	    MNT_FSNAME="no_root_filesystem_set_in_fstab"
+	    MNT_DIR="/"
+	    MNT_TYPE="unknown"
+	    MNT_OPTS="defaults"
+	    MNT_FREQ="0"
+	    MNT_PASS="0"
+	    echo "${MNT_FSNAME} ${MNT_DIR} ${MNT_TYPE} ${MNT_OPTS} ${MNT_FREQ} ${MNT_PASS}"
+	fi
+}
+
+# Create fstab for filesystems needed for mounting in the initramfs.
+# The list is sorted on the mountpoint to ensure that the rootfs is
+# listed first.
+# Echos fstab format to stdout
+create_initramfs_fstab () {
+	parse_initramfs_fstab | sort -k 2,2
+}
+
 # Parameter: device node to check
 # Echos fstype to stdout
 # Return value: indicates if an fs could be recognized
-- 
1.7.7.3

>From 70c85db65a7d7194b20acafd697cdbd468cf3b05 Mon Sep 17 00:00:00 2001
From: Roger Leigh <Roger Leigh rleigh@debian.org>
Date: Sat, 17 Dec 2011 13:08:14 +0000
Subject: [PATCH 2/2] scripts/local: Make use of fstab file for mounting
 rootfs

Mount all filesystems in fstab in addition to the rootfs.
---
 scripts/local |   81 ++++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 57 insertions(+), 24 deletions(-)

diff --git a/scripts/local b/scripts/local
index 521e69a..a049069 100644
--- a/scripts/local
+++ b/scripts/local
@@ -76,35 +76,68 @@ pre_mountroot()
 
 mountroot()
 {
-	pre_mountroot
+	while read MNT_FSNAME MNT_DIR MNT_TYPE MNT_OPTS MNT_FREQ MNT_PASS MNT_JUNK
+	do
+		# Skip comments
+		case "${MNT_FSNAME}" in
+		""|\#*)
+			continue;;
+		esac
 
-	# Get the root filesystem type if not set
-	if [ -z "${ROOTFSTYPE}" ]; then
-		FSTYPE=$(get_fstype "${ROOT}")
-	else
-		FSTYPE=${ROOTFSTYPE}
-	fi
+		# First fstab entry is guaranteed to be the rootfs
+		case "${MNT_DIR}" in
+		/)
+			# If ROOT is set, then override all fstab
+			# settings, otherwise set ROOT to the fstab
+			# value
+			if [ -n "${ROOT}" ]; then
+				MNT_FSNAME="${ROOT}"
+			else
+				ROOT="${MNT_FSNAME}"
+			fi
+			# Set mount options
+			if [ -n "${ROOTFLAGS}" ]; then
+				MNT_OPTS="${ROOTFLAGS},$MNT_OPTS"
+			else
+				MNT_OPTS="-o ${MNT_OPTS}"
+			fi
+			# Get the root filesystem type if not set
+			if [ -z "${ROOTMNT_TYPE}" ]; then
+				MNT_TYPE=$(get_fstype "${MNT_FSNAME}")
+			else
+				MNT_TYPE=${ROOTFSTYPE}
+			fi
 
-	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
-	run_scripts /scripts/local-premount
-	[ "$quiet" != "y" ] && log_end_msg
+			pre_mountroot
 
-	if [ "${readonly}" = "y" ]; then
-		roflag=-r
-	else
-		roflag=-w
-	fi
+			[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
+			run_scripts /scripts/local-premount
+			[ "$quiet" != "y" ] && log_end_msg
+			;;
+		*)
+		    MNT_OPTS="-o ${MNT_OPTS}"
+		    ;;
+		esac
 
-	# FIXME This has no error checking
-	modprobe ${FSTYPE}
+		if [ "${MNT_TYPE}" != "unknown" ]; then
+			MNT_TYPE="-t ${MNT_TYPE}"
+		else
+			MNT_TYPE=""
+		fi
 
-	# FIXME This has no error checking
-	# Mount root
-	if [ "${FSTYPE}" != "unknown" ]; then
-		mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}
-	else
-		mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt}
-	fi
+		if [ "${readonly}" = "y" ]; then
+			roflag=-r
+		else
+			roflag=-w
+		fi
+
+		# FIXME This has no error checking
+		modprobe ${MNT_TYPE}
+
+		# FIXME This has no error checking
+		# Mount filesystem
+		mount ${roflag} ${MNT_TYPE} ${MNT_OPTS} ${MNT_FSNAME} ${rootmnt}
+	done < "/etc/fstab"
 
 	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
 	run_scripts /scripts/local-bottom
-- 
1.7.7.3


--- End Message ---
--- Begin Message ---
Source: initramfs-tools
Source-Version: 0.117

We believe that the bug you reported is fixed in the latest version of
initramfs-tools, which is due to be installed in the Debian FTP archive.

A summary of the changes between this version and the previous one is
attached.

Thank you for reporting the bug, which will now be closed.  If you
have further comments please address them to 652459@bugs.debian.org,
and the maintainer will reopen the bug report if appropriate.

Debian distribution maintenance software
pp.
Michael Prokop <mika@debian.org> (supplier of updated initramfs-tools package)

(This message was generated automatically at their request; if you
believe that there is a problem with it please contact the archive
administrators by mailing ftpmaster@ftp-master.debian.org)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Format: 1.8
Date: Thu, 25 Sep 2014 10:49:26 +0200
Source: initramfs-tools
Binary: initramfs-tools
Architecture: source all
Version: 0.117
Distribution: unstable
Urgency: medium
Maintainer: Debian kernel team <debian-kernel@lists.debian.org>
Changed-By: Michael Prokop <mika@debian.org>
Description:
 initramfs-tools - generic modular initramfs generator
Closes: 652459 708000
Changes:
 initramfs-tools (0.117) unstable; urgency=medium
 .
   [ Roger Leigh ]
   * Generalise logic used for mounting the rootfs:
     - The existing logic was only intended for mounting the root
       filesystem; this logic has been refactored to support the
       mounting of multiple filesystems
     - Add a read_fstab_entry function to parse /etc/fstab on the
       mounted rootfs
     - Add resolve_device function which generalises the existing
       support for resolving LABEL= and UUID= strings to the
       corresponding device node
     - Add general mount_top, mount_premount and mount_bottom functions,
       with boot-script-specific variants for the local and nfs scripts;
       other boot scripts should override them if needed; the local and
       nfs scripts show how to use these to redirect to a specific
       implementation
     - Add general mountfs function to mount a filesystem from the
       /etc/fstab on the mounted rootfs.  This works for both local and
       nfs mounts; other boot scripts may override it to provide more
       specialised functionality
     - The local and nfs bottom scripts are run on demand if used; this
       does not interfere with alternative boot scripts being used,
       which will run first
     - Canonicalise device names to match util-linux mount behaviour;
       this ensures that "mount -a" in mountall does not try to mount
       /usr a second time (which it will attempt if the mounted device
       does not match the canonical device name)
   * Mount /usr if present in the /etc/fstab on the mounted rootfs
     (Closes: #652459)
   * Check filesystems prior to mounting (Closes: #708000):
     - Add empty /etc/fstab and symlink /etc/mtab to /proc/mounts;
       not essential, but quell a number of fsck warnings
     - Copy fsck and needed fsck helpers, plus logsave
     - Add checkfs function, based on the initscripts checkroot
       script
     - local mount functions will call checkfs prior to mounting
       the filesystem
 .
   [ Michael Prokop ]
   * [3298dea] Bump Standards-Version to 3.9.6
   * [a12d5ed] hooks/fsck: fall back to blkid, make sure fsck binary exists
     + install /sbin/sulogin
Checksums-Sha1:
 18c4e227b9379ee5034748ba6744d155467b3e53 1077 initramfs-tools_0.117.dsc
 1408c1149b1f70e5e9e51bcc34f6b9afb3b2c50d 77384 initramfs-tools_0.117.tar.xz
 0c02df5d1d01e4893c02efdac96816283de99d7d 92082 initramfs-tools_0.117_all.deb
Checksums-Sha256:
 c608d96b361344b723e025cf098b17c80957fbb04b1fc601fa0fbebba5446311 1077 initramfs-tools_0.117.dsc
 fec85cad0140a9a9a0a8147c1ac4a2d0af2ed280ab9e3e4ac0f4007740346546 77384 initramfs-tools_0.117.tar.xz
 922632f5d03e3eee272879d03d4a1d0e938535a06f4bf7fe0e2a0ee38b8c4a71 92082 initramfs-tools_0.117_all.deb
Files:
 6eda969c8808ed798f5f5a063c5fce8e 92082 utils optional initramfs-tools_0.117_all.deb
 7be363c9709c915b58a02cb5866d2a84 1077 utils optional initramfs-tools_0.117.dsc
 0d77dea2b9f46840e0cebc7a6b3be1b0 77384 utils optional initramfs-tools_0.117.tar.xz

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iEYEARECAAYFAlQj2mMACgkQ2N9T+zficuir4ACeKQJfDLIR/rvA0J9xSChIWqy/
OjYAniJnX/8ZpAN/Cncm9+glPJdAA+D3
=CP5g
-----END PGP SIGNATURE-----

--- End Message ---

Reply to: