-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREMOVE_INSTALED_SYSTEM.sh
More file actions
executable file
·57 lines (51 loc) · 1.53 KB
/
Copy pathREMOVE_INSTALED_SYSTEM.sh
File metadata and controls
executable file
·57 lines (51 loc) · 1.53 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
49
50
51
52
53
54
55
56
57
#!/bin/bash
# Setting variables
LVM_VOLUME="/dev/mainvg/mining_randomx"
BTRFS_DEVICE="/dev/nvme0n1p9"
BTRFS_SUBVOLUME="@mining_randomx_boot"
MOUNT_POINT="/mnt/btrfs_mount"
# Removing LVM volume
echo "Removing LVM volume: $LVM_VOLUME"
if lvdisplay $LVM_VOLUME &>/dev/null; then
sudo lvremove -y $LVM_VOLUME
if [ $? -eq 0 ]; then
echo "LVM volume $LVM_VOLUME successfully removed."
else
echo "Error when removing LVM volume $LVM_VOLUME."
exit 1
fi
else
echo "LVM volume $LVM_VOLUME not found."
fi
# Mounting Btrfs partition
echo "Mounting Btrfs partition: $BTRFS_DEVICE"
sudo mkdir -p $MOUNT_POINT
sudo mount $BTRFS_DEVICE $MOUNT_POINT
if [ $? -ne 0 ]; then
echo "Error when mounting Btrfs partition $BTRFS_DEVICE."
exit 1
fi
# Removing Btrfs subvolume
echo "Removing subvolume: $BTRFS_SUBVOLUME"
if sudo btrfs subvolume show $MOUNT_POINT/$BTRFS_SUBVOLUME &>/dev/null; then
sudo btrfs subvolume delete $MOUNT_POINT/$BTRFS_SUBVOLUME
if [ $? -eq 0 ]; then
echo "Subvolume $BTRFS_SUBVOLUME successfully removed."
else
echo "Error when removing subvolume $BTRFS_SUBVOLUME."
sudo umount $MOUNT_POINT
exit 1
fi
else
echo "Subvolume $BTRFS_SUBVOLUME not found."
fi
# Unmounting Btrfs partition
echo "Unmounting Btrfs partition: $BTRFS_DEVICE"
sudo umount $MOUNT_POINT
if [ $? -eq 0 ]; then
echo "Btrfs partition $BTRFS_DEVICE successfully unmounted."
else
echo "Error when unmounting Btrfs partition $BTRFS_DEVICE."
exit 1
fi
echo "Operations completed."