forked from Jagoum/Automated_Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Diskpartition.sh
executable file
·63 lines (58 loc) · 1.55 KB
/
Diskpartition.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
#!/bin/bash
usage() {
echo "To create a partition follow the instructions below"
echo "Enter :"
echo "1 to list the different disk partitions already available. You might be prompted to enter your password."
echo "2 to create a new partition"
echo "3 to exit"
}
partition() {
read num
case $num in
1)
sudo fdisk -l
read -p "Enter p to proceed" p
if [ "$p" = 'p' ]; then
usage
partition
fi
;;
2)
echo "Copy the path to the disk and paste it here : "
read path
if [ ! -d $path ]; then
if [[ "$path" =~ ^/ ]]; then #This statment means if i find something in the home directory that starts with / , then i should go to the root directory and look for the path before patitioning it.
cd /
sudo fdisk $path
fi
echo "Path /dev/nvme0n1p2th to disk does not exist"
read -p "Enter r to return" r
if [ "$r" = 'r' ]; then
usage
partition
fi
else
if [ "${path#/}" != "/" ]; then
cd /
sudo fdisk $path
fi
fi
;;
3)
exit
;;
*)
usage
;;
esac
}
echo "Hello I Guess you will like to partition your disk [yes/no]"
read ans
if [ "$ans" = "yes" ]; then
echo "You are at the right place"
read -p "Now Lets create a partition press c to continue : " c
if [ "$c" = "c" ]; then
usage
partition
fi
fi