[archiso] Change cowfile_size= behavior
Move from percent to explicit size and set a default of 256M (sparse) Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@gmail.com>
This commit is contained in:
parent
ccbeb35a7f
commit
edfdd37ba0
@ -11,19 +11,13 @@ _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})
|
||||||
if [[ "${cowfile_size}" == "100" ]]; then
|
|
||||||
rw_dev_size=${ro_dev_size}
|
|
||||||
else
|
|
||||||
# size calculation done in this way to avoid integer overflow when ro_dev_size is > 10.2G
|
|
||||||
rw_dev_size=$((ro_dev_size/100*cowfile_size))
|
|
||||||
fi
|
|
||||||
|
|
||||||
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=${rw_dev_size} &> /dev/null
|
truncate -s "${cowfile_size}" "/run/archiso/cowspace/${cow_directory}/${img_name}.cow"
|
||||||
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
|
||||||
@ -31,13 +25,13 @@ _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=${rw_dev_size} &> /dev/null
|
truncate -s "${cowfile_size}" "/run/archiso/cowspace/${cow_directory}/${img_name}.cow"
|
||||||
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")
|
||||||
echo ${rw_dev} >> /run/archiso/used_block_devices
|
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}
|
dmsetup create ${dm_snap_name} --table "0 ${ro_dev_size} snapshot ${ro_dev} ${rw_dev} ${cow_persistent} 8"
|
||||||
|
|
||||||
_mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w"
|
_mnt_dev "/dev/mapper/${dm_snap_name}" "${newroot}${mnt}" "-w"
|
||||||
echo $(readlink -f /dev/mapper/${dm_snap_name}) >> /run/archiso/used_block_devices
|
echo $(readlink -f /dev/mapper/${dm_snap_name}) >> /run/archiso/used_block_devices
|
||||||
@ -108,9 +102,7 @@ run_hook() {
|
|||||||
[[ -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
|
if [[ -z "${cowfile_size}" ]]; then
|
||||||
cowfile_size="100"
|
cowfile_size="256M"
|
||||||
else
|
|
||||||
cowfile_size=${cowfile_size/%}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${cow_label}" ]]; then
|
if [[ -n "${cow_label}" ]]; then
|
||||||
|
@ -12,6 +12,7 @@ build() {
|
|||||||
add_binary dmsetup
|
add_binary dmsetup
|
||||||
add_binary losetup
|
add_binary losetup
|
||||||
add_binary mountpoint
|
add_binary mountpoint
|
||||||
|
add_binary truncate
|
||||||
|
|
||||||
add_file /usr/lib/udev/rules.d/60-cdrom_id.rules
|
add_file /usr/lib/udev/rules.d/60-cdrom_id.rules
|
||||||
add_file /usr/lib/udev/rules.d/10-dm.rules
|
add_file /usr/lib/udev/rules.d/10-dm.rules
|
||||||
|
@ -31,27 +31,26 @@ INDEX
|
|||||||
and continue booting if ok.
|
and continue booting if ok.
|
||||||
Default: (unset)
|
Default: (unset)
|
||||||
* cow_label= Set the filesystem label where COW (dm-snapshot)
|
* cow_label= Set the filesystem label where COW (dm-snapshot)
|
||||||
files must be stored.
|
file must be stored.
|
||||||
Default: (unset)
|
Default: (unset)
|
||||||
* cow_device= Set the device node where COW (dm-snapshot) files
|
* cow_device= Set the device node where COW (dm-snapshot) file
|
||||||
must be stored.
|
must be stored.
|
||||||
Default: (unset) or "/dev/disk/by-label/${cow_label}"
|
Default: (unset) or "/dev/disk/by-label/${cow_label}"
|
||||||
* cow_directory= Set a directory inside ${cow_device}.
|
* cow_directory= Set a directory inside ${cow_device}.
|
||||||
Default: "/persistent_${archisolabel}/${arch}"
|
Default: "/persistent_${archisolabel}/${arch}"
|
||||||
* cow_persistent= Set if snapshots are persistent "P" or non-persistent "N".
|
* cow_persistent= Set if snapshot is persistent "P" or non-persistent "N".
|
||||||
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.
|
||||||
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),
|
* cowfile_size= Set the size for COW file (dm-snapshot).
|
||||||
in percentage of the ro-device.fs file. This is mostly useful
|
The argument is an integer and optional unit.
|
||||||
when cow_device= is used and filesystem does not support
|
Units are M,G (powers of 1024) or MB,GB (powers of 1000).
|
||||||
sparse files (ie VFAT).
|
Default: "256M"
|
||||||
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.
|
airootfs.sfs image 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
|
||||||
in percentage of available RAM.
|
in percentage of available RAM.
|
||||||
Default: "75%"
|
Default: "75%"
|
||||||
|
Loading…
Reference in New Issue
Block a user