Script to add all the partitions to the fstab.

Script to add all the partitions to the fstab.

I wrote a simple script today to get all the partitions on all the disks and then create fstab entry with them. The script also gets the UUID and uses the same to make the entry 🙂

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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash -
#===============================================================================
#
#          FILE:  mount_add_all.sh
#
#         USAGE:  ./mount_add_all.sh
#
#   DESCRIPTION:  Find all the <a class="zem_slink freebase/en/disk_partitioning" title="Disk partitioning" rel="wikipedia" href="http://en.wikipedia.org/wiki/Disk_partitioning">disk partitions</a> and all those that are not present
#                 in the fstab.
#
#       OPTIONS:  ---
#  REQUIREMENTS:  ---
#          BUGS:  ---
#         NOTES:  ---
#        AUTHOR:  <a class="zem_slink" title="Digital Inspiration" rel="homepage" href="http://amit-agarwal.co.in">Amit Agarwal</a> (AKA), amit.agarwal@amit-agarwal.co.in
#       COMPANY:  Individual
#       VERSION:  1.0
#       CREATED:  06/19/2010 10:44:34 PM IST
#      REVISION:  0.1
#===============================================================================
file="/tmp/fstab"
disk_types=(hd sd)
count=${#disk_types}

find_disks ()
{
echo ${#disk_types} $count
for i in $(seq 1 $count)
do
(( j=i-1 ))
echo $i $j
echo $j ${disk_types[0]} ${disk_types[1]}
disk_array[$j]=$(ls <a class="zem_slink freebase/en/device_file_system" title="Device file" rel="wikipedia" href="http://en.wikipedia.org/wiki/Device_file">/dev</a>/${disk_types[$j]}[a-z])
echo ${disk_array[$j]}
done
}    # ----------  end of function find_disks  ----------

find_partitions ()
{
echo "In find_partitions"
l=0
count=${#disk_types}
for i in $(seq 1 $count)
do
((j=i-1))
for k in ${disk_array[$i]}
do
echo $k
<!--loginview start-->disk_partitions[$l]=`fdisk -l $k |<a class="zem_slink freebase/en/grep" title="Grep" rel="wikipedia" href="http://en.wikipedia.org/wiki/Grep">grep</a> "^/dev" |grep -v "Extended$"|cut -d" " -f1`
echo ${disk_partitions[$l]} $l<!--loginview end-->
((l++))
done
done
}    # ----------  end of function find_partitions  ----------

add_fat ()
{
echo "# Added with script for $label and $k" >> $file
echo "$uuid /mnt/$label vfat  nosuid,nodev,uhelper=udisks,uid=500,gid=500,shortname=mixed,dmask=0077  0 0"  >> $file
}    # ----------  end of function add_fat  ----------

add_<a class="zem_slink freebase/en/ext3" title="Ext3" rel="wikipedia" href="http://en.wikipedia.org/wiki/Ext3">ext3</a> ()
{
echo "# Added with script for $label and $k" >> $file
echo "$uuid /mnt/$label ext3     defaults     0 0" >> $file

}    # ----------  end of function add_ext3  ----------

find_UUID ()
{
echo "In find_UUID with $l"
((l--))
for i in $(seq 0 $l)
do
echo ${disk_partitions[$i]}
for k in ${disk_partitions[$i]}
do
echo $k
<!--loginview start-->temp=$(blkid $k)
label=$(echo $temp|grep "LABEL="|sed \'s/.*LABEL="//\'|sed \'s/".*//\')
uuid=$(echo $temp|grep "UUID="|sed \'s/.*UUID="//\'|sed \'s/".*//\')
atype=$(echo $temp|grep "TYPE="|sed \'s/.*TYPE="//\'|sed \'s/".*//\')<!--loginview end-->
if [ $atype = "vfat" ]
then
add_fat $label $uuid $k
fi
if [ $atype = "ext3" ]
then
add_ext3 $label $uuid $k
fi
echo $label $uuid $atype
done
done
}    # ----------  end of function find_UUID  ----------

find_disks
find_partitions
find_UUID
\"Enhanced

Fedora 11 Leonidas — Fix HDD (Hard Disk) and CD/DVD automount issues for users other than root.

I have been thinking of putting this for quite some time now. By default no user (other than root) on Fedora 11 has the permission to mount CD/DVD and or ntfs/vfat partitions. So HAL automount does not work for these.

Here is something you can do to fix this:

Open System-> Preferences -> Authourizations

\"Screenshot-Authorizations\"

Now, go to org -> hal -> storage and make the changes to suit your needs. You can add or remove a particular user for the operation with the Grant or Block buttons or for all the users system-wide with the Edit button.

Working with FTP Directories.

If you have to manage some ftp site, I can understand you pain in managing the site with FTP. Specially if you are managing a site where you need to edit the files. Without shelling out some decent amount of money you will not get decent editor which can help you edit the files directly over ftp. So today I spent my time looking for a good solution and UREKA I found it.

download and install curlftpfs. mount your ftp directory onto some directory with a command like the below:
curlftpfs ftp://w/ak /mnt/ftp

Once done use your faviourite file manager of editor to manage it like  a local folder.

PS:: you can use netrc file demonstrated earlier to make sure you dont have to type the username and password.
Technorati Tags: Linux, FTP, edit, file, mount