Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a mount script instead of editing /etc/fstab #15

Merged
merged 1 commit into from
Jun 6, 2023
Merged

Conversation

jandubois
Copy link
Member

This enables support for mount points that include spaces. /etc/fstab normally supports encoding special characters in filenames using octal constants (like "\040` for a space), but that doesn't work on Alpine.

$ l shell rd ls /Applications/Rancher\ Desktop.app/Contents/Resources/resources
darwin             icons              linux              preload.js         rancher-dashboard  rdx-proxy.tgz

$ l shell rd cat /etc/lima-mounts
#!/bin/sh -eux
mkdir -p "/Users/jan"
mount -t 9p -o "ro,trans=virtio,version=9p2000.L,msize=131072,cache=fscache,nofail" mount0 "/Users/jan"
mkdir -p "/Volumes/ThunderBlade"
mount -t 9p -o "rw,trans=virtio,version=9p2000.L,msize=131072,cache=mmap,nofail" mount1 "/Volumes/ThunderBlade"
mkdir -p "/tmp/lima"
mount -t 9p -o "rw,trans=virtio,version=9p2000.L,msize=131072,cache=mmap,nofail" mount2 "/tmp/lima"
mkdir -p "/Applications/Rancher Desktop.app/Contents/Resources/resources"
mount -t 9p -o "rw,trans=virtio,version=9p2000.L,msize=131072,cache=mmap,nofail" mount3 "/Applications/Rancher Desktop.app/Contents/Resources/resources"

@jandubois jandubois requested a review from mook-as June 6, 2023 21:51
mook-as
mook-as previously approved these changes Jun 6, 2023
lima-init.sh Outdated Show resolved Hide resolved
sed -i '/#LIMA-START/,/#LIMA-END/d' /etc/fstab
echo "#LIMA-START" >> /etc/fstab
awk -f- "${LIMA_CIDATA_MNT}"/user-data <<'EOF' >> /etc/fstab
MOUNT_SCRIPT=/etc/lima-mounts
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I'm not sure (as a script) it should live in /etc. But I guess that doesn't hurt? It's not as if /etc/init.d/ isn't full of scripts…

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know where else to put it. And I wanted to keep a record of it, which is why I didn't just pipe it into the shell.

@@ -49,15 +49,17 @@ awk -f- "${LIMA_CIDATA_MNT}"/user-data <<'EOF' >> /etc/fstab
flag = 0
}
flag {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit can use more documentation.

Given a line like:

- [mount1, /tmp/rancher-desktop, 9p, "rw,trans=virtio,version=9p2000.L,msize=131072,cache=mmap,nofail", "0", "0"]

@@ -49,15 +49,17 @@ awk -f- "${LIMA_CIDATA_MNT}"/user-data <<'EOF' >> /etc/fstab
flag = 0
}
flag {
# Use a pattern unlikely to appear in a filename. "\0" unfortunately doesn't work.
FS = "<;><><;>"
sub(/^ *- \[/, "")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strips the -[ prefix…

@@ -49,15 +49,17 @@ awk -f- "${LIMA_CIDATA_MNT}"/user-data <<'EOF' >> /etc/fstab
flag = 0
}
flag {
# Use a pattern unlikely to appear in a filename. "\0" unfortunately doesn't work.
FS = "<;><><;>"
sub(/^ *- \[/, "")
sub(/"?\] *$/, "")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This strips the ] suffix, possibly with a " in front…

sub(/^ *- \[/, "")
sub(/"?\] *$/, "")
gsub("\"?, \"?", "\t")
print $0
gsub("\"?, \"?", FS)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And this… replaces ", " with the field separator? So it's a very limited YAML parse.

This enables support for mount points that include spaces. `/etc/fstab`
normally supports encoding special characters in filenames using octal
constants (like "\040` for a space), but that doesn't work on Alpine.

Signed-off-by: Jan Dubois <jan.dubois@suse.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants