[Pkg-utopia-maintainers] Bug#945539: udisks2: Make it possible to use zram device for /tmp
Dmitry Katsubo
dma_k at mail.ru
Tue Nov 26 17:14:18 GMT 2019
Package: udisks2
Version: 2.8.4-1
Severity: wishlist
It would be nice if the service script zram-setup at .service could support
creating partitions for /tmp. I think at the end of the day that is a
nice usecase!
I have implemented the service /etc/systemd/system/zram-setup at .service
as follows:
[Unit]
Description=Setup zram based device %i
After=dev-%i.device
Requires=dev-%i.device
Before=local-fs.target umount.target
[Service]
Type=oneshot
RemainAfterExit=yes
EnvironmentFile=-/etc/zram.conf.d/%i
ExecStart=/bin/sh -c 'if [ -n "$ZRAM_COMPRESSION" ]; then echo
$ZRAM_COMPRESSION > /sys/class/block/%i/comp_algorithm; fi'
ExecStart=/bin/sh -c 'if [ -n "$ZRAM_STREAMS_NUM" ]; then echo
$ZRAM_STREAMS_NUM > /sys/class/block/%i/max_comp_streams; fi'
ExecStart=/bin/sh -c 'if [ -n "$ZRAM_DEV_SIZE" ]; then echo
$ZRAM_DEV_SIZE > /sys/class/block/%i/disksize; fi'
ExecStart=/bin/sh -c 'if [ "$SWAP" = "y" ]; then mkswap /dev/%i
&& swapon /dev/%i; fi'
ExecStart=/bin/sh -c 'if [ "$TMP" = "y" ]; then mke2fs -q -m 0
-b 4096 -O sparse_super -L %i /dev/%i && mount -t ext2 /dev/%i /tmp &&
chmod 1777 /tmp; fi'
ExecStop=-/bin/sh -c 'echo 1 > /sys/class/block/%i/reset'
[Install]
WantedBy=local-fs-pre.target
/etc/zram.conf.d/zram0:
ZRAM_COMPRESSION=lz4
ZRAM_DEV_SIZE=100M
SWAP=y
/etc/zram.conf.d/zram1:
ZRAM_COMPRESSION=lz4
ZRAM_DEV_SIZE=100M
TMP=y
After that comment out mounting of /tmp in fstab and:
systemctl enable zram-setup at zram0.service
systemctl enable zram-setup at zram1.service
I have encountered a problem that there is no "mode=1777" mount option
for ext2, that is why I call "chmod 1777" explicitly after mounting it.
Any further improvements are welcomed.
--
With best regards,
Dmitry
More information about the Pkg-utopia-maintainers
mailing list