It's a necessary hassle

How to have a reasonable relationship with your OSes.

It’s a necessary hassle ?! Or maybe it takes learning (getting used to it). But I really don’t want to do anything.

I have multiple Manjaro and arclinux-based distributions (eos, cachy) installed. I use them to compare DEs and test before they break. I take excessive backups and snapshots, but I don’t think about it, so I do it to repair the occasional breakdown.

By the way, I noticed that my main 5-year-old installation (cinnamon) takes a few extra seconds to boot. It doesn’t affect my actual use, but I was just looking into mkinitcpio.conf.

I added the following settings and it really made booting from grub faster. Lol. mkinitcpio -P

https://wiki.archlinux.org/title/Mkinitcpio

COMPRESSION="zstd"
COMPRESSION_OPTIONS=(-v -5 --long)

I wonder if the default settings are better. I’m happy with the results.

I have enough RAM. I also added btrfs to the hook.

btrfs device scan | sort
Scanning for Btrfs filesystems
registered: /dev/nvme0n1p3
registered: /dev/nvme0n1p5
registered: /dev/nvme0n1p6
registered: /dev/nvme0n1p8
registered: /dev/nvme0n1p9
registered: /dev/nvme2n1p3
registered: /dev/nvme3n1p1
registered: /dev/sda
registered: /dev/sdb
registered: /dev/sdc
registered: /dev/sdd
registered: /dev/sde
registered: /dev/sdg1

This has been default for a long time.
Have you neglected pacnews ?

This is setting the compression level.
Default is 3.
I would be flabbergasted if you got higher speeds from what is essentially double the compression (and then double the decompression).

I might often expect this to create losses … but it all depends on what kind of matches.

See also these tables;

When there are many long distance matches:

Method Compression ratio Compression speed Decompression speed
zstd -1 5.065 284.8 MB/s 759.3 MB/s
zstd -5 5.826 124.9 MB/s 674.0 MB/s
zstd -10 6.504 29.5 MB/s 771.3 MB/s
zstd -1 --long 17.426 220.6 MB/s 1638.4 MB/s
zstd -5 --long 19.661 165.5 MB/s 1530.6 MB/s
zstd -10 --long 21.949 75.6 MB/s 1632.6 MB/s

And when there are few long distance matches:

Method Compression ratio Compression speed Decompression speed
zstd -1 2.878 231.7 MB/s 594.4 MB/s
zstd -1 --long 2.929 106.5 MB/s 517.9 MB/s
zstd -5 3.274 77.1 MB/s 464.2 MB/s
zstd -5 --long 3.319 51.7 MB/s 371.9 MB/s
zstd -10 3.523 16.4 MB/s 489.2 MB/s
zstd -10 --long 3.566 16.2 MB/s 415.7 MB/s

Docs:


PS.

If you really care about speed … you might want to use --fast or --fast=# … these will really speed things up in exchange for a loss of some compression ratio.

Or … use lzop which is just faster.

(lz4 could get a mention here, but its speed is comparable to lzop, while having worse compression)

2 Likes
Method Compression ratio Compression speed Decompression speed
zstd -5 --long 19.661 165.5 MB/s 1530.6 MB/s

This looks attractive to try, how much RAM might be needed?

Note that that table is explicitly for when there are many long matches.
Thats the only reason it looks that way.
(maybe I should amend the post to reflect this - OK, did it)

Comparitvely they provide a second table when there are few long distance matches:

Method Compression ratio Compression speed Decompression speed
zstd -1 2.878 231.7 MB/s 594.4 MB/s
zstd -1 --long 2.929 106.5 MB/s 517.9 MB/s
zstd -5 3.274 77.1 MB/s 464.2 MB/s
zstd -5 --long 3.319 51.7 MB/s 371.9 MB/s
zstd -10 3.523 16.4 MB/s 489.2 MB/s
zstd -10 --long 3.566 16.2 MB/s 415.7 MB/s

I dont know. But I’m guessing its well within most desktops for decompressing the kernel during boot. zstd has algorithms for extremely memory constrained environments - like in the hundreds of kb, so I’m just figuring in the case of Xgb linux boot … you are fine.
Its more a general ‘this will use more RAM’.

I still say most folks would get the most boosts from lzop if they care most about decompression speed.

Or heck - you can set no compression if space is of no concern. 0 decompression.

2 Likes

I wonder if changing the defaults is really worth the hassle. For context, we are talking about 14 MB and 1.2 seconds here.

[teo@teo-lenovo-v15 ~]$ ls -lh /boot | grep 'initramfs\|vmlinuz' | grep -v 'fallback'
-rw------- 1 root root  14M 10. Okt 16:35 initramfs-6.1-x86_64.img
-rw------- 1 root root  15M 10. Okt 16:35 initramfs-6.6-x86_64.img
-rw-r--r-- 1 root root  12M 10. Okt 07:32 vmlinuz-6.1-x86_64
-rw-r--r-- 1 root root  13M 10. Okt 07:32 vmlinuz-6.6-x86_64
[teo@teo-lenovo-v15 ~]$ systemd-analyze
Startup finished in 9.756s (firmware) + 1.662s (loader) + 628ms (kernel) + 1.281s (initrd) + 4.233s (userspace) = 17.562s 
graphical.target reached after 3.614s in userspace.

