[arch-releng] [PATCH v2 1/1] add boot params archisoflags= and cow_flags= for mount options
From: Christian Hesse <mail@eworm.de> Having files on btrfs subvolumes requires to give mount options. Add boot params archisoflags= and cow_flags= for this purpose. Boot parameters could look like this: ... archisodevice=/dev/sdaX archisoflags=subvolume=isos cow_device=/dev/sdaX cow_flags=subvolume=persist ... Signed-off-by: Christian Hesse <mail@eworm.de> --- archiso/initcpio/hooks/archiso | 6 ++++-- docs/README.bootparams | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/archiso/initcpio/hooks/archiso b/archiso/initcpio/hooks/archiso index 3edc76c..b4c0b43 100644 --- a/archiso/initcpio/hooks/archiso +++ b/archiso/initcpio/hooks/archiso @@ -110,6 +110,7 @@ run_hook() { [[ -z "${archisobasedir}" ]] && archisobasedir="arch" [[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch" [[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}" + [[ -z "${archisoflags}" ]] && archisoflags="defaults" [[ -z "${cow_spacesize}" ]] && cow_spacesize="256M" if [[ -n "${cow_label}" ]]; then @@ -121,6 +122,7 @@ run_hook() { cow_persistent="N" fi + [[ -z "${cow_flags}" ]] && cow_flags="defaults" [[ -z "${cow_directory}" ]] && cow_directory="persistent_${archisolabel}/${arch}" [[ -z "${cow_chunksize}" ]] && cow_chunksize="8" @@ -135,7 +137,7 @@ archiso_mount_handler() { local newroot="${1}" if ! mountpoint -q "/run/archiso/bootmnt"; then - _mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r" + _mnt_dev -o "${archisoflags}" "${archisodevice}" "/run/archiso/bootmnt" "-r" if [[ "${copytoram}" != "y" ]]; then echo $(readlink -f ${archisodevice}) >> /run/archiso/used_block_devices fi @@ -164,7 +166,7 @@ archiso_mount_handler() { fi if [[ -n "${cow_device}" ]]; then - _mnt_dev "${cow_device}" "/run/archiso/cowspace" "-r" + _mnt_dev -o "${cow_flags}" "${cow_device}" "/run/archiso/cowspace" "-r" echo $(readlink -f ${cow_device}) >> /run/archiso/used_block_devices mount -o remount,rw "/run/archiso/cowspace" else diff --git a/docs/README.bootparams b/docs/README.bootparams index 356375d..9737554 100644 --- a/docs/README.bootparams +++ b/docs/README.bootparams @@ -21,6 +21,8 @@ INDEX Default: (unset) * archisodevice= Set the device node where archiso medium is located. Default: "/dev/disk/by-label/${archisolabel}" +* archisoflags= Set extra mount options, e.g. for btrfs subvolumes. + Default: defaults * archisobasedir= Set the base directory where all files reside. Default: "arch" * copytoram= If set to "y" or just "copytoram" without arguments, @@ -35,6 +37,8 @@ INDEX Default: (unset) * cow_device= Like cow_label= but using device node. Default: (unset) or "/dev/disk/by-label/${cow_label}" +* cow_flags= Set extra mount options, e.g. for btrfs subvolumes. + Default: defaults * cow_directory= Set a directory inside ${cow_device}. Default: "/persistent_${archisolabel}/${arch}" * cow_persistent= Set if snapshot is persistent "P" or non-persistent "N". -- 2.6.4
On 12/13/15 11:18, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
Having files on btrfs subvolumes requires to give mount options. Add boot params archisoflags= and cow_flags= for this purpose. Boot parameters could look like this:
... archisodevice=/dev/sdaX archisoflags=subvolume=isos cow_device=/dev/sdaX cow_flags=subvolume=persist ...
Signed-off-by: Christian Hesse <mail@eworm.de> --- archiso/initcpio/hooks/archiso | 6 ++++-- docs/README.bootparams | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/archiso/initcpio/hooks/archiso b/archiso/initcpio/hooks/archiso index 3edc76c..b4c0b43 100644 --- a/archiso/initcpio/hooks/archiso +++ b/archiso/initcpio/hooks/archiso @@ -110,6 +110,7 @@ run_hook() { [[ -z "${archisobasedir}" ]] && archisobasedir="arch" [[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch" [[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}" + [[ -z "${archisoflags}" ]] && archisoflags="defaults" [[ -z "${cow_spacesize}" ]] && cow_spacesize="256M"
if [[ -n "${cow_label}" ]]; then @@ -121,6 +122,7 @@ run_hook() { cow_persistent="N" fi
+ [[ -z "${cow_flags}" ]] && cow_flags="defaults" [[ -z "${cow_directory}" ]] && cow_directory="persistent_${archisolabel}/${arch}" [[ -z "${cow_chunksize}" ]] && cow_chunksize="8"
@@ -135,7 +137,7 @@ archiso_mount_handler() { local newroot="${1}"
if ! mountpoint -q "/run/archiso/bootmnt"; then - _mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r" + _mnt_dev -o "${archisoflags}" "${archisodevice}" "/run/archiso/bootmnt" "-r" if [[ "${copytoram}" != "y" ]]; then echo $(readlink -f ${archisodevice}) >> /run/archiso/used_block_devices fi @@ -164,7 +166,7 @@ archiso_mount_handler() { fi
if [[ -n "${cow_device}" ]]; then - _mnt_dev "${cow_device}" "/run/archiso/cowspace" "-r" + _mnt_dev -o "${cow_flags}" "${cow_device}" "/run/archiso/cowspace" "-r" echo $(readlink -f ${cow_device}) >> /run/archiso/used_block_devices mount -o remount,rw "/run/archiso/cowspace" else diff --git a/docs/README.bootparams b/docs/README.bootparams index 356375d..9737554 100644 --- a/docs/README.bootparams +++ b/docs/README.bootparams @@ -21,6 +21,8 @@ INDEX Default: (unset) * archisodevice= Set the device node where archiso medium is located. Default: "/dev/disk/by-label/${archisolabel}" +* archisoflags= Set extra mount options, e.g. for btrfs subvolumes. + Default: defaults * archisobasedir= Set the base directory where all files reside. Default: "arch" * copytoram= If set to "y" or just "copytoram" without arguments, @@ -35,6 +37,8 @@ INDEX Default: (unset) * cow_device= Like cow_label= but using device node. Default: (unset) or "/dev/disk/by-label/${cow_label}" +* cow_flags= Set extra mount options, e.g. for btrfs subvolumes. + Default: defaults * cow_directory= Set a directory inside ${cow_device}. Default: "/persistent_${archisolabel}/${arch}" * cow_persistent= Set if snapshot is persistent "P" or non-persistent "N".
breaks boot because # args: device, mountpoint, flags _mnt_dev() { but called as _mnt_dev -o "${archisoflags}" "${archisodevice}" "/run/archiso/bootmnt" "-r"
Gerardo Exequiel Pozzi <vmlinuz386@gmail.com> on Mon, 2016/02/01 22:07:
breaks boot
Uh, this is borked completely... Looks like I was in complete lack of sleep when I sent this patch. I will reply with something that should work. :-p Give it some testing... -- main(a){char*c=/* Schoene Gruesse */"B?IJj;MEH" "CX:;",b;for(a/* Chris get my mail address: */=0;b=c[a++];) putchar(b-1/(/* gcc -o sig sig.c && ./sig */b/42*2-3)*42);}
From: Christian Hesse <mail@eworm.de> Fixes: 03c296cb4f031148f657b8924460a30c5c9dfecc Signed-off-by: Christian Hesse <mail@eworm.de> --- archiso/initcpio/hooks/archiso | 14 +++++++------- archiso/initcpio/hooks/archiso_loop_mnt | 3 ++- docs/README.bootparams | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/archiso/initcpio/hooks/archiso b/archiso/initcpio/hooks/archiso index b4c0b43..fb76327 100644 --- a/archiso/initcpio/hooks/archiso +++ b/archiso/initcpio/hooks/archiso @@ -33,7 +33,7 @@ _mnt_dmsnapshot() { dmsetup create ${dm_snap_name} --table "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} ${cow_chunksize}" - _mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w" + _mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w" "defaults" echo $(readlink -f /dev/mapper/${dm_snap_name}) >> /run/archiso/used_block_devices } @@ -65,14 +65,15 @@ _mnt_sfs() { fi sfs_dev=$(losetup --find --show --read-only "${img}") echo ${sfs_dev} >> /run/archiso/used_block_devices - _mnt_dev "${sfs_dev}" "${mnt}" "-r" + _mnt_dev "${sfs_dev}" "${mnt}" "-r" "defaults" } -# args: device, mountpoint, flags +# args: device, mountpoint, flags, opts _mnt_dev() { local dev="${1}" local mnt="${2}" local flg="${3}" + local opts="${4}" mkdir -p "${mnt}" @@ -85,7 +86,7 @@ _mnt_dev() { launch_interactive_shell done - if mount "${flg}" "${dev}" "${mnt}"; then + if mount -o "${opts}" "${flg}" "${dev}" "${mnt}"; then msg ":: Device '${dev}' mounted successfully." else echo "ERROR; Failed to mount '${dev}'" @@ -110,7 +111,6 @@ run_hook() { [[ -z "${archisobasedir}" ]] && archisobasedir="arch" [[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch" [[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}" - [[ -z "${archisoflags}" ]] && archisoflags="defaults" [[ -z "${cow_spacesize}" ]] && cow_spacesize="256M" if [[ -n "${cow_label}" ]]; then @@ -137,7 +137,7 @@ archiso_mount_handler() { local newroot="${1}" if ! mountpoint -q "/run/archiso/bootmnt"; then - _mnt_dev -o "${archisoflags}" "${archisodevice}" "/run/archiso/bootmnt" "-r" + _mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r" "defaults" if [[ "${copytoram}" != "y" ]]; then echo $(readlink -f ${archisodevice}) >> /run/archiso/used_block_devices fi @@ -166,7 +166,7 @@ archiso_mount_handler() { fi if [[ -n "${cow_device}" ]]; then - _mnt_dev -o "${cow_flags}" "${cow_device}" "/run/archiso/cowspace" "-r" + _mnt_dev "${cow_device}" "/run/archiso/cowspace" "-r" "${cow_flags}" echo $(readlink -f ${cow_device}) >> /run/archiso/used_block_devices mount -o remount,rw "/run/archiso/cowspace" else diff --git a/archiso/initcpio/hooks/archiso_loop_mnt b/archiso/initcpio/hooks/archiso_loop_mnt index f95a47d..2e99404 100644 --- a/archiso/initcpio/hooks/archiso_loop_mnt +++ b/archiso/initcpio/hooks/archiso_loop_mnt @@ -2,6 +2,7 @@ run_hook () { [[ -n "${img_label}" ]] && img_dev="/dev/disk/by-label/${img_label}" + [[ -z "${img_flags}" ]] && img_flags="defaults" if [[ -n "${img_dev}" && -n "${img_loop}" ]]; then mount_handler="archiso_loop_mount_handler" fi @@ -13,7 +14,7 @@ archiso_loop_mount_handler () { local _dev_loop msg ":: Setup a loop device from ${img_loop} located at device ${img_dev}" - _mnt_dev "${img_dev}" "/run/archiso/img_dev" "-r" + _mnt_dev "${img_dev}" "/run/archiso/img_dev" "-r" "${img_flags}" if [[ "${copytoram}" != "y" ]]; then echo $(readlink -f ${img_dev}) >> /run/archiso/used_block_devices fi diff --git a/docs/README.bootparams b/docs/README.bootparams index 9737554..77161df 100644 --- a/docs/README.bootparams +++ b/docs/README.bootparams @@ -21,8 +21,6 @@ INDEX Default: (unset) * archisodevice= Set the device node where archiso medium is located. Default: "/dev/disk/by-label/${archisolabel}" -* archisoflags= Set extra mount options, e.g. for btrfs subvolumes. - Default: defaults * archisobasedir= Set the base directory where all files reside. Default: "arch" * copytoram= If set to "y" or just "copytoram" without arguments, @@ -125,6 +123,8 @@ INDEX Default: (unset) * img_dev= Device where archiso-image.iso reside. Default: (unset) or "/dev/disk/by-label/${img_label}" +* img_flags= Set extra mount options, e.g. for btrfs subvolumes. + Default: defaults * img_loop= Full path where archiso-image.iso is located on ${img_dev} Default: (unset) -- 2.7.0
On 02/02/16 11:45, Christian Hesse wrote:
From: Christian Hesse <mail@eworm.de>
Fixes: 03c296cb4f031148f657b8924460a30c5c9dfecc Signed-off-by: Christian Hesse <mail@eworm.de> --- archiso/initcpio/hooks/archiso | 14 +++++++------- archiso/initcpio/hooks/archiso_loop_mnt | 3 ++- docs/README.bootparams | 4 ++-- 3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/archiso/initcpio/hooks/archiso b/archiso/initcpio/hooks/archiso index b4c0b43..fb76327 100644 --- a/archiso/initcpio/hooks/archiso +++ b/archiso/initcpio/hooks/archiso @@ -33,7 +33,7 @@ _mnt_dmsnapshot() {
dmsetup create ${dm_snap_name} --table "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} ${cow_chunksize}"
- _mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w" + _mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w" "defaults" echo $(readlink -f /dev/mapper/${dm_snap_name}) >> /run/archiso/used_block_devices }
@@ -65,14 +65,15 @@ _mnt_sfs() { fi sfs_dev=$(losetup --find --show --read-only "${img}") echo ${sfs_dev} >> /run/archiso/used_block_devices - _mnt_dev "${sfs_dev}" "${mnt}" "-r" + _mnt_dev "${sfs_dev}" "${mnt}" "-r" "defaults" }
-# args: device, mountpoint, flags +# args: device, mountpoint, flags, opts _mnt_dev() { local dev="${1}" local mnt="${2}" local flg="${3}" + local opts="${4}"
mkdir -p "${mnt}"
@@ -85,7 +86,7 @@ _mnt_dev() { launch_interactive_shell done
- if mount "${flg}" "${dev}" "${mnt}"; then + if mount -o "${opts}" "${flg}" "${dev}" "${mnt}"; then msg ":: Device '${dev}' mounted successfully." else echo "ERROR; Failed to mount '${dev}'" @@ -110,7 +111,6 @@ run_hook() { [[ -z "${archisobasedir}" ]] && archisobasedir="arch" [[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch" [[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}" - [[ -z "${archisoflags}" ]] && archisoflags="defaults" [[ -z "${cow_spacesize}" ]] && cow_spacesize="256M"
if [[ -n "${cow_label}" ]]; then @@ -137,7 +137,7 @@ archiso_mount_handler() { local newroot="${1}"
if ! mountpoint -q "/run/archiso/bootmnt"; then - _mnt_dev -o "${archisoflags}" "${archisodevice}" "/run/archiso/bootmnt" "-r" + _mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r" "defaults" if [[ "${copytoram}" != "y" ]]; then echo $(readlink -f ${archisodevice}) >> /run/archiso/used_block_devices fi @@ -166,7 +166,7 @@ archiso_mount_handler() { fi
if [[ -n "${cow_device}" ]]; then - _mnt_dev -o "${cow_flags}" "${cow_device}" "/run/archiso/cowspace" "-r" + _mnt_dev "${cow_device}" "/run/archiso/cowspace" "-r" "${cow_flags}" echo $(readlink -f ${cow_device}) >> /run/archiso/used_block_devices mount -o remount,rw "/run/archiso/cowspace" else diff --git a/archiso/initcpio/hooks/archiso_loop_mnt b/archiso/initcpio/hooks/archiso_loop_mnt index f95a47d..2e99404 100644 --- a/archiso/initcpio/hooks/archiso_loop_mnt +++ b/archiso/initcpio/hooks/archiso_loop_mnt @@ -2,6 +2,7 @@
run_hook () { [[ -n "${img_label}" ]] && img_dev="/dev/disk/by-label/${img_label}" + [[ -z "${img_flags}" ]] && img_flags="defaults" if [[ -n "${img_dev}" && -n "${img_loop}" ]]; then mount_handler="archiso_loop_mount_handler" fi @@ -13,7 +14,7 @@ archiso_loop_mount_handler () { local _dev_loop
msg ":: Setup a loop device from ${img_loop} located at device ${img_dev}" - _mnt_dev "${img_dev}" "/run/archiso/img_dev" "-r" + _mnt_dev "${img_dev}" "/run/archiso/img_dev" "-r" "${img_flags}" if [[ "${copytoram}" != "y" ]]; then echo $(readlink -f ${img_dev}) >> /run/archiso/used_block_devices fi diff --git a/docs/README.bootparams b/docs/README.bootparams index 9737554..77161df 100644 --- a/docs/README.bootparams +++ b/docs/README.bootparams @@ -21,8 +21,6 @@ INDEX Default: (unset) * archisodevice= Set the device node where archiso medium is located. Default: "/dev/disk/by-label/${archisolabel}" -* archisoflags= Set extra mount options, e.g. for btrfs subvolumes. - Default: defaults * archisobasedir= Set the base directory where all files reside. Default: "arch" * copytoram= If set to "y" or just "copytoram" without arguments, @@ -125,6 +123,8 @@ INDEX Default: (unset) * img_dev= Device where archiso-image.iso reside. Default: (unset) or "/dev/disk/by-label/${img_label}" +* img_flags= Set extra mount options, e.g. for btrfs subvolumes. + Default: defaults * img_loop= Full path where archiso-image.iso is located on ${img_dev} Default: (unset)
Thanks!, testing...
participants (2)
-
Christian Hesse
-
Gerardo Exequiel Pozzi