Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I've a Linux Centos (5.0) machine with 2 disks. I was changing the SATA cable to one of the disk when I realized that depending on what SATA slot I'm using, the OS starts from sda or sdb.

The problem is that I have daily backups from sda to sdb (merely copies), if by accident someone change the SATA cable, I will screw up and overwrite new data with old data.

The only thing that I know is, that current boot disk is the good one. How I can certainly know which disk is the current boot disk (sda or sdb)?

Additional info: I've no physical access to the machine.

share|improve this question
The solution would be to stop using "sda" and "sdb" and start using disk UUIDs... – grawity Aug 28 '12 at 16:56
grawity is absolutely right, once you solve this you should switch to using UUIDs instead, which prevents this sort of problem. – ChimneyImp Aug 28 '12 at 17:14
Like grawity said. Those names sda and sdb are dependent on the order they are found at boot time. Usually the lower numbered port is sda. So they will change if you swap the cables. sda will then be called sdb, and vice versa. So you can't go by that name to identify them. They need a unique name... – Keith Aug 28 '12 at 17:43
BTW, since you have two disks you might want to just make them RAID 1, and let the OS do the sync/copy operation for you. Then you won't have to deal with it. – Keith Aug 28 '12 at 18:50
About the RAID1, yes it would be the best option but I had too much troubles to set it and gave up. – LoThaR Aug 29 '12 at 1:56

4 Answers 4

I too would suggest using UUID's, but short of that, if you are not using LVM or RAID or something else which obscures the underlying block device using "df" will expose which drive is mounted. (Even if you are using LVM or RAID you will probably have a /boot partition which can tell you this).

Alternatively "hdparm -a /dev/sdX" will tell you the model AND SERIAL number of the drive, so you could run this command and grep to work out which hard drive is which.

share|improve this answer

First, use disk UUIDs like @grawity said.

If you want to know the UUIDs of everything that looks like a block device to Linux, use the blkid command. I think you can do something like blkid /dev/sda to find out the UUID of sda as well.

Another thing you can do is use the symlinks in /dev/disk/by-id which are created for each disk based on the bus it's connected to and its reported model and serial number.

Technically, Linux doesn't know or care about the device it was loaded from, because

  • that's the bootloader's job - which runs before the kernel is running - to load the kernel into memory.
  • anything that's not in the kernel needed at boot is in the initramfs (initrd), such as drivers, early userland utilities - loading this is also the bootloader's job.

Now, after Linux loads, boot scripts or whatever other mechanism running under the kernel tries to mount a root file system so you have other things to run besides the kernel, as well as swap, etc. Basically all the stuff in your /etc/fstab. This is what you really care about and that file will have the information you need. You can use UUIDs in /etc/fstab (and I believe most distributions already use them) - so with a couple grep's and cut's you can get UUIDs out of here that you want.

Example (this probably can be done better): cat /etc/fstab | grep "/ " | cut -f 1 -d " "

And you can use the output of that for blkid to find the UUID of your root file system or whatever other partition.

share|improve this answer
Also, instead of/in addition to UUIDs you could also use labels. They're more human-readable, after all. – Daniel B Jun 23 at 20:51
awk '$2 == "/"' /proc/self/mounts
share|improve this answer
ese comando me devuelve: rootfs / rootfs rw 0 0 /dev/root / ext3 rw,data=ordered 0 0. ... – LoThaR Aug 28 '12 at 17:01

sudo fdisk -l gets it done, and it works even if you're connected remotely. The boot partition will have an asterisk next to it.

share|improve this answer
The problem is the second disk is an image of the first, so both has the boot asterisk... and I still don't know which is the boot disk. – LoThaR Aug 28 '12 at 16:40
Ohh. I didn't know you could even do that. – ChimneyImp Aug 28 '12 at 17:13

Your Answer


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

Not the answer you're looking for? Browse other questions tagged or ask your own question.