[initramfs]: porting loopback file system support patch to v0.133

explicitly install dependency linux-base

Signed-off-by: Guohan Lu <lguohan@gmail.com>
This commit is contained in:
Guohan Lu 2020-02-04 04:19:44 +00:00
parent e479a56db3
commit 124ce22b8c
5 changed files with 62 additions and 36 deletions

View File

@ -129,7 +129,7 @@ fi
## 2. mount supports squashfs ## 2. mount supports squashfs
## However, 'dpkg -i' plus 'apt-get install -f' will ignore the recommended dependency. So ## However, 'dpkg -i' plus 'apt-get install -f' will ignore the recommended dependency. So
## we install busybox explicitly ## we install busybox explicitly
sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install busybox sudo LANG=C chroot $FILESYSTEM_ROOT apt-get -y install busybox linux-base
echo '[INFO] Install SONiC linux kernel image' echo '[INFO] Install SONiC linux kernel image'
## Note: duplicate apt-get command to ensure every line return zero ## Note: duplicate apt-get command to ensure every line return zero
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/initramfs-tools-core_*.deb || \ sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/initramfs-tools-core_*.deb || \

View File

@ -1,6 +1,6 @@
# initramfs-tools package # initramfs-tools package
INITRAMFS_TOOLS_VERSION = 0.130 INITRAMFS_TOOLS_VERSION = 0.133
export INITRAMFS_TOOLS_VERSION export INITRAMFS_TOOLS_VERSION
INITRAMFS_TOOLS = initramfs-tools_$(INITRAMFS_TOOLS_VERSION)_all.deb INITRAMFS_TOOLS = initramfs-tools_$(INITRAMFS_TOOLS_VERSION)_all.deb

View File

@ -278,6 +278,7 @@ RUN apt-get update && apt-get install -y \
# For bash # For bash
texi2html \ texi2html \
# For initramfs # For initramfs
shellcheck \
bash-completion \ bash-completion \
{%- if CONFIGURED_ARCH == "amd64" %} {%- if CONFIGURED_ARCH == "amd64" %}
# For sonic vs image build # For sonic vs image build

View File

