You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
X-mount.mkdir is an option for mount where mount creates the target directory if it doesn't already exists (see man mount).
If one passes this option to zram-init it won't even call mount to give it a change to create the target directory, it will fail first:
root@localhost:~ # zram-init -t ext2 -o x-mount.mkdir=775 -d 3 512 /var/tmp/portage
zram-init:
${dir:-(empty)} is not a directory
If one calls zramctl and mount directly, it works as expected:
root@localhost:~ # zramctl -f -s 512M
/dev/zram3
root@localhost:~ # mkfs.ext2 /dev/zram3 -q
root@localhost:~ # mount /dev/zram3 /var/tmp/portage
mount: /var/tmp/portage: mount point does not exist.
root@localhost:~ # mount /dev/zram3 /var/tmp/portage -o x-mount.mkdir=775
root@localhost:~ # ls -ld /var/tmp/portage
drwxr-xr-x 3 root root 4096 Mar 17 19:41 /var/tmp/portage
Q: What's is the use case for this? Why not simply do an mkdir before running zram-init?
A: On my setup, both /var/tmp and /var/tmp/portage are mounted by zram-init, with different options each. Among the differences there is noexec for /var/tmp (for security reasons) but exec for /var/tmp/portage (required).
Since both mount points are mounted by zram-init triggered by the distribution init scripts (openrc), /var/tmp will necessarily be empty after it's mounted and /var/tmp/portage is then mounted immediately after, leaving no opportunity for me to insert a mkdir command between the two mount operations.
For reference, my actual setup from /etc/conf.d/zram-init:
I did simple check for X-mount.mkdir where zram-init checks if the directory exists, if it's there it won't trigger the error. I'm not sure if it's the best or even appropriate solution but it was what I came up with and it worked for me:
root@localhost:~ # ls -ld /var/tmp/portage
ls: cannot access '/var/tmp/portage': No such file or directory
root@localhost:~ # sh zram-init.sh -t ext2 -o noatime,nosuid,nodev,x-mount.mkdir=775 -c portage:portage -d 3 -D 4 -s 1 -a zstd -L tmp_portage_dir -- 16384 /var/tmp/portage
mke2fs 1.45.5 (07-Jan-2020)
root@localhost:~ # # ls -ld /var/tmp/portage
drwxr-xr-x 3 portage portage 4096 Mar 17 19:47 /var/tmp/portage
I'll be opening a PR next with my patch for discussion.
The text was updated successfully, but these errors were encountered:
X-mount.mkdir
is an option formount
wheremount
creates the target directory if it doesn't already exists (seeman mount
).If one passes this option to
zram-init
it won't even call mount to give it a change to create the target directory, it will fail first:If one calls
zramctl
andmount
directly, it works as expected:Q: What's is the use case for this? Why not simply do an
mkdir
before runningzram-init
?A: On my setup, both
/var/tmp
and/var/tmp/portage
are mounted byzram-init
, with different options each. Among the differences there isnoexec
for/var/tmp
(for security reasons) butexec
for/var/tmp/portage
(required).Since both mount points are mounted by
zram-init
triggered by the distribution init scripts (openrc),/var/tmp
will necessarily be empty after it's mounted and/var/tmp/portage
is then mounted immediately after, leaving no opportunity for me to insert amkdir
command between the two mount operations.For reference, my actual setup from
/etc/conf.d/zram-init
:Solution
I did simple check for
X-mount.mkdir
wherezram-init
checks if the directory exists, if it's there it won't trigger the error. I'm not sure if it's the best or even appropriate solution but it was what I came up with and it worked for me:I'll be opening a PR next with my patch for discussion.
The text was updated successfully, but these errors were encountered: