Disk identification by UUID in Fedora.

Yesterday I managed to delete my complete /usr directory and thus had to re-install my OS but I learned something new yesterday which I didn\’t know earlier or actually never bothered to find out.br /br /All the partitions are mounted by udev using the UUID or label now. Finding the label of setting the label is easy but that was not the case with UUID (at least till you dont know how to do it). So finally I set my foot to search it. Heres some of the things that I found:br /br /bblkid/b – Gives you a list like below for all your partitions:br //dev/sda6: UUID=\”8D8A-6CF1\” TYPE=\”vfat\” LABEL=\”Backup\” br /So this is sufficient to modify your fstab to refer to the UUID or label instead of the drive. So whats the change in fstab. If the earlier entry looks likebr //dev/sdb6nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; /media/Bkup3nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; vfatnbsp;nbsp;nbsp; uid=500,nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 0 0br /then you can change this to :br /UUID=\”8D8A-6CF1\”nbsp;nbsp; /media/Bkup3nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; vfatnbsp;nbsp;nbsp; uid=500,nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; 0 0br /What is the benifit:br /———————br /When you re-format your Hard Disk there is a likely possibility that the dev name could well change and thus completely changing the mount points for all your fstab entries. This is really a pain if you have 10 or more partitions like the way I have. So if you use label or UUID then they never change and your mount points remain the same.br /br /Effective use: Use autofs package to automatically mount all your partitions. Autofs mounts the package at /media/LABEL, so before you hit to start your autofs label all your disks.br /br /Other ways to find the disk labels and UUID\’s:br /ls /dev/disk/by-uuid –gt; simplest way. :)br /br /Will get back to this later with more details.br /br /

Fedora 11 – Mount options for vfat and other volumes for automount.

I have been searching to look for how to change the default umask and dmask for the auto-mounted directories. I searched all the google and bing pages that I could, but to no avail. But I found some interesting info though.

Fedora now uses DeviceKit for managing the disks and Devicekit calls udev for actually mounting and unmounting the disks. The operation is controlled by policykit to determine who can do what?

So, with this information, I was pretty sure that I should resort to fstab to mount my disks. But remember another change Fedora made some time back. UUID are preferred way to mount the disk in the fstab. So I thought why not do it this way, so here\’s what I did (might save you with some time)

lshal|grep uuid

This will give you output like the below:

udi = \’/org/freedesktop/Hal/devices/volume_uuid_4852_A67D\’
info.udi = \’/org/freedesktop/Hal/devices/volume_uuid_4852_A67D\’  (string)
volume.uuid = \’4852-A67D\’  (string)
volume.uuid = \’\’  (string)

This will give you the UUID.  and then you can map the devices with the UUID from the current mount locations.

But if you like to do things the easire way then just run the following:

blkid

The output will be similar to below:

/dev/sda5: LABEL=\”\” UUID=\”XXXX-XXXX\” TYPE=\”vfat\”

Now login as root and add the following to the fstab file in /etc.

If you want to do it with a bash one liner, then you can try this: (Be careful to take a  backup of fstab, as I have not tried this)

IFS=\’

\’;mount_opts=\”rw,uid=500\”; for i in $(blkid|grep \”vfat\”); do  temp=$(echo $i|awk \'{print $3}\’);echo \”$temp $mount_opts 0 0\”; done

Please note that this will not specify the mount point and thus mount will fail, if you directly use the output in the fstab file. You can insert the mount point in the output as second field.

Also, change the mount_opts value in the above to whatever mount options you want.

Mount and unmount/umount images(iso/img) from nautilus (Fixed not mounting in Fedora)

Get the Nautilus Script here. So what is required is that you have the necessary permission to run mount and umount as normal user with sudo command. If you are using gksu or gnomesu then you can change this in the script that you will get. Once you have got the script then you can run the installer for the script that comes in the package.

If you are running this is Fedora then you would need to make one more change other than the ones done by the installer, which is to allow sudo from non tty devices. Since this will be running from the nautilus so the script will not have any tty device and hence you would need to comment the following in the /etc/sudoers file:

so you should change

Defaults    requiretty

to

#Defaults    requiretty

Also note that the script add group called moiso and adds the user to this group and then allows this group to run mount and umount command. If you have already allowed the username to run all commands via sudo then you can skip all the steps of the script and directly copy the script moiso and umoiso to the \”~/.gnome2/nautilus-scripts\” directory and you are done.

If you don\’t feel like doing all this work of downloading and installing then you can simply create one temp diretory in directory of choice (lets say /tmp/mount) and create a new file called \”mount_iso\” in ~/.gnome2/nautilus-scripts with the content below:

sudo mount \”$1\” /tmp/mount

And create umount_iso in the same directory with the below content:

sudo umount /tmp/mount

But I would strongly advise that you use the moiso available at the gnome-look link given above.