Add new hard drives (HDD) to Debian server , and boot in correct order :)

Sometimes debian can be messy after installing a new hardware, especially if you want to install new hard drives.
Here is the case
I have installed debian on the first partition of the first hard drive (sda1)
after the installation I added a PCI JBOD card with 2 hard drives…
and debian won’t boot.
Why?
Here is the answer!
New hard drives appears in the system as sda and sdb, and our old installation is now on sdc (it was on sda) so the boot loader can’t find the root partition .

The easiest way is to edit boot menu and to point it to the new device letter (from sda1 to sdc1)

But what if some of the hard drives might appear or disappear (sata disks are hot swapable- right!? ) How to solve this problem dynamically?
The answer is very simple.
On linux ( Debian in my case ) we have not only drive letters for the devices. We have there names, ids, paths etc.

You might take a look at /dev/disk/ directory and you will find
by-id/ by-label/ by-path/ by-uuid/
subdirectories.

look at /dev/disk/by-id/
you will find some long names (as listed here):

scsi-SATA_WDC_WD10EADS-00_WD-WMAV50148278
scsi-SATA_WDC_WD10EADS-00_WD-WMAV50148278-part1
scsi-SATA_WDC_WD10EADS-00_WD-WMAV50148278-part2

scsi-SATA_WDC_WD10EADS-00_WD-WMAV50148279
scsi-SATA_WDC_WD10EADS-00_WD-WMAV50148279-part1
scsi-SATA_WDC_WD10EADS-00_WD-WMAV50148279-part2


These are just examples (yours will probably not look the same)
that represents Disk ID's (they are unique for each drive)
followed by a partition number:

DISKNAME-PART1

with cfdisk you can find your root device and root partition
after the change in your boot loader
/dev/sda1 (or whatever the old device name is)
with
/dev/disk/by-id/scsi-SATA_WDC_WD10EADS-00_WD-WMAV50148279-part1 (or whatever your device id is)

commit changes and reboot,
now your system will boot in the correct root each time, without getting messy with new disks.

(special 10x to to Tomi Toshevski for helping me with the translation )

Comments

Popular posts from this blog

Using Debian on linksys NAS-200

Малко за мъката по светът.