Mail archive
alpine-devel

Re: [alpine-devel] Re: [Patch] mkinitfs - Support for rootfstype and rootflags

From: Natanael Copa <ncopa_at_alpinelinux.org>
Date: Wed, 8 Apr 2015 14:38:13 +0200

On Tue, 17 Mar 2015 08:36:26 +0200
Olivier Mauras <olivier_at_mauras.ch> wrote:

> Please find the update patch below:
>
> From acda031c6cc79f427b90d4395b95b3472b6c587d Mon Sep 17 00:00:00 2001
> From: Olivier Mauras <olivier_at_mauras.ch>
> Date: Mon, 2 Mar 2015 11:30:17 +0100
> Subject: Add support for two new options in the cmdline.
> - rootfstype: Let's you specify the type of filesystem for the root fs
> - rootflags: Let's you specify mount options for the root fs - If
> specified, "ro" flag won't be added by default
>
> This has primarily been setup to be able to boot Alpine guests from a
> 9P virtio share and make it easy to change mount options from
> libvirt/qemu
>
> diff --git a/initramfs-init.in b/initramfs-init.in
> index fd3e510..10116f9 100755
> --- a/initramfs-init.in
> +++ b/initramfs-init.in
> _at_@ -387,8 +387,8 @@ eval set -- `cat /proc/cmdline`
>
> myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm
> debug_init
> dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root
> - usbdelay ip alpine_repo apkovl alpine_start splash blacklist
> - overlaytmpfs"
> + rootfstype rootflags usbdelay ip alpine_repo apkovl alpine_start
> + splash blacklist overlaytmpfs"
>
> for opt; do
> case "$opt" in
> _at_@ -551,8 +551,20 @@ if [ -n "$KOPT_root" ]; then
> mount -t tmpfs root-tmpfs /media/root-rw
> mkdir -p /media/root-rw/work /media/root-rw/root
> mount -t overlay -o
> lowerdir=/media/root-ro,upperdir=/media/root-rw/root,workdir=/media/root-rw/work
> overlayfs $sysroot
> + elif [ -n $KOPT_rootfstype ]; then
> + if [ -n $KOPT_rootflags ]; then
> + rootflags="$KOPT_rootflags"
> + else
> + rootflags="ro"
> + fi
> + retry_mount -t $KOPT_rootfstype -o $rootflags $KOPT_root $sysroot
> 2>/dev/null
> else
> - retry_mount -o ro $KOPT_root $sysroot 2>/dev/null
> + if [ -n $KOPT_rootflags ]; then
> + rootflags="$KOPT_rootflags"
> + else
> + rootflags="ro"
> + fi
> + retry_mount -o $rootflags $KOPT_root $sysroot 2>/dev/null
> fi
>
> eend $?

Sorry for late answer.
To avoid if/else spagetti i suggest this instead, which should do exactly the same:
diff --git a/initramfs-init.in b/initramfs-init.in
index d687e64..42ee63f 100755
--- a/initramfs-init.in
+++ b/initramfs-init.in
_at_@ -388,7 +388,7 @@ eval set -- `cat /proc/cmdline`
 myopts="alpine_dev autodetect autoraid chart cryptroot cryptdm debug_init
        dma init_args keep_apk_new modules ovl_dev pkgs quiet root_size root
        usbdelay ip alpine_repo apkovl alpine_start splash blacklist
- overlaytmpfs"
+ overlaytmpfs rootfstype rootflags"
 
 for opt; do
        case "$opt" in
_at_@ -552,7 +552,9 @@ if [ -n "$KOPT_root" ]; then
                mkdir -p /media/root-rw/work /media/root-rw/root
                mount -t overlay -o lowerdir=/media/root-ro,upperdir=/media/root-rw/root,workdir=/media/root-rw/work overlayfs $sysroot
        else
- retry_mount -o ro $KOPT_root $sysroot 2>/dev/null
+ retry_mount ${KOPT_rootfstype:+-t} ${KOPT_rootfstype} \
+ -o ${KOPT_rootflags:-ro} \
+ $KOPT_root $sysroot 2>/dev/null
        fi
 
        eend $?


Do you think you could test it?

While at it i think I will replace the root_size boot opt with the new
rootflags.

-nc



---
Unsubscribe:  alpine-devel+unsubscribe_at_lists.alpinelinux.org
Help:         alpine-devel+help_at_lists.alpinelinux.org
---
Received on Wed Apr 08 2015 - 14:38:13 GMT