[archiso] Mount all fs on /run/archiso instead of /

This allow to take control again of these mountpoints outside initramfs.
(i.e: on deinitramfs stage at shutdown for unmount it)

Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
This commit is contained in:
Gerardo Exequiel Pozzi 2011-10-23 21:24:17 -03:00
parent e2055835fd
commit 90fb8ea480
5 changed files with 40 additions and 41 deletions

4
README
View File

@ -47,13 +47,11 @@ INDEX
Default: "N" (if no ${cow_device} is used) otherwise "P". Default: "N" (if no ${cow_device} is used) otherwise "P".
* cowspace_size= Set the size of tmpfs /cowspace. This space is used for * cowspace_size= Set the size of tmpfs /cowspace. This space is used for
Copy-On-Write files of dm-snapshot. Copy-On-Write files of dm-snapshot.
(directory not visible outside initramfs)
Size is in bytes (suffix with "k", "m" and "g") or Size is in bytes (suffix with "k", "m" and "g") or
in percentage of available RAM. in percentage of available RAM.
Default: "75%" Default: "75%"
* copytoram_size= Set the size of tmpfs /cowpytoram. This space is used for * copytoram_size= Set the size of tmpfs. This space is used for
copy of all SquashFS images used, if copytoram=y. copy of all SquashFS images used, if copytoram=y.
(directory not visible outside initramfs)
Size is in bytes (suffix with "k", "m" and "g") or Size is in bytes (suffix with "k", "m" and "g") or
in percentage of available RAM. in percentage of available RAM.
Default: "75%" Default: "75%"

View File

