Sample Header Ad - 728x90

Can't mount zram device on /tmp (Booting problem)

1 vote
1 answer
889 views
I have a simple script that creates a zram device and formats it to ext4 and finally, it mounts zram on /tmp.
#!/bin/bash

# create zram with size 1.5G
# $zram_dev is created device path (eg. /dev/zram1)
zram_dev=$(/usr/sbin/zramctl -f -s 1536M)

# format it to ext4
yes | /usr/sbin/mkfs.ext4 $zram_dev 

# mount it on /tmp
/usr/bin/mount $zram_dev /tmp
It works when I manually run it. But obviously, I don't want to run it after every login. I put that script in root crontab and I rebooted the system, and then I couldn't get my graphical interface, I removed it from crontab and everything worked fine. And at the end of the day, I changed the mount directory to something else like /zram and rebooted the system, surprisingly system comes up. (zram device was created and was mounted on /zram) I should mention that I tried to do that automation with systemd service and I get the same result I just want to know why I can't mount the zram device on /tmp? OS: Linux fedora 5.17.5-300.fc36.x86_64 #1 SMP PREEMPT x86_64 x86_64 x86_64 GNU/Linux
Asked by linux user (11 rep)
Jul 16, 2022, 09:18 AM
Last activity: Sep 11, 2022, 05:46 PM