Mar 11

Automount partition using UUID in Ubuntu

Scribbled on Tuesday, March 11th, 2008

Updated on: 02 Feb, 2009 at 3:08 AM IST

Here is a tutorial to mount your drive partitions using UUID (even if u change the label and swap ur hard drives this thing will not change). The UUID of a particular partition changes only after format/deletion of that drive.

Step by step approcah:

For NTFS volume you have to install ntfs-3g driver, use the below command to install it

sudo apt-get update && sudo apt-get install ntfs-3g

Step 1 (Create a directory in media folder to mount the desired partition)
Use mkdir command to create a directory named dld.

sudo mkdir /media/dld
If you are mounting an EXT3 partition or having trouble writing to a mounted partition  then change the ownership of the mount folder to your username. Use the below command to change the ownership of folder dld to username noface.

sudo chown -R noface /media/dld

You should be able to write on EXT3 partition now.

Here dld is the directory on which I want to mount sda8 partition

Step 2 (Find out UUID of the desired partition sda6)
Use either blkid or the other command to find out UUID of a partition, a UUID is a unique signature identification for a partition of Hard-Disk.

blkid

or

ls /dev/disk/by-uuid

Step 3 (Open fstab file inside /etc directory)
Use Gedit text editor to open fstab file for editing.

sudo gedit /etc/fstab



Step 3 (Edit you fstab file to include the partition sda6 to mount on dld)
include this line (assuming the partition is NTFS)

UUID=287808DD7808AC1E /media/dld ntfs-3g defaults 0 0

Similarly for other partition you can edit fstab appropriately.

write ext3 (for ext3 partition) or reiserfs (for reiserfs partition) or xfs (for xfs partition) in place of ntfs-3g
e.g UUID=123456789 /media/mountdirectory ext3 defaults 0 0

Here in above screenshot see that I have mounted two EXT3 partition in the last two lines. It’s that simple :D


Enjoyed this post? Subscribe to Full Feeds or by Email and receive free daily updates on this Blog.

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

  1. 6 Responses to “Automount partition using UUID in Ubuntu”

  2. 1

    thank you very much!
    it was so helpful!!!

    By Laura on Mon 24th Mar, 2008

  3. 2

    Thanks alot. :D

    By Orbixx on Thu 24th Apr, 2008

  4. 3

    Thanks for the useful iformation. I changed ntfs to ntfs-3g and it worked well. :)

    By Math. on Tue 27th May, 2008

  5. 4

    I had a little ‘problem’ with this simple tutorial. If you just created the partitions the UUIDs are not yet created and mount says something like “partition does not exist”. Therefor you have to execute “sudo partprobe” first in order to generate the proper UUIDs.

    thanks for the good tutorial!

    By Florian Bruckner on Tue 10th Jun, 2008

  6. 5

    @Florian Bruckner
    thanks for your extremely helpful comment, i was not aware of it

    have a nice day

    @Math
    am glad that your problem got fixed

    @Orbixx
    thank you too

    @Laura
    at your service lady :p

    By T on Sat 14th Jun, 2008

  1. 1 Trackback(s)

  2. May 15, 2008: Automount partition using UUID in Ubuntu 7.10 (Gutsy) « A Bittersweet Life | blog

Post a Comment

March 2008
M T W T F S S
« Jan   Apr »
 12
3456789
10111213141516
17181920212223
24252627282930
31