summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>2011-10-23 21:24:17 -0300
committerGerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>2011-10-23 21:24:17 -0300
commite2055835fda3d2c99378231e4595472bf28631c4 (patch)
tree6676cc95ef8209a87cbfe29bbbb19fae0035cd99
parent91e11c30f46094bcc7352f42e11799f662b6b689 (diff)
downloadarchiso32-e2055835fda3d2c99378231e4595472bf28631c4.tar.xz
[archiso] Allow persistent cow dm-snapshots.
Add some options to control where all COW files will be located. Until this moment all files are located in a tmpfs filesystem. Now is posible to set a device via a filesystem label or device node plus a directory, where all these files will be stored. All dm-snapshot devices will be persistent by default, but this can be changed if wanted. Take care, a filesystem that does not support sparse files maybe is not the best choice for COW files, because they are created with the same size (is apparent) like the read-only device (the image.fs inside .sfs). Of course sooner or later, depending on use, these files actually end up being as big as the read-only device. KNOW-ISSUE: On shutdown in step "Unmounting Filesystems" will [FAIL], all filesystem except $cow_device, will be unmounted/remounted-ro. For this reason this change needs an archiso_shutdown hook, thats unmount all block devices used by archiso. (Work in progress) Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
-rw-r--r--README10
-rw-r--r--archiso/hooks/archiso57
2 files changed, 57 insertions, 10 deletions
diff --git a/README b/README
index 9c49946..8f59be3 100644
--- a/README
+++ b/README
@@ -35,6 +35,16 @@ INDEX
performs a self-test of all files inside ${install_dir},
and continue booting if ok.
Default: (unset)
+* cow_label= Set the filesystem label where COW (dm-snapshot)
+ files must be stored.
+ Default: (unset)
+* cow_device= Set the device node where COW (dm-snapshot) files
+ must be stored.
+ Default: (unset) or "/dev/disk/by-label/${cow_label}"
+* cow_directory= Set a directory inside ${cow_device}.
+ Default: "/persistent_${archisolabel}/${arch}"
+* cow_persistent= Set if snapshots are persistent "P" or non-persistent "N".
+ Default: "N" (if no ${cow_device} is used) otherwise "P".
* cowspace_size= Set the size of tmpfs /cowspace. This space is used for
Copy-On-Write files of dm-snapshot.
(directory not visible outside initramfs)
diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso
index 1ef6e95..4b512ef 100644
--- a/archiso/hooks/archiso
+++ b/archiso/hooks/archiso
@@ -38,11 +38,27 @@ _mnt_fs() {
ro_dev_size=$(blockdev --getsz ${ro_dev})
ro_dev_fs_type=$(blkid -o value -s TYPE -p ${ro_dev} 2> /dev/null)
- dd of="/cowspace/${img_name}.cow" count=0 seek=${ro_dev_size} &> /dev/null
+
+ if [[ "${cow_persistent}" == "P" ]]; then
+ if [[ -f "/cowspace/${cow_directory}/${img_name}.cow" ]]; then
+ msg ":: Found '/cowspace/${cow_directory}/${img_name}.cow', using as persistent."
+ else
+ msg ":: Creating '/cowspace/${cow_directory}/${img_name}.cow' as persistent."
+ dd of="/cowspace/${cow_directory}/${img_name}.cow" count=0 seek=${ro_dev_size} &> /dev/null
+ fi
+ else
+ if [[ -f "/cowspace/${cow_directory}/${img_name}.cow" ]]; then
+ msg ":: Found '/cowspace/${cow_directory}/${img_name}.cow' but non-persistent requested, removing."
+ rm -f "/cowspace/${cow_directory}/${img_name}.cow"
+ fi
+ msg ":: Creating '/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
+ fi
+
_next_loop_dev
- rw_dev=$(_make_loop_dev "/cowspace/${img_name}.cow")
+ rw_dev=$(_make_loop_dev "/cowspace/${cow_directory}/${img_name}.cow")
- echo "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} N 8" | dmsetup create ${dm_snap_name}
+ echo "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} 8" | dmsetup create ${dm_snap_name}
msg ":: Mounting '/dev/mapper/${dm_snap_name}' (${ro_dev_fs_type}) to '${mnt}'"
if ! mount -t "${ro_dev_fs_type}" "/dev/mapper/${dm_snap_name}" "${mnt}" ; then
@@ -132,11 +148,24 @@ run_hook() {
[[ -z "${archisobasedir}" ]] && archisobasedir="arch"
[[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch"
[[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}"
+
if [[ -z "${aitab}" ]]; then
aitab="/bootmnt/${archisobasedir}/aitab"
else
aitab="/bootmnt/${aitab}"
fi
+
+ if [[ -n "${cow_label}" ]]; then
+ cow_device="/dev/disk/by-label/${cow_label}"
+ [[ -z "${cow_persistent}" ]] && cow_persistent="P"
+ elif [[ -n "${cow_device}" ]]; then
+ [[ -z "${cow_persistent}" ]] && cow_persistent="P"
+ else
+ cow_persistent="N"
+ fi
+
+ [[ -z "${cow_directory}" ]] && cow_directory="persistent_${archisolabel}/${arch}"
+
# set mount handler for archiso
mount_handler="archiso_mount_handler"
}
@@ -149,7 +178,12 @@ archiso_mount_handler() {
_init_loop_dev
- _mnt_dev "${archisodevice}" "/bootmnt" "-r"
+ if [[ "${archisodevice}" -ef "${cow_device}" ]]; then
+ _mnt_dev "${archisodevice}" "/bootmnt"
+ else
+ _mnt_dev "${archisodevice}" "/bootmnt" "-r"
+ fi
+
if [[ ! -f "${aitab}" ]]; then
echo "ERROR: '${aitab}' file does not exist."
echo " Falling back to interactive prompt"
@@ -174,14 +208,17 @@ archiso_mount_handler() {
fi
if [[ "${copytoram}" == "y" ]]; then
- msg -n ":: Mounting /copytoram (tmpfs) filesystem, size=${copytoram_size}..."
+ msg ":: Mounting /copytoram (tmpfs) filesystem, size=${copytoram_size}"
mount -t tmpfs -o "size=${copytoram_size}",mode=0755 copytoram /copytoram
- msg "done."
fi
- msg -n ":: Mounting /cowspace (tmpfs) filesystem, size=${cowspace_size}..."
- mount -t tmpfs -o "size=${cowspace_size}",mode=0755 cowspace /cowspace
- msg "done."
+ if [[ -n "${cow_device}" ]]; then
+ _mnt_dev "${cow_device}" "/cowspace"
+ else
+ msg ":: Mounting /cowspace (tmpfs) filesystem, size=${cowspace_size}..."
+ mount -t tmpfs -o "size=${cowspace_size}",mode=0755 cowspace /cowspace
+ fi
+ mkdir -p "/cowspace/${cow_directory}"
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
@@ -202,7 +239,7 @@ archiso_mount_handler() {
if [[ "${copytoram}" == "y" ]]; then
umount /bootmnt
else
- mkdir "${newroot}/bootmnt"
+ mkdir -p "${newroot}/bootmnt"
mount --bind /bootmnt "${newroot}/bootmnt"
fi
}