On Wed 2021-08-18 @ 11:37:36 PM, Sinan Kaya wrote: > On 8/18/2021 11:36 PM, Trevor Woerner wrote: > > this is a WIP patch submitted for RFC > > this patch only works, currently, with sysvinit > > but I wanted to get feedback on the general approach before tackling systemd > > How about using/extending the zram package in meta-openembedded? > Would that be an option?
When I found the zram package in meta-openembedded I had thought that my work was done. I figured I'd add it to my image and move on. Unfortunately the zram package in meta-openembedded is woefully inadequate :-( In fact, if my patch gets accepted into oe-core, my next patch would be to remove this package from meta-openembedded ;-) So far I have only considered the case where the user wants to use zram with sysvinit. I haven't looked at the systemd case yet, but if it has as many holes as the sysvinit caseā¦ If you look at the package in meta-openembedded you'll see that it: - tries to do its work using start/stop initscripts - doesn't even try to handle the case where the user wants to use zram instead of tmpfs, and that's not a coincidence A running system will happily incorporate added SWAP anytime that SWAP is added. Simply prepare the partition for SWAP as appropriate then "swapon" and everything is happy. Substituting zram for tmpfs, however is a lot more finicky. You can't simply wait until after tmpfs has been used for your various tmp partitions then mount new partitions on top of the existing /var/volatile and /run. This will cause your logger to get upset, and it will cause pretty much every currently-running program to not be very happy. Programs that are started and put their pids in /run and various things in /tmp don't usually react favourably when those filesystems have something else mounted on top of them during their execution. Therefore in order to properly switch from tmpfs to zram for tmp filesystems: - /etc/fstab has to be modified to not try to mount tmpfs things to /var/volatile and /run - the place where "mount -a" is called has to be modified to setup, format, and mount zram-based disks. specifying zram disks is not something you can simply tweak /etc/fstab to do. according to the kernel documentation there is no zram /var/volatile zram,ext2 defaults 0 2 line that can be added to /etc/fstab to get zram-based filesystems to mount automatically via "mount -a" Because this change is much more invasive than simply running a script at a given runlevel I came to the conclusion that an IMAGE_FEATURE would be a better fit for this sort of feature. I also took the opportunity to parameterize various parts of the configuration to make it easy for the user to either accept the sane defaults, or easily tweak them to their liking. I added checks to these parameters so that they're valid/sane. I added the feature in a way that any required packages are added to the image automatically without the user having to do anything. I also tied into the kernel's "kmeta config" system so that simply enabling this IMAGE_FEATURE will also tweak the kernel config to add the necessary options (again, without user intervention). Also, if you look at the existing sysvinit script in meta-openembedded you'll notice that it jumps through some hoops trying to figure out how many cores/cpus are on the system, then it uses that number as a basis for how many SWAPs to create. You can tell this is a very old script because, according to the kernel documentation, this is something that was required a long time ago, but has long since is no longer required. Simply create one SWAP or one zram-backed /tmp mount and the number of "streams" is automatically handled internally in the kernel: root@rock-pi-e:~# zramctl NAME ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT /dev/zram2 lz4 975.6M 4K 73B 12K 4 [SWAP] /dev/zram1 lz4 10M 400K 16.1K 240K 4 /run /dev/zram0 lz4 30M 68K 1.6K 68K 4 /var/volatile So, in conclusion, the stuff on meta-openembmedded's zram package is: - old - has very few knobs for the user to tweak - doesn't handle the zram-tmpfs case - doesn't update your kernel config automatically (at least for the sysvinit portion)
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#154947): https://lists.openembedded.org/g/openembedded-core/message/154947 Mute This Topic: https://lists.openembedded.org/mt/84982026/21656 Group Owner: openembedded-core+ow...@lists.openembedded.org Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-