@ -40,23 +40,23 @@ _mnt_fs() {
if [[ "${cow_persistent}" == "P" ]]; then if [[ "${cow_persistent}" == "P" ]]; then
if [[ -f "/cowspace/${cow_directory}/${img_name}.cow" ]]; then if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then
msg ":: Found '/cowspace/${cow_directory}/${img_name}.cow', using as persistent." msg ":: Found '/run/archiso/cowspace/${cow_directory}/${img_name}.cow', using as persistent."
else else
msg ":: Creating '/cowspace/${cow_directory}/${img_name}.cow' as persistent." msg ":: Creating '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as persistent."
dd of="/cowspace/${cow_directory}/${img_name}.cow" count=0 seek=${ro_dev_size} &> /dev/null dd of="/run/archiso/cowspace/${cow_directory}/${img_name}.cow" count=0 seek=${ro_dev_size} &> /dev/null
fi fi
else else
if [[ -f "/cowspace/${cow_directory}/${img_name}.cow" ]]; then if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then
msg ":: Found '/cowspace/${cow_directory}/${img_name}.cow' but non-persistent requested, removing." msg ":: Found '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' but non-persistent requested, removing."
rm -f "/cowspace/${cow_directory}/${img_name}.cow" rm -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow"
fi fi
msg ":: Creating '/cowspace/${cow_directory}/${img_name}.cow' as non-persistent." msg ":: Creating '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as non-persistent."
dd of="/cowspace/${cow_directory}/${img_name}.cow" count=0 seek=${ro_dev_size} &> /dev/null dd of="/run/archiso/cowspace/${cow_directory}/${img_name}.cow" count=0 seek=${ro_dev_size} &> /dev/null
fi fi
_next_loop_dev _next_loop_dev
rw_dev=$(_make_loop_dev "/cowspace/${cow_directory}/${img_name}.cow") rw_dev=$(_make_loop_dev "/run/archiso/cowspace/${cow_directory}/${img_name}.cow")
echo "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} 8" | dmsetup create ${dm_snap_name} echo "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} 8" | dmsetup create ${dm_snap_name}
@ -77,11 +77,11 @@ _mnt_sfs() {
if [[ "${copytoram}" == "y" ]]; then if [[ "${copytoram}" == "y" ]]; then
msg -n ":: Copying squashfs image to RAM..." msg -n ":: Copying squashfs image to RAM..."
if ! cp "${img}" "/copytoram/${img_fullname}" ; then if ! cp "${img}" "/run/archiso/copytoram/${img_fullname}" ; then
echo "ERROR: while copy '${img}' to '/copytoram/${img_fullname}'" echo "ERROR: while copy '${img}' to '/run/archiso/copytoram/${img_fullname}'"
launch_interactive_shell launch_interactive_shell
fi fi
img="/copytoram/${img_fullname}" img="/run/archiso/copytoram/${img_fullname}"
msg "done." msg "done."
fi fi
_next_loop_dev _next_loop_dev
@ -100,6 +100,8 @@ _mnt_dev() {
local fstype fserror local fstype fserror
mkdir -p "${mnt}"
msg ":: Mounting '${dev}' to '${mnt}'" msg ":: Mounting '${dev}' to '${mnt}'"
while ! poll_device "${dev}" 30; do while ! poll_device "${dev}" 30; do
@ -132,7 +134,7 @@ _mnt_dev() {
_verify_checksum() { _verify_checksum() {
local _status local _status
cd "/bootmnt/${archisobasedir}" cd "/run/archiso/bootmnt/${archisobasedir}"
md5sum -c checksum.md5 > /checksum.log 2>&1 md5sum -c checksum.md5 > /checksum.log 2>&1
_status=$? _status=$?
cd "${OLDPWD}" cd "${OLDPWD}"
@ -150,9 +152,9 @@ run_hook() {
[[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}" [[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}"
if [[ -z "${aitab}" ]]; then if [[ -z "${aitab}" ]]; then
aitab="/bootmnt/${archisobasedir}/aitab" aitab="/run/archiso/bootmnt/${archisobasedir}/aitab"
else else
aitab="/bootmnt/${aitab}" aitab="/run/archiso/bootmnt/${aitab}"
fi fi
if [[ -n "${cow_label}" ]]; then if [[ -n "${cow_label}" ]]; then
@ -179,9 +181,9 @@ archiso_mount_handler() {
_init_loop_dev _init_loop_dev
if [[ "${archisodevice}" -ef "${cow_device}" ]]; then if [[ "${archisodevice}" -ef "${cow_device}" ]]; then
_mnt_dev "${archisodevice}" "/bootmnt" _mnt_dev "${archisodevice}" "/run/archiso/bootmnt"
else else
_mnt_dev "${archisodevice}" "/bootmnt" "-r" _mnt_dev "${archisodevice}" "/run/archiso/bootmnt" "-r"
fi fi
if [[ ! -f "${aitab}" ]]; then if [[ ! -f "${aitab}" ]]; then
@ -192,7 +194,7 @@ archiso_mount_handler() {
fi fi
if [[ "${checksum}" == "y" ]]; then if [[ "${checksum}" == "y" ]]; then
if [[ -f "/bootmnt/${archisobasedir}/checksum.md5" ]]; then if [[ -f "/run/archiso/bootmnt/${archisobasedir}/checksum.md5" ]]; then
msg -n ":: Self-test requested, please wait..." msg -n ":: Self-test requested, please wait..."
if _verify_checksum; then if _verify_checksum; then
msg "done. Checksum is OK, continue booting." msg "done. Checksum is OK, continue booting."
@ -208,17 +210,19 @@ archiso_mount_handler() {
fi fi
if [[ "${copytoram}" == "y" ]]; then if [[ "${copytoram}" == "y" ]]; then
msg ":: Mounting /copytoram (tmpfs) filesystem, size=${copytoram_size}" msg ":: Mounting /run/archiso/copytoram (tmpfs) filesystem, size=${copytoram_size}"
mount -t tmpfs -o "size=${copytoram_size}",mode=0755 copytoram /copytoram mkdir -p /run/archiso/copytoram
mount -t tmpfs -o "size=${copytoram_size}",mode=0755 copytoram /run/archiso/copytoram
fi fi
if [[ -n "${cow_device}" ]]; then if [[ -n "${cow_device}" ]]; then
_mnt_dev "${cow_device}" "/cowspace" _mnt_dev "${cow_device}" "/run/archiso/cowspace"
else else
msg ":: Mounting /cowspace (tmpfs) filesystem, size=${cowspace_size}..." msg ":: Mounting /run/archiso/cowspace (tmpfs) filesystem, size=${cowspace_size}..."
mount -t tmpfs -o "size=${cowspace_size}",mode=0755 cowspace /cowspace mkdir -p /run/archiso/cowspace
mount -t tmpfs -o "size=${cowspace_size}",mode=0755 cowspace /run/archiso/cowspace
fi fi
mkdir -p "/cowspace/${cow_directory}" mkdir -p "/run/archiso/cowspace/${cow_directory}"
local aitab_img aitab_mnt aitab_arch aitab_sfs_comp aitab_fs_type aitab_fs_size local aitab_img aitab_mnt aitab_arch aitab_sfs_comp aitab_fs_type aitab_fs_size
while read aitab_img aitab_mnt aitab_arch aitab_sfs_comp aitab_fs_type aitab_fs_size; do while read aitab_img aitab_mnt aitab_arch aitab_sfs_comp aitab_fs_type aitab_fs_size; do
@ -226,21 +230,21 @@ archiso_mount_handler() {
[[ "${aitab_arch}" != "any" && "${aitab_arch}" != "${arch}" ]] && continue [[ "${aitab_arch}" != "any" && "${aitab_arch}" != "${arch}" ]] && continue
if [[ "${aitab_fs_type}" != "none" ]]; then if [[ "${aitab_fs_type}" != "none" ]]; then
if [[ "${aitab_sfs_comp}" != "none" ]]; then if [[ "${aitab_sfs_comp}" != "none" ]]; then
_mnt_sfs "/bootmnt/${archisobasedir}/${aitab_arch}/${aitab_img}.fs.sfs" "/sfs/${aitab_img}" _mnt_sfs "/run/archiso/bootmnt/${archisobasedir}/${aitab_arch}/${aitab_img}.fs.sfs" "/run/archiso/sfs/${aitab_img}"
_mnt_fs "/sfs/${aitab_img}/${aitab_img}.fs" "${newroot}${aitab_mnt}" _mnt_fs "/run/archiso/sfs/${aitab_img}/${aitab_img}.fs" "${newroot}${aitab_mnt}"
else else
_mnt_fs "/bootmnt/${archisobasedir}/${aitab_arch}/${aitab_img}.fs" "${newroot}${aitab_mnt}" _mnt_fs "/run/archiso/bootmnt/${archisobasedir}/${aitab_arch}/${aitab_img}.fs" "${newroot}${aitab_mnt}"
fi fi
else else
_mnt_sfs "/bootmnt/${archisobasedir}/${aitab_arch}/${aitab_img}.sfs" "${newroot}${aitab_mnt}" _mnt_sfs "/run/archiso/bootmnt/${archisobasedir}/${aitab_arch}/${aitab_img}.sfs" "${newroot}${aitab_mnt}"
fi fi
done < "${aitab}" done < "${aitab}"
if [[ "${copytoram}" == "y" ]]; then if [[ "${copytoram}" == "y" ]]; then
umount /bootmnt umount /run/archiso/bootmnt
else else
mkdir -p "${newroot}/bootmnt" mkdir -p "${newroot}/bootmnt"
mount --bind /bootmnt "${newroot}/bootmnt" mount --bind /run/archiso/bootmnt "${newroot}/bootmnt"
fi fi
} }

View File

@ -20,9 +20,10 @@ archiso_loop_mount_handler () {
msg "::: Setup a loop device from ${img_loop} located at device ${img_dev}" msg "::: Setup a loop device from ${img_loop} located at device ${img_dev}"
FSTYPE=$(blkid -o value -s TYPE -p ${img_dev} 2> /dev/null) FSTYPE=$(blkid -o value -s TYPE -p ${img_dev} 2> /dev/null)
if [ -n "${FSTYPE}" ]; then if [ -n "${FSTYPE}" ]; then
if mount -r -t "${FSTYPE}" ${img_dev} /img_dev > /dev/null 2>&1; then mkdir -p /run/archiso/img_dev
if mount -r -t "${FSTYPE}" ${img_dev} /run/archiso/img_dev > /dev/null 2>&1; then
_dev_loop=$(losetup -f) _dev_loop=$(losetup -f)
losetup ${_dev_loop} /img_dev/${img_loop} losetup ${_dev_loop} /run/archiso/img_dev/${img_loop}
fi fi
fi fi

View File

@ -9,10 +9,6 @@ build ()
BINARIES="" BINARIES=""
FILES="" FILES=""
add_dir /cowspace
add_dir /copytoram
add_dir /bootmnt
add_binary /lib/udev/cdrom_id add_binary /lib/udev/cdrom_id
add_binary /sbin/blockdev add_binary /sbin/blockdev
add_binary /sbin/dmsetup add_binary /sbin/dmsetup

View File

@ -6,7 +6,7 @@ build ()
BINARIES="" BINARIES=""
FILES="" FILES=""
add_dir /img_dev
SCRIPT="archiso_loop_mnt" SCRIPT="archiso_loop_mnt"
} }