/
mkmnt
executable file
·50 lines (47 loc) · 1.32 KB
/
mkmnt
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
#!/bin/bash
# mkmnt - creates mount points and a snippet for fstab
# 20140208 machinebacon - linuxbbq.org
# released under the BBQ beard-wearers-pipe-smokers license (bwpl)
# wget http://linuxbbq.org/mkmnt
sudo -v
echo "These partitions exist :"
sudo blkid -o list
echo
echo "These directories exist in /mnt :"
ls -a /mnt
fstab-build()
{
echo "# from device /dev/sda:"
sudo mount | awk '/^\/dev\/sda/ {print $1,"\t",$3,"\t",$5,"\tdefaults\t0","\t0"}'
echo "# from device /dev/sdb:"
sudo mount | awk '/^\/dev\/sdb/ {print $1,"\t",$3,"\t",$5,"\tdefaults\t0","\t0"}'
echo "# from device /dev/sdc:"
sudo mount | awk '/^\/dev\/sdc/ {print $1,"\t",$3,"\t",$5,"\tdefaults\t0","\t0"}'
}
mounter()
{
echo
echo "Enter Mountpoint name (eg. part1) :"
read n
echo "Device node (eg. /dev/sda4) : "
read m
sudo mkdir -p /mnt/$n
sudo mount $m /mnt/$n
echo "The mountpoints are as follows :"
echo "-----------------------------------------------------------------"
fstab-build
echo "-----------------------------------------------------------------"
}
mounter
echo
read -n1 -p "More? (y/n) "
if [ $REPLY = 'y' ]; then
mounter
fi
echo
echo "You can copy this snippet and paste it into your /etc/fstab file:"
echo
echo "# start: manually added partitions"
fstab-build
echo "# end: manually added partitions"
echo