Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I've set up fstab to auto mount media drives on a Linux Mint machine.
The OS is installed on a IDE/ATA Disk while 3 SATA disks hold data to share.
The BIOS has the ATA disk as first boot device.
All SATA drives are NTFS non bootable with a single partition.

When I installed the OS:
The ATA disk was seen as sda and the other drives as sdb, sdc and sdd. The problem is that every so often when I reboot, the drives are changing: sda becomes sdd, sdb becomes sda, etc... It doesn't seem to affect the OS, but obviously my fstab config sends errors.

All the drives seem fine, and none of them is ever missing.

So, question: can I force to map the drives with fixed path? I tried using Labels but it didn't seem to work.

Also, I don't know if it is abnormal and/or relevant but my ATA drive has four partitions:
- sda1 => OS
- sda2 => Empty EX4 partition, maybe concurrent OS in the future
- sda4 => Extended partition
- sda5 => Swap
- sdb4 => SATA HDD 1
- sdc1 => SATA HDD 2
- sdd1 => SATA HDD 3

Isn't there something weird? I'd have thought I would get sda1 to 4, then sdb1, sdc1, and sdd1.

Thanks for your help!

share|improve this question

migrated from serverfault.com Nov 11 '11 at 16:29

This question came from our site for professional system and network administrators.

2 Answers 2

So, question: can I force to map the drives with fixed path? I tried using Labels but it didn't seem to work.

Use UUID:

$ ls -lF /dev/disk/by-uuid/
total 0
lrwxrwxrwx 1 root root 10 Sep 15 15:35 61965e0c-8aba-4207-9424-1350aa6e051e -> ../../sda2
lrwxrwxrwx 1 root root 10 Sep 15 15:35 e002a7bc-02da-47a8-ab98-1225e6ace6d5 -> ../../sda1
lrwxrwxrwx 1 root root 10 Sep 15 15:35 e23cc6c4-0e57-4cbd-8036-91ea9974bab0 -> ../../sda5

# blkid
/dev/sda5: LABEL="/data" UUID="e23cc6c4-0e57-4cbd-8036-91ea9974bab0" TYPE="ext3" 
/dev/sda3: LABEL="SWAP-sda3" TYPE="swap" 
/dev/sda2: LABEL="/" UUID="61965e0c-8aba-4207-9424-1350aa6e051e" TYPE="ext3" 
/dev/sda1: LABEL="/boot" UUID="e002a7bc-02da-47a8-ab98-1225e6ace6d5" TYPE="ext3" 

and change your /etc/fstab to use persistent name:

UUID=e23cc6c4-0e57-4cbd-8036-91ea9974bab0    /data    ext3    defaults    1 2
...
share|improve this answer

The disk names (sda, sdb, sdc, …) are assigned in the order in which the drivers are initialized. That can be pretty random (it depends in which order the devices are loaded, and sometimes which drive responds to a query a microsecond earlier than the other on some system bus).

The partition numbers (sda1 vs sda2 vs …) are fixed; they won't change until you repartition the disk. Partition numbers aren't assigned sequentially; read on PC partitioning (follow the “further information” links) and perhaps this answer and this thread.

The reliable way to access particular disks is through LVM, labels or UUIDs.

  • UUIDs are assigned when you create the filesystem; quanta's answer shows how to see a disk's UUID and use it in /etc/fstab.
  • If you prefer to use meaningful labels, run tune2fs -L ubuntu /dev/sda1 and so on to give each partition with a filesystem a unique label, and mkswap -L swap1 /dev/sda5 (don't do that while the swap area is in use). Then use a line like this in /etc/fstab:

    LABEL="ubuntu" / ext4 errors=remount-ro,acl 0 1
    
  • LVM logical volume names is what I prefer to use, but your system doesn't use LVM. Think of it for your next build.

share|improve this answer
    
For your NTFS drives, you may also want to use ntfslabel from ntfsprogs package (instead of booting into Windows or gparted on Linux to change the label). It now gets shipped on quite a couple major distros. –  syntaxerror Oct 20 '13 at 23:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.