On 02/22/2012 04:39 AM, Dieter Plaetinck wrote:
On Tue, 21 Feb 2012 20:01:30 -0300 Gerardo Exequiel Pozzi<vmlinuz386@yahoo.com.ar> wrote:
NOTE: Not tested yet, but should work(tm).
This list includes block devices of ( /run/archiso/used_block_devices ): * Boot medium [archisodevice] (only if no copytoram= is used) * Loop medium [img_dev] (only if no copytoram= is used) * COW space [cowdevice] (only if cowdevice= is used (no tmpfs is used)) * Loop devices used for SquashFS images. * Loop devices used for device-mapper devices (two per each dm-device, one RO{*.fs} and one RW{*.cow})
Aditionally all loop devices except for backing COW files, all are setup as read-only.
In configs/releng profile, a symlink is made at boot-time for AIF: /run/aif/ignore_devs -> /run/archiso/used_block_devices --- archiso/hooks/archiso | 20 ++++++++++++++++---- archiso/hooks/archiso_loop_mnt | 3 ++- .../rc.d/functions.d/symlink_used_block_devices | 7 +++++++ 3 files changed, 25 insertions(+), 5 deletions(-) create mode 100644 configs/releng/root-image/etc/rc.d/functions.d/symlink_used_block_devices
diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso index 3518d16..22b67e9 100644 --- a/archiso/hooks/archiso +++ b/archiso/hooks/archiso @@ -10,7 +10,8 @@ _mnt_fs() {
mkdir -p "${newroot}${mnt}"
- ro_dev=$(losetup --find --show "${img}") + ro_dev=$(losetup --find --show --read-only "${img}") + echo ${ro_dev}>> /run/archiso/used_block_devices ro_dev_size=$(blockdev --getsz ${ro_dev})
if [[ "${cow_persistent}" == "P" ]]; then @@ -30,6 +31,7 @@ _mnt_fs() { fi
rw_dev=$(losetup --find --show "/run/archiso/cowspace/${cow_directory}/${img_name}.cow") + echo ${rw_dev}>> /run/archiso/used_block_devices
echo "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} 8" | dmsetup create ${dm_snap_name}
@@ -39,6 +41,7 @@ _mnt_fs() { launch_interactive_shell else echo "/dev/mapper/${dm_snap_name} ${mnt} auto defaults 0 0">> ${newroot}/etc/fstab + echo /dev/mapper/${dm_snap_name}>> /run/archiso/used_block_devices fi }
@@ -46,7 +49,8 @@ _mnt_fs() { _mnt_sfs() { local img="${1}" local mnt="${2}" - local img_fullname="${img##*/}"; + local img_fullname="${img##*/}" + local sfs_dev
mkdir -p "${mnt}"
@@ -60,7 +64,9 @@ _mnt_sfs() { msg "done." fi msg ":: Mounting '${img}' (SquashFS) to '${mnt}'" - if ! mount -r "${img}" "${mnt}"&> /dev/null ; then + sfs_dev=$(losetup --find --show --read-only "${img}") + echo ${sfs_dev}>> /run/archiso/used_block_devices + if ! mount -r "${sfs_dev}" "${mnt}"&> /dev/null ; then echo "ERROR: while mounting '${img}' to '${mnt}'" launch_interactive_shell fi @@ -137,7 +143,12 @@ run_hook() { archiso_mount_handler() { local newroot="${1}"
- mountpoint -q "/run/archiso/bootmnt" || _mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r" + if ! mountpoint -q "/run/archiso/bootmnt"; then + _mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r" + if [[ "${copytoram}" != "y" ]]; then + echo $(readlink -f ${archisodevice})>> /run/archiso/used_block_devices + fi + fi
if [[ ! -f "${aitab}" ]]; then echo "ERROR: '${aitab}' file does not exist." @@ -170,6 +181,7 @@ archiso_mount_handler() {
if [[ -n "${cow_device}" ]]; then _mnt_dev "${cow_device}" "/run/archiso/cowspace" "-r" + echo $(readlink -f ${cow_device})>> /run/archiso/used_block_devices mount -o remount,rw "/run/archiso/cowspace" else msg ":: Mounting /run/archiso/cowspace (tmpfs) filesystem, size=${cowspace_size}..." diff --git a/archiso/hooks/archiso_loop_mnt b/archiso/hooks/archiso_loop_mnt index 664f3a5..808100d 100644 --- a/archiso/hooks/archiso_loop_mnt +++ b/archiso/hooks/archiso_loop_mnt @@ -15,7 +15,7 @@ archiso_loop_mount_handler () { msg ":: Setup a loop device from ${img_loop} located at device ${img_dev}" _mnt_dev "${img_dev}" "/run/archiso/img_dev" "-r"
- if ! _dev_loop=$(losetup --find --show "/run/archiso/img_dev/${img_loop}"); then + if ! _dev_loop=$(losetup --find --show --read-only "/run/archiso/img_dev/${img_loop}"); then echo "ERROR: Setting loopback device for file '/run/archiso/img_dev/${img_loop}'" launch_interactive_shell fi @@ -27,5 +27,6 @@ archiso_loop_mount_handler () { umount /run/archiso/img_dev else echo ${_dev_loop}> /run/archiso/img_dev_loop + echo $(readlink -f ${img_dev})>> /run/archiso/used_block_devices fi } diff --git a/configs/releng/root-image/etc/rc.d/functions.d/symlink_used_block_devices b/configs/releng/root-image/etc/rc.d/functions.d/symlink_used_block_devices new file mode 100644 index 0000000..e2b9fc1 --- /dev/null +++ b/configs/releng/root-image/etc/rc.d/functions.d/symlink_used_block_devices @@ -0,0 +1,7 @@ +symlink_used_block_devices() +{ + mkdir /run/aif + ln -s /run/archiso/used_block_devices /run/aif/ignore_devs +} + +add_hook multi_end symlink_used_block_devices Hey G, seems like there's some small edits in here that have nothing to do with the actual block device listing changeset?
Dieter
Yes, --read-only loops. -- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1