This repository has been archived on 2024-04-07. You can view files and clone it, but cannot push or open issues or pull requests.
dotfiles/root/_create-subvolumes

24 lines
549 B
Plaintext
Raw Permalink Normal View History

2021-06-23 06:49:38 +02:00
#!/bin/sh
2021-06-23 16:59:23 +02:00
set -e
BTRFS_ROOT="{{@@ filesystem.partitions['/'] @@}}"
if ! mountpoint "$BTRFS_ROOT"
2021-06-23 06:49:38 +02:00
then
2021-06-23 16:59:23 +02:00
mkdir -p "$BTRFS_ROOT"
mount "$BTRFS_ROOT"
2021-06-23 06:49:38 +02:00
fi
2021-06-23 16:59:23 +02:00
cd "$BTRFS_ROOT"
2021-06-23 06:49:38 +02:00
2021-06-23 16:59:23 +02:00
{%@@ set new_partitions = filesystem.partitions.update({root_subvol: '/'}) @@%}
2021-06-23 06:49:38 +02:00
{%@@ for name, path in filesystem.partitions.items() @@%}
test -e "./{{@@ name @@}}" ||
btrfs subvolume create "./{{@@ name @@}}"
test -d "{{@@ path @@}}" ||
mkdir -p "{{@@ path @@}}"
mountpoint "{{@@ path @@}}" ||
mount "{{@@ path @@}}"
{%@@ endfor @@%}