[archiso] Introduce cowfile_size= bootparam

If not set, nothing is changed in current behaviour.

Since dm-snapshot allows to use as "COW" a file with any size,
without caring about the the size of "origin", we can avoid creating a
"COW" file of the same size as the "origin". This is really useful,
when using as cow_device= a filesystem that is VFAT where sparse files
are not supported, so if root-image.fs is 1000M, passing cowfile_size=25%
will create a root-image.cow of 250M instead of 1000M.

Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
This commit is contained in:
Gerardo Exequiel Pozzi 2012-10-13 14:40:41 -03:00
parent 2e94974e2b
commit 1746e31049
2 changed files with 13 additions and 2 deletions

5
README
View File

@ -65,6 +65,11 @@ INDEX
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%"
* cowfile_size= Set the size for all files to be used as COW (dm-snapshot),
in percentage of the ro-device.fs file. This is mostly useful
when cow_device= is used and filesystem does not support
sparse files (ie VFAT).
Default: "100%"
* copytoram_size= Set the size of tmpfs. 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.
Size is in bytes (suffix with "k", "m" and "g") or Size is in bytes (suffix with "k", "m" and "g") or

View File

@ -11,13 +11,14 @@ _mnt_fs() {
ro_dev=$(losetup --find --show --read-only "${img}") ro_dev=$(losetup --find --show --read-only "${img}")
echo ${ro_dev} >> /run/archiso/used_block_devices echo ${ro_dev} >> /run/archiso/used_block_devices
ro_dev_size=$(blockdev --getsz ${ro_dev}) ro_dev_size=$(blockdev --getsz ${ro_dev})
rw_dev_size=$((ro_dev_size*cowfile_size/100))
if [[ "${cow_persistent}" == "P" ]]; then if [[ "${cow_persistent}" == "P" ]]; then
if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then
msg ":: Found '/run/archiso/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 '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as persistent." msg ":: Creating '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as persistent."
dd of="/run/archiso/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=${rw_dev_size} &> /dev/null
fi fi
else else
if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then if [[ -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" ]]; then
@ -25,7 +26,7 @@ _mnt_fs() {
rm -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" rm -f "/run/archiso/cowspace/${cow_directory}/${img_name}.cow"
fi fi
msg ":: Creating '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as non-persistent." msg ":: Creating '/run/archiso/cowspace/${cow_directory}/${img_name}.cow' as non-persistent."
dd of="/run/archiso/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=${rw_dev_size} &> /dev/null
fi fi
rw_dev=$(losetup --find --show "/run/archiso/cowspace/${cow_directory}/${img_name}.cow") rw_dev=$(losetup --find --show "/run/archiso/cowspace/${cow_directory}/${img_name}.cow")
@ -101,6 +102,11 @@ run_hook() {
[[ -z "${archisobasedir}" ]] && archisobasedir="arch" [[ -z "${archisobasedir}" ]] && archisobasedir="arch"
[[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch" [[ -z "${dm_snap_prefix}" ]] && dm_snap_prefix="arch"
[[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}" [[ -z "${archisodevice}" ]] && archisodevice="/dev/disk/by-label/${archisolabel}"
if [[ -z "${cowfile_size}" ]]; then
cowfile_size="100"
else
cowfile_size=${cowfile_size/%}
fi
if [[ -z "${aitab}" ]]; then if [[ -z "${aitab}" ]]; then
aitab="/run/archiso/bootmnt/${archisobasedir}/aitab" aitab="/run/archiso/bootmnt/${archisobasedir}/aitab"