Mounting disks by UUID PDF Print E-mail
Saturday, 04 July 2009 00:24

Getting disks to mount on the same mount points every time not a concern with IDE disks, but once you start using USB disks you run the risk of them being enumerated in a different order...................which means a disk that was /dev/sdb1 this time round could be /dev/sdd1 next time.  If you want the disks to always use the same mount point the simplest way is to mount them by UUID.  All my disks are formatted ext3, and I have no idea if it works with other filesystems......but then filesystems not designed by wife-killers probably have less bugs anyway.

 

 

Firstly to work out what the UUID of your disk is in the first place look at /dev/disk/by-uuid:

     cianer@Detritus:/dev/disk/by-uuid$ ls -la
    total 0
    drwxr-xr-x 2 root root 120 2009-07-04 01:16 .
    drwxr-xr-x 6 root root 120 2009-07-04 01:16 ..
    lrwxrwxrwx 1 root root  10 2009-07-04 01:16 12f82c6b-d11f-4635-9bdb-bab557919879 -> ../../sdc1
    lrwxrwxrwx 1 root root  10 2009-07-04 01:16 56566b53-cce6-470c-8676-ce0f1bb1af76 -> ../../sda1
    lrwxrwxrwx 1 root root  10 2009-07-04 01:16 7aed29cf-a525-43f1-9d63-65591154a6b1 -> ../../sda5
    lrwxrwxrwx 1 root root  10 2009-07-04 01:16 dc5040bd-0b0d-4edf-9bec-cea6b73a8774 -> ../../sdb1
    cianer@Detritus:/dev/disk/by-uuid$

 

This tells you the UUID of the disks and which device they currently are.  Mount them in turn & see what content is on them so you know which disk is which.  Next, simply edit your /etc/fstab to use the UUID, thus:

     cianer@Detritus:~$ more /etc/fstab 
    # /etc/fstab: static file system information.
    #
    # <file system> <mount point>   <type>  <options>       <dump>  <pass>
    proc            /proc           proc    defaults        0       0
    # OS disk - no data
    UUID=56566b53-cce6-470c-8676-ce0f1bb1af76 /               ext3    relatime,errors=remount-ro 0       1
    # Swap
    UUID=7aed29cf-a525-43f1-9d63-65591154a6b1 none            swap    sw              0       0
    # Primary storage drive
    UUID=b4bf964e-cfa6-43a3-9409-723302de2cca /media/shared   auto    defaults,users,auto         0       1
    # Secondary storage drive
    UUID=dc5040bd-0b0d-4edf-9bec-cea6b73a8774 /media/videos   auto    defaults,users,auto  0       1
    # External 1TB USB backup disk
    UUID=12f82c6b-d11f-4635-9bdb-bab557919879 /media/backup_disk  auto   defaults,users,auto    0    1
    /dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0
    /dev/fd0        /media/floppy0  auto    rw,user,noauto,exec,utf8 0       0

    cianer@Detritus:~$

 

Ta daa!  Now you don't have to worry about the USB enumeration screwing up your disk order and having your nightly backups trash your data by backing up to the wrong place.

 
Joomla Templates by Joomlashack