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
Bash
Executable File

#!/bin/sh
set -e
BTRFS_ROOT="{{@@ filesystem.partitions['/'] @@}}"
if ! mountpoint "$BTRFS_ROOT"
then
mkdir -p "$BTRFS_ROOT"
mount "$BTRFS_ROOT"
fi
cd "$BTRFS_ROOT"
{%@@ set new_partitions = filesystem.partitions.update({root_subvol: '/'}) @@%}
{%@@ 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 @@%}