-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreconfig.sh
70 lines (49 loc) · 1.63 KB
/
preconfig.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
65
66
67
68
#!/bin/bash
clear
echo "======================================================================"
echo "=========================== Partition Disk ==========================="
echo "======================================================================"
sleep 3
#Listing the available disks
lsblk
#Select the disk for partitioning:-
read -p "Select the disk for partition:- " DISK
if [ "${BIOS}"=="UEFI" ]; then
sgdisk -Z $DISK
sgdisk -a 2048 -o ${DISK}
sgdisk -n 1:0:+500M ${DISK} # partition 1 => EFI Partition
sgdisk -n 2:0:-2G ${DISK} # partition 2 => Root Partition
sgdisk -n 3:0:0 ${DISK} # partition 3 => Swap Partition
# set partition types
sgdisk -t 1:ef00 ${DISK}
sgdisk -t 2:8300 ${DISK}
sgdisk -t 3:8200 ${DISK}
#elif [ $BIOS=="MBR"]; then
# sfdisk -Z $DISK
fi
#Labelling the Partitions
sgdisk -c 1:"EFI" ${DISK}
sgdisk -c 2:"Root" ${DISK}
sgdisk -c 3:"Swap" $DISK
#Getting partition Names
disks=`(fdisk -l) | (grep "^/dev") | (awk '{print $1}')`
partitionNames=()
while read -r line; do
partitionNames+=("$line")
done <<< "$disks"
#Making the FileSystems
mkfs.vfat -F32 -n "EFI" "${partitionNames[0]}"
mkfs.ext4 -L "Root" "${partitionNames[1]}" -F
mkswap "${partitionNames[2]}"
#Mounting the disks
mkdir /mnt/boot
mkdir /mnt/boot/efi
mount ${partitionNames[1]} /mnt
mount ${partitionNames[0]} /mnt/boot/efi
swapon ${partitionNames[2]}
sleep 5
lsblk
echo "======================================================================"
echo "=====================Disk Partitioning Complete======================="
echo "======================================================================"
sleep 3