hetzneronline / installimage

Bash scripts to universally deploy various distributions
Other
517 stars 143 forks source link

Fix creation of subvolumes nested in a directory #44

Closed timakro closed 2 years ago

timakro commented 2 years ago

This is the example subvolume configuration the user will see in the editor to uncomment or adapt to their own liking.

SUBVOL btrfs.1  @           /
SUBVOL btrfs.1  @/usr       /usr

Now consider this slightly modified configuration.

SUBVOL btrfs.1  @           /
SUBVOL btrfs.1  @/var/log   /var/log

This modified configuration is failing with the following error.

[14:27:16] creating btrfs subvolume btrfs.1/@/var/log at /var/log on /dev/sda1
[14:27:16] :   ERROR: cannot access '/tmp/btrfs.MaLyd/btrfs.1/@/var': No such file or directory

The problem being that the btrfs subvolume create command expects the parent directory of the subvolume to exist. This commit adds a mkdir command to create the parent directory.

I tested this on a fresh Hetzner machine in rescue mode by copying the /root/.oldroot/nfs/install/ directory to a writeable location, adding the mkdir line and pointing the installimage shell alias to the new location.

asciiprod commented 2 years ago

Thanks!