FS#52608 - Unnecessary use of COW space
Attached to Project:
Release Engineering
Opened by brent saner (sanerb) - Tuesday, 17 January 2017, 23:46 GMT
Last edited by Gerardo Exequiel Pozzi (djgera) - Friday, 23 February 2018, 03:05 GMT
Opened by brent saner (sanerb) - Tuesday, 17 January 2017, 23:46 GMT
Last edited by Gerardo Exequiel Pozzi (djgera) - Friday, 23 February 2018, 03:05 GMT
|
Details
On line 28 of the archiso initcpio hook:
truncate -s "${cow_spacesize}" "/run/archiso/cowspace/${cow_directory}/${img_name}.cow" and line 31 of the same file: rw_dev=$(losetup --find --show "/run/archiso/cowspace/${cow_directory}/${img_name}.cow") These steps are an unnecessary limitation if a cow file is not provided/specified to be used. It is a waste of RAM usage otherwise. The default behaviour is a 256MB cow file is created and mounted. However, since ArchISO now uses overlayFS, the squash image itself can be used as the lower via a -o loop mount, and the upper dir can be run entirely in RAM- meaning the only limitation is the RAM on the system rather than an arbitrary file size that must be set during the boot process or ISO creation. What can be (and should be) done instead is if a cow file is not specified on the kernel commandline/${img_name}.cow does not exist, then an upper directory should be created in the initrd (for example, /run/archiso/upper), a work directory created on the initrd (e.g. /run/archiso/work) and then (since initrd is running on memory), one would create an overlayFS mount with those directories at /new_root. |
This task depends upon
Closed by Gerardo Exequiel Pozzi (djgera)
Friday, 23 February 2018, 03:05 GMT
Reason for closing: Not a bug
Friday, 23 February 2018, 03:05 GMT
Reason for closing: Not a bug
EDIT: it seems it's set at line 123. If a persistent image is not specified, I'd recommend setting a tmpfs to use the whole size of available RAM. tmpfs will grow (and shrink) as necessary, there should be no need to set this to a hard limit.
In any case you can not boot on system with less than 256MB with XY compression of initramfs, try it ;)
so, if you do something like this:
--- /usr/lib/initcpio/hooks/archiso 2016-12-21 17:30:46.000000000 -0500
+++ archiso 2017-01-18 10:24:37.113333330 -0500
@@ -194,9 +194,15 @@
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=${cow_spacesize}..."
- mkdir -p /run/archiso/cowspace
- mount -t tmpfs -o "size=${cow_spacesize}",mode=0755 cowspace /run/archiso/cowspace
+ if [[ "${cow_persistent}" != 'P' ]]; then
+ msg ":: Mounting /run/archiso/cowspace (tmpfs) filesystem, size=${cow_spacesize}..."
+ mkdir -p /run/archiso/cowspace
+ mount -t tmpfs -o "size=${cow_spacesize}",mode=0755 cowspace /run/archiso/cowspace
+ else
+ msg ":: Mounting /run/archiso/cowspace (tmpfs) filesystem..."
+ mkdir -p /run/archiso/cowspace
+ mount -t tmpfs -o mode=0755 cowspace /run/archiso/cowspace
+ fi
fi
mkdir -p -m 0700 "/run/archiso/cowspace/${cow_directory}"
it should do the trick. (might want to test it with persistent cow images though. works fine with copytoram).
result:
dev 2.0G 0 2.0G 0% /dev
run 2.0G 73M 1.9G 4% /run
/dev/sr0 2.4G 2.4G 0 100% /run/archiso/bootmnt
cowspace 2.0G 47M 1.9G 3% /run/archiso/cowspace
/dev/loop0 1.2G 1.2G 0 100% /run/archiso/sfs/airootfs
airootfs 2.0G 47M 1.9G 3% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
tmpfs 2.0G 0 2.0G 0% /tmp
tmpfs 396M 0 396M 0% /run/user/0
edit: and the available RAM isn't affected. :)
[root@bdisk-live ~]# free -m
total used free shared buff/cache available
Mem: 3954 63 3323 118 566 3555
Swap: 0 0 0
Looks related to old discussion
FS#45618PS: mkdir command is duplicated, patch uses tabs, while archiso use spaces, see .editorconfig/vim last line
regardless; remove the if test if it isn't needed, but putting a size limitation on a tmpfs for a live environment is unnecessary. for an install and for something like /tmp it makes perfect sense, but not for a system designed to be run on RAM entirely.
FS#45618- just tested)Sure I can remove the limit and left the 75% default for tmpfs and set parameter on releng profile. Such low limit on releng profile has two purposes: as said before is just sufficient for install/rescue procedure, and "avoid" install Arch on RAM, like many users do!, they will see error messages, instead of blank install.
Edit: maybe is time to remove dm-snapshot support since overlayfs works fine.
What about a third option in the build script releng/build or releng/efiboot/loader/entries/archiso-x86_64-cd.conf, where one can specify the size according to his needs?. The later seems easier to just append cow_spacesize=SIZE at the end of the line, so that it reads "options archisobasedir=%INSTALL_DIR% archisolabel=%ARCHISO_LABEL% cow_spacesize=SIZE". Am just not sure if it would work this way and don't know the difference between the files archiso-x86_64-cd.conf and archiso-x86_64-usb.conf, I will have to try it.
Since this is not really related to what this bug report is about, let's come back to it. Sorry for hijacking.