diff options
-rw-r--r-- | src/initrd/btrfs-create.sh | 35 |
1 files changed, 25 insertions, 10 deletions
diff --git a/src/initrd/btrfs-create.sh b/src/initrd/btrfs-create.sh index ff09bf7..567ad97 100644 --- a/src/initrd/btrfs-create.sh +++ b/src/initrd/btrfs-create.sh | |||
@@ -109,19 +109,34 @@ copy_execs() | |||
109 | done | 109 | done |
110 | } | 110 | } |
111 | 111 | ||
112 | initialize_root_filesystem() | 112 | is_subvolume() |
113 | { | 113 | { |
114 | rm -r /root/root | 114 | btrfs subvolume show "$1" >/dev/null 2>&1 |
115 | btrfs subvolume create /root/root || return | 115 | } |
116 | mv /gpg/gnupghome /root/root/.gnupg || return | 116 | |
117 | make_subvolume_idem() | ||
118 | { | ||
119 | is_subvolume "$1" && return | ||
120 | if [ -d "$1" ]; then | ||
121 | rmdir "$1" || mv "$1" "$1"~ | ||
122 | btrfs subvolume create "$1" | ||
123 | mv "$1"~/* "$1"~/.* "$1"/ 2>&1 | ||
124 | else | ||
125 | if [ -e "$1" ]; then | ||
126 | rm -f "$1" | ||
127 | fi | ||
128 | btrfs subvolume create "$1" | ||
129 | fi | ||
130 | } | ||
117 | 131 | ||
118 | rmdir /root/srv | 132 | initialize_root_filesystem() |
119 | btrfs subvolume create /root/srv | 133 | { |
120 | rm -r /root/var/cache/apt/archives | 134 | for d in /root/root /root/srv /root/var/cache/apt/archives /root/home; do |
121 | btrfs subvolume create /root/var/cache/apt/archives || return | 135 | make_subvolume_idem "$d" |
136 | done | ||
122 | 137 | ||
123 | rmdir /root/home | 138 | mv /root/root/.gnupg /root/root/.gnupg~ |
124 | btrfs subvolume create /root/home || return | 139 | mv /gpg/gnupghome /root/root/.gnupg || return |
125 | 140 | ||
126 | copy_execs sbin mdadm dmsetup cryptsetup fsck.hfsplus | 141 | copy_execs sbin mdadm dmsetup cryptsetup fsck.hfsplus |
127 | copy_execs bin btrfs rsync gpg gpg2 gpg-agent | 142 | copy_execs bin btrfs rsync gpg gpg2 gpg-agent |