p.s. ok i admit this is with the boot on SSD. It will be slower on a spinning disk.

@cscs

thanks.

COMPRESSION="zstd"
COMPRESSION_OPTIONS=(-v -3 --long)

I set it to 3.

It looks like this now. I’m quite satisfied. This is to be expected, as there are many disks/RAIDs attached.

systemd-analyze
Startup finished in 23.018s (firmware) + 11.608s (loader) + 8.148s (kernel) + 1min 3.821s (userspace) = 1min 46.597s
graphical.target reached after 1min 3.451s in userspace.

previous file

ll mkinitcpio.conf*
-rw-r--r-- 1 root root 3298 2024-05-30 23:59 mkinitcpio.conf
-rw-r--r-- 1 root root 2518 2021-03-22 14:21 mkinitcpio.conf_orgin

Normally, pacnew is automatically detected by the hook, so I don’t think it’s likely that it’s overlooked, but you may be right.I am occasionally senile.

I’ve been using this script for about a year now. Thank you.
@Ste74

2021-03-22 14:21 mkinitcpio.conf_orgin << just garbage

According to my notes from 6 months ago about boot times.
In my case, this seems to have reduced the time by about 50 seconds since then.
From selecting grub menu and hitting enter, to the time the desktop screen appears.
About 29 seconds.
Amazing.

I could write more of a response to both of these, but its all roughly covered by mentioning the drop-in that I use. This takes about no effort, and wont be bothered by a pacnew (whether this is good or bad may be arguable).

$ cat /etc/mkinitcpio.conf.d/mine.conf 
MODULES=(i2c_algo_bit xhci_pci ext4 video amdgpu)
HOOKS=(autodetect systemd microcode modconf kms keyboard block filesystems fsck)
COMPRESSION="lzop"

You could create it it with a simple

sudo mkdir -p /etc/mkinitcpio.conf.d && grep -E '^[A-Z]' /etc/mkinitcpio.conf | sudo tee /etc/mkinitcpio.conf.d/custom.conf

(added a ‘create directory if not existing’ first, then just pipe active lines to new file)

From there you can edit it.

sudoedit /etc/mkinitcpio.conf.d/custom.conf

Then you just need to do your rebuilds, ex:

sudo mkinitcpio -P && sudo update-grub

And not more bother except when you want to make more changes.

2 Likes

I forgot i actually customized the default hooks (mainly autodetect and systemd) so i guess i am already quite optimized, beside on a ssd. So for me if i play with the compression it will make maximum half of a second difference.
Here are my hooks

HOOKS=(autodetect systemd microcode modconf kms block keyboard sd-vconsole filesystems fsck)
1 Like

Always nice to see someone else with good systemd HOOKS instead of base,udev, etc.

I actually got the idea from you. But for anyone wanting to play with hooks, the obligatory read where everything is explained is
https://wiki.archlinux.org/title/Mkinitcpio#Common_hooks

1 Like

I prefer to read and understand what is going on because I like having my system under my control instead of following the herd-mentality consenus or ChatGPT

2 Likes

If you are using btrfs, there is another option:

  • Enable compression allover in btrfs
UUID=3487ba3d-1cba-xxxx-a043-c420ebca2aca	/			btrfs	rw,noatime,compress=zstd:9,subvol=@			0 0
  • Disable compression for initrd
# COMPRESSION
# Use this to compress the initramfs image. By default, zstd compression
# is used for Linux ≥ 5.9 and gzip compression is used for Linux < 5.9.
# Use 'cat' to create an uncompressed image.
#COMPRESSION="zstd"
#COMPRESSION="gzip"
#COMPRESSION="bzip2"
#COMPRESSION="lzma"
#COMPRESSION="xz"
#COMPRESSION="lzop"
#COMPRESSION="lz4"
#akf
COMPRESSION=cat

The inititrd will not be compressed while it is created.
But while it is stored in its place btrfs will compress it.

When booting, btrfs will decompress everything on the fly.

:footprints:

2 Likes

Great idea!!

Found this on a forum the day before yesterday. cat

Users don’t have to be aware of it.

Unfortunately, my main Linux root is Manjaro Cinnamon on EXT4.

Second Linux has btrfs root (Manjaro KDE). Fresh install.

All other distributions have btrfs root. Converted from EXT4 to BTRFS this year and tweaked them.

I have my largest volume configured in BTRFS RAID.

1 Like

I had set it 2.
I wonder…There’s no way for me to know the answer.

slow disk, fast processor: → use high compression (4-8)
fast disk, slow processor: → use default compression (3)
fast disk, very slow processor → use low compression (1-3)
fast disk, fast processor: → use what you want :wink: (9)
slow disk, slow processor: → upgrade system :man_shrugging:

Compression ratio is ca. 2:1 over all files on my computers

:footprints:

4 Likes