@ -5,12 +5,12 @@ SHELL = /bin/bash
MAIN_TARGET = initramfs-tools_$(INITRAMFS_TOOLS_VERSION)_all.deb MAIN_TARGET = initramfs-tools_$(INITRAMFS_TOOLS_VERSION)_all.deb
DERIVED_TARGETS = initramfs-tools-core_$(INITRAMFS_TOOLS_VERSION)_all.deb DERIVED_TARGETS = initramfs-tools-core_$(INITRAMFS_TOOLS_VERSION)_all.deb
INITRAMFS_TOOLS_REVISION = 18fc98e1b63b012f9bcf06ae3f5477872a5880c0 INITRAMFS_TOOLS_REVISION = 40e544e13611c1b2690eb99a8096fc16c1b9c74e
$(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% : $(addprefix $(DEST)/, $(MAIN_TARGET)): $(DEST)/% :
# Obtaining the initramfs-tools # Obtaining the initramfs-tools
rm -rf ./initramfs-tools rm -rf ./initramfs-tools
git clone --branch v0.130 https://salsa.debian.org/kernel-team/initramfs-tools.git ./initramfs-tools git clone --branch v0.133 https://salsa.debian.org/kernel-team/initramfs-tools.git ./initramfs-tools
# Patch # Patch
pushd ./initramfs-tools pushd ./initramfs-tools

View File

@ -13,11 +13,29 @@ And added NFS support! Full patch below...
live well, live well,
vagrant vagrant
---
init | 12 ++++++++++++
initramfs-tools.7 | 13 +++++++++++++
scripts/functions | 40 ++++++++++++++++++++++++++++++++++++++++
scripts/local | 7 ++++++-
scripts/nfs | 4 ++++
5 files changed, 75 insertions(+), 1 deletion(-)
diff --git a/init b/init diff --git a/init b/init
index abf7f25..2760bcb 100755 index 3dc9f6b..fe1005a 100755
--- a/init --- a/init
+++ b/init +++ b/init
@@ -98,6 +98,15 @@ for x in $(cat /proc/cmdline); do @@ -49,6 +49,9 @@ export ROOT=
export ROOTDELAY=
export ROOTFLAGS=
export ROOTFSTYPE=
+export LOOP=
+export LOOPFLAGS=
+export LOOPFSTYPE=
export IP=
export DEVICE=
export BOOT=
@@ -104,6 +107,15 @@ for x in $(cat /proc/cmdline); do
;; ;;
esac esac
;; ;;
@ -31,16 +49,17 @@ index abf7f25..2760bcb 100755
+ LOOPFSTYPE="${x#loopfstype=}" + LOOPFSTYPE="${x#loopfstype=}"
+ ;; + ;;
nfsroot=*) nfsroot=*)
# shellcheck disable=SC2034
NFSROOT="${x#nfsroot=}" NFSROOT="${x#nfsroot=}"
;; diff --git a/initramfs-tools.7 b/initramfs-tools.7
diff --git a/initramfs-tools.8 b/initramfs-tools.8 index 45b7de7..745e7a0 100644
index ea8c098..ce8e830 100644 --- a/initramfs-tools.7
--- a/initramfs-tools.8 +++ b/initramfs-tools.7
+++ b/initramfs-tools.8 @@ -53,6 +53,19 @@ The default is 180 seconds.
@@ -42,6 +42,19 @@ The default is 180 seconds. \fB\fI rootflags
set the file system mount option string. set the file system mount option string.
.TP +.TP
+\fB\fI loop +\fB\fI loop
+path within the original root file system to loop-mount and use as the +path within the original root file system to loop-mount and use as the
+real root file system. +real root file system.
@ -53,15 +72,14 @@ index ea8c098..ce8e830 100644
+\fB\fI loopfstype +\fB\fI loopfstype
+set the loop file system type, if applicable. +set the loop file system type, if applicable.
+ +
+.TP .TP
\fB\fI nfsroot \fB\fI nfsroot
can be either "auto" to try to get the relevant information from DHCP or a can be either "auto" to try to get the relevant information from DHCP or a
string of the form NFSSERVER:NFSPATH or NFSSERVER:NFSPATH:NFSOPTS.
diff --git a/scripts/functions b/scripts/functions diff --git a/scripts/functions b/scripts/functions
index 8c1bb1f..2ed3ce3 100644 index 077697f..a17e740 100644
--- a/scripts/functions --- a/scripts/functions
+++ b/scripts/functions +++ b/scripts/functions
@@ -426,6 +426,42 @@ mountfs() @@ -445,6 +445,46 @@ mountfs()
${type}_mount_fs "$1" ${type}_mount_fs "$1"
} }
@ -69,14 +87,14 @@ index 8c1bb1f..2ed3ce3 100644
+mount_loop_root() +mount_loop_root()
+{ +{
+ mkdir -p /host + mkdir -p /host
+ mount -o move ${rootmnt} /host + mount -o move "${rootmnt}" /host
+ loopfile="/host/${LOOP#/}" + loopfile="/host/${LOOP#/}"
+ +
+ while [ ! -e "$loopfile" ]; do + while [ ! -e "$loopfile" ]; do
+ panic "ALERT! $loopfile does not exist. Dropping to a shell!" + panic "ALERT! $loopfile does not exist. Dropping to a shell!"
+ done + done
+ +
+ if [ ${readonly} = y ]; then + if [ "${readonly?}" = "y" ]; then
+ roflag=-r + roflag=-r
+ else + else
+ roflag=-w + roflag=-w
@ -91,13 +109,17 @@ index 8c1bb1f..2ed3ce3 100644
+ +
+ # FIXME This has no error checking + # FIXME This has no error checking
+ modprobe loop + modprobe loop
+ modprobe ${FSTYPE} + modprobe "${FSTYPE}"
+ +
+ # FIXME This has no error checking + # FIXME This has no error checking
+ mount ${roflag} -o loop -t ${FSTYPE} ${LOOPFLAGS} "$loopfile" ${rootmnt} + if [ -z "${LOOPFLAGS}" ]; then
+ mount ${roflag} -o loop -t "${FSTYPE}" "$loopfile" "${rootmnt}"
+ else
+ mount ${roflag} -o loop -t "${FSTYPE}" "${LOOPFLAGS}" "$loopfile" "${rootmnt}"
+ fi
+ +
+ if [ -d ${rootmnt}/host ]; then + if [ -d "${rootmnt}/host" ]; then
+ mount -o move /host ${rootmnt}/host + mount -o move /host "${rootmnt}/host"
+ fi + fi
+} +}
+ +
@ -105,22 +127,22 @@ index 8c1bb1f..2ed3ce3 100644
# boot scripts. # boot scripts.
mountroot() mountroot()
diff --git a/scripts/local b/scripts/local diff --git a/scripts/local b/scripts/local
index f6424f0..072013e 100644 index a103e68..2ef6413 100644
--- a/scripts/local --- a/scripts/local
+++ b/scripts/local +++ b/scripts/local
@@ -135,7 +135,8 @@ local_mount_root() @@ -170,7 +170,8 @@ local_mount_root()
ROOT=$(resolve_device "$ROOT") local_premount
- if [ "${readonly}" = "y" ]; then - if [ "${readonly?}" = "y" ]; then
+ if [ "${readonly}" = "y" ] && \ + if [ "${readonly?}" = "y" ] && \
+ ([ -z "$LOOP" ] || [ "${FSTYPE#ntfs}" = "$FSTYPE" ]); then + { [ -z "$LOOP" ] || [ "${FSTYPE#ntfs}" = "$FSTYPE" ]; }; then
roflag=-r roflag=-r
else else
roflag=-w roflag=-w
@@ -153,6 +154,10 @@ local_mount_root() @@ -183,6 +184,10 @@ local_mount_root()
else if ! mount ${roflag} ${FSTYPE:+-t "${FSTYPE}"} ${ROOTFLAGS} "${ROOT}" "${rootmnt?}"; then
mount ${roflag} ${ROOTFLAGS} ${ROOT} ${rootmnt} panic "Failed to mount ${ROOT} as root file system."
fi fi
+ +
+ if [ "${LOOP}" ]; then + if [ "${LOOP}" ]; then
@ -130,13 +152,13 @@ index f6424f0..072013e 100644
local_mount_fs() local_mount_fs()
diff --git a/scripts/nfs b/scripts/nfs diff --git a/scripts/nfs b/scripts/nfs
index 1c29850..d382413 100644 index 40c92c7..dfa8e88 100644
--- a/scripts/nfs --- a/scripts/nfs
+++ b/scripts/nfs +++ b/scripts/nfs
@@ -72,6 +72,10 @@ nfs_mount_root_impl() @@ -73,6 +73,10 @@ nfs_mount_root_impl()
fi
nfsmount -o nolock ${roflag} ${NFSOPTS} ${NFSROOT} ${rootmnt} # shellcheck disable=SC2086
nfsmount -o nolock ${roflag} ${NFSOPTS} "${NFSROOT}" "${rootmnt?}"
+ +
+ if [ "${LOOP}" ]; then + if [ "${LOOP}" ]; then
+ mount_loop_root + mount_loop_root
@ -144,3 +166,6 @@ index 1c29850..d382413 100644
} }
# NFS root mounting # NFS root mounting
--
2.17.1