ZRAM-INIT(8)

πŸ“¦ version 13.0.1, in alpine 3.24

πŸ¦‹ ZRAM-INIT πŸ¦‹

okay so welcome to zram-init(8) β€” section 8 of the manual, system administration territory, and honestly? this page ate. it's a script that makes compressed swap devices and ramdisks happen with zram, and you're gonna understand every single flag by the end. no cap. πŸ’…


πŸ’– NAME πŸ’–

zram-init β€” scripts to support compressed swap devices or ramdisks with zram. that's it, that's the whole vibe. 🫢


✨ SYNOPSIS ✨

zram-init [options] SIZE|write [DIR]

🌸 DESCRIPTION 🌸

So what this actually does: it prepares a zram device and then uses it as swap (or mounts it under DIR β€” your call, bestie). SIZE is the maximal size in megabytes. And if you wanna umount/free that zram device? You set SIZE=0. that's the off switch, periodt. πŸŽ€

When you use write β€” or literally anything else that starts with w β€” an idle writeback is forced. heads up tho: that only makes sense if you previously initialized with -w or -W LIMIT. otherwise it's giving nothing. πŸ™ˆ

Now the fun part: if DIR is -, then only a filesystem is created in /dev/zramDEV (or the device gets removed if SIZE is 0), but it is not mounted. and yes, that means options -o, -c, -m, -T take no effect in this case β€” of course they don't, you literally didn't mount anything. 😭

Why would you even want that? the manual says the latter can be useful e.g. for btrfs if multiple devices should be mounted jointly afterwards. very main character energy of btrfs ngl. πŸ”₯


πŸ‘‘ OPTIONS πŸ‘‘

first rule of options club: an empty argument means the same as if the option is not specified. so don't stress if something comes through blank. 🌈

  • -d DEV β€” use zram device /dev/zramDEV. default is 0, so /dev/zram0. make sure to use the matching value for unmounting (SIZE=0) β€” seriously, keep track of which device you grabbed. πŸ’€
  • -D NUM β€” if modprobe needs to be used, require NUM devices. and the manual is very clear here: this is not recommended. instead rely on /etc/modprobe.d/zram.conf with the line options zram num_devices=NUM. do it the good way, bestie. ⭐
  • -s NUM β€” use up to NUM parallel compression streams for the device. go parallel, go fast. πŸ’¨
  • -S MAX β€” use maximally MAX megabytes of uncompressed memory for the device. memory budget: set. πŸ“
  • -b DEV β€” use DEV as the backing device. πŸ¦‹
  • -I β€” if combined with -b DEV, store incompressible pages to the backing device. the stubborn pages get evicted ✨
  • -w β€” if combined with -b DEV, enable idle writeback to the backing device. πŸ’œ
  • -W LIMIT β€” same as -w, but additionally set writeback_limit to LIMIT * 4kB. math! 🧚
  • -a 842|deflate|lz4|lz4hc|lzo|zstd β€” set the compression algorithm used for compressing data in the zram device. pick your fighter. πŸ”₯
  • -c OWNER β€” chown to OWNER (or OWNER:GROUP) after mounting. πŸ’…
  • -m MODE β€” chmod DIR to MODE after mounting. πŸŽ€
  • -o OPTS β€” mount DIR with -o OPTS. 🫢
  • -p PRIO β€” use priority PRIO for the swap device. default is 16383. and if you want to keep the default priority (-1), use PRIO=-. 😌
  • -t ext2|ext4|btrfs|xfs β€” set the filesystem type if DIR is specified. default is ext4. 🌸
  • -B BSIZE β€” override default blocksize (ext2, ext4). valid values are 1024, 2048, 4096. only those three, don't get creative. πŸ™ˆ
  • -i IRATIO β€” override default bytes/inodes in fs (ext2, ext4). πŸ¦‹
  • -N INODES β€” override inode count (ext2, ext4). πŸ“
  • -L LABEL β€” specify the label LABEL for the new filesystem. name her. πŸ‘‘
  • -U UUID β€” specify the uuid UUID for the new filesystem. πŸ’œ
  • -T β€” do not use the discard (TRIM) feature of ext4/swap. use this option with linux-3.14 or earlier, or when you want a slight speed increase at the cost of possibly wasting a lot of memory. like, a lot of memory. you've been warned, bestie 😭
  • -l β€” do not use zramctl even if it's available. 🧚
  • -k β€” do not attempt to umount/free a previously used zram under this device. leave it be. βœ‹

🌟 the push.sh era 🌟

if you have push.sh in $PATH, you can also use the following options accumulatively β€” stack 'em, layer 'em, go off:

  • -K ARG β€” pass ARG to the respective mkswap or mkfs.* call. ⭐
  • -M ARG β€” pass ARG to the respective swapon/mount call. πŸ”₯
  • -2 ARG β€” pass ARG to the tune2fs call (ignored unless for ext2 or ext4). 🌈
  • -Z ARG β€” pass ARG to the zramctl call. πŸ’…

tiny but mighty: call with LANG=C to disable translations. iykyk 🌸

🫢 AUTHORS 🫢

Martin VΓ€th <martin at mvath.de> β€” developer, current maintainer. thank you for your service, king πŸ‘‘


🌈 SEE ALSO 🌈

The zram-init homepage https://github.com/vaeth/zram-init provides… (the source sentence kinda trails off in the original, but the link is the link, bestie β€” go click it πŸ’–)


aaaand that's the page!! this was zram-init, the July 2020 edition, brought to you by section 8 of the manual. go compress something. slay. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from