-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconvert.brfs.sh
More file actions
49 lines (42 loc) · 1.24 KB
/
convert.brfs.sh
File metadata and controls
49 lines (42 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#/bin/bash
set -euxo pipefail
root_mount_by=$(cat /etc/fstab | grep ' / ' | grep -E 'subvol=@([[:space:]]|,)' | cut -f1 -d' ')
sudo btrfs subvolume snapshot / /@
sudo btrfs subvolume create /@home
sudo mv /@/home/* /@home/
sed -e '|" / " |s|^#*|#|' -i /etc/fstab
echo "${root_mount_by} / btrfs defaults,compress=zstd:1,subvol=@ 0 1
${root_mount_by} /home btrfs defaults,compress=zstd:1,subvol=@home 0 2" | sudo tee -a /etc/fstab
sudo sed 's|GRUB_TIMEOUT_STYLE=.*|GRUB_TIMEOUT_STYLE=menu|' -i /etc/default/grub
sudo sed 's|GRUB_TIMEOUT=.*|GRUB_TIMEOUT=10|' -i /etc/default/grub
sudo update-grub
echo "On next boot:
on the linux line
linux /@/boot/...
near the end add:
rootflags=subvol=@
so that it looks like:
ro rootflags=subvol=@ quiet splash
modify initrd:
initrd /@/boot/...
On reboot verify subvol=@ is being used
mount | grep ' / ' | grep subvol=@
"
exit 0
# After restart
# Permanently setup new boot
mount | grep ' / '
mount | grep ' / ' | grep subvol=@ || exit 1
sudo update-grub
grub-install --efi-directory=/boot/efi
reboot
# Remove root
root_device=$(mount | grep ' / ' | cut -f1 -d' ')
sudo mount $root_device /mnt
cd /mnt
ls | grep "^@"
ls | grep "^@" || exit 1
shopt -s extglob
sudo rm -rf !(@*)
shopt -u extglob
sudo umount $root_device