-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathdisk.sh
More file actions
executable file
·82 lines (57 loc) · 2.77 KB
/
disk.sh
File metadata and controls
executable file
·82 lines (57 loc) · 2.77 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# CodeVerse Linux Installer - Disk Module
# Disk partitioning and formatting functions
# Partition the disk
partition_disk() {
step_header "Partitioning Disk"
gum style --faint " Preparing disk..."
# Wipe existing partition table
gum spin --spinner dot --title "Wiping partition table..." -- bash -c "wipefs -af '$DISK' >/dev/null 2>&1 || true; sgdisk -Z '$DISK' >/dev/null 2>&1 || true"
if [[ "$BOOT_MODE" == "uefi" ]]; then
partition_disk_uefi
else
partition_disk_bios
fi
gum style --foreground 82 " ✓ Disk prepared successfully"
}
# Partition disk for UEFI
partition_disk_uefi() {
gum style --foreground 6 " ● Creating GPT partition table (UEFI)"
gum spin --spinner dot --title "Creating GPT table..." -- parted -s "$DISK" mklabel gpt
gum spin --spinner dot --title "Creating EFI partition..." -- bash -c "parted -s '$DISK' mkpart primary fat32 1MiB 513MiB; parted -s '$DISK' set 1 esp on"
gum spin --spinner dot --title "Creating root partition..." -- parted -s "$DISK" mkpart primary ext4 513MiB 100%
EFI_PART=$(get_partition_name "$DISK" 1)
ROOT_PART=$(get_partition_name "$DISK" 2)
sleep 1 # Wait for kernel to recognize partitions
gum style --foreground 6 " ● Formatting EFI partition (FAT32)"
gum spin --spinner dot --title "Formatting EFI..." -- mkfs.fat -F32 "$EFI_PART"
gum style --foreground 6 " ● Formatting root partition (ext4)"
gum spin --spinner dot --title "Formatting root..." -- mkfs.ext4 -F "$ROOT_PART"
gum style --foreground 6 " ● Mounting partitions"
mount "$ROOT_PART" /mnt
mkdir -p /mnt/boot/efi
mount "$EFI_PART" /mnt/boot/efi
}
# Partition disk for BIOS
partition_disk_bios() {
gum style --foreground 6 " ● Creating MBR partition table (BIOS)"
gum spin --spinner dot --title "Creating MBR table..." -- parted -s "$DISK" mklabel msdos
gum spin --spinner dot --title "Creating boot partition..." -- bash -c "parted -s '$DISK' mkpart primary ext4 1MiB 100%; parted -s '$DISK' set 1 boot on"
ROOT_PART=$(get_partition_name "$DISK" 1)
sleep 1
gum style --foreground 6 " ● Formatting root partition (ext4)"
gum spin --spinner dot --title "Formatting root..." -- mkfs.ext4 -F "$ROOT_PART"
gum style --foreground 6 " ● Mounting partition"
mount "$ROOT_PART" /mnt
}
# Generate fstab
generate_fstab() {
step_header "Generating Filesystem Table"
gum spin --spinner dot --title "Creating /etc/fstab..." -- bash -c "genfstab -U /mnt >> /mnt/etc/fstab"
gum style --foreground 82 " ✓ Filesystem table generated"
}
# Unmount all partitions
unmount_all() {
gum spin --spinner dot --title "Unmounting partitions..." -- umount -R /mnt
gum style --foreground 82 " ✓ Partitions unmounted"
}