-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrw-rescue.sh
64 lines (57 loc) · 2.85 KB
/
rw-rescue.sh
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
echo -e "----------------------------------------------------------------------------------"
echo -e " __________ ._____ __ .__ "
echo -e " \\______ \\ _________ __| _/ \\ / \\____ ______________|__| ___________ "
echo -e " | _// _ \\__ \\ / __ |\\ \\/\\/ |__ \\\\_ __ \\_ __ \\ |/ _ \\_ __ \\ "
echo -e " | | ( <_> ) __ \\/ /_/ | \\ / / __ \\| | \\/| | \\/ ( <_> ) | \\/ "
echo -e " |____|_ /\\____(____ |____ | \\__/\\ / (____ /__| |__| |__|\\____/|__| "
echo -e " \\/ \\/ \\/ \\/ \\/ "
echo -e "----------------------------------------------------------------------------------"
echo -e "- Remounts encrypted Arch drive"
echo -e "----------------------------------------------------------------------------------"
sleep 1
set -e
echo "Please select the disk you installed Arch on:"
select ENTRY in $(lsblk -dpnoNAME|grep -P "/dev/sd|nvme|vd");
do
DISK=$ENTRY
if [[ -n "$DISK" ]]; then
if [[ ${DISK} =~ "nvme" ]]; then
DISKP=${DISK}p
else
DISKP=${DISK}
fi
echo "Remounting LUKS partition ${DISKP}3, with /efi ${DISKP}2"
break
fi
done
read -r -s -p "Enter encryption password: " password
echo ""
echo -n "$password" | cryptsetup open "${DISKP}3" cryptroot -d -
mountpoint -q "/mnt" && umount -R "/mnt"
# Format warning
read -p "Run disk check? - fsck (y/N):" formatdisk
case $formatdisk in
y|Y|yes|Yes|YES)
btrfs check /dev/mapper/cryptroot
;;
*)
;;
esac
echo ""
echo "--------------------------------------------------------------------------"
echo "- Remounting disc "
echo "--------------------------------------------------------------------------"
mountpoint -q "/mnt" && umount -R "/mnt"
mkdir -p /mnt
mount -o defaults,compress=zstd,noatime,space_cache=v2,subvol=@ /dev/mapper/cryptroot /mnt
mount -t vfat "${DISKP}2" /mnt/efi
mount -o defaults,compress=zstd,noatime,space_cache=v2,subvol=@home /dev/mapper/cryptroot /mnt/home
mount -o defaults,compress=zstd,noatime,space_cache=v2,subvol=@cache /dev/mapper/cryptroot /mnt/var/cache
mount -o defaults,compress=zstd,noatime,space_cache=v2,subvol=@log /dev/mapper/cryptroot /mnt/var/log
mount -o defaults,noatime,subvol=@swap /dev/mapper/cryptroot /mnt/swap
mount -o defaults,compress=zstd,noatime,space_cache=v2,subvol=@snapshots /dev/mapper/cryptroot /mnt/.snapshots
mount -o defaults,compress=zstd,noatime,space_cache=v2,subvol=@homesnaps /dev/mapper/cryptroot /mnt/home/.snapshots
echo "--------------------------------------------------------------------------"
echo "- Disc remounted "
echo "--------------------------------------------------------------------------"