LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Blogs > gegechris99
User Name
Password

Notices


Rate this Entry

Slackware 14.1 - Use persistent disk names in lilo and fstab before adding a second hard disk

Posted 11-07-2015 at 05:31 PM by gegechris99
Updated 11-08-2015 at 06:16 AM by gegechris99
Tags lilo

I recently added to a laptop a second SATA Hitachi hard disk (HDD) using a HDD caddy that replaced the CD/DVD drive. This second HDD was from an old laptop whose motherboard died and had a Windows Vista partition and a linux partition.

The first HDD (Toshiba) in the laptop was partitioned as follows:
/dev/sda1 for the swap
/dev/sda2 for the root directory of Slackware 14.1 64bit with ext4 filesystem

After adding the second HDD, the boot process failed because the first HDD was recognized as device /dev/sdb instead of /dev/sda. I couldn't find a way to reassign device /dev/sda to the first HDD. To solve that issue, I used persistent disk names for the device and partitions of the first HDD. More precisely, I used persistent disk Ids.

Persistent disk Ids are symlinks that are located in directory /dev/disk/by-id/. With one HDD (Toshiba), it showed:
Code:
ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT -> ../../sda
ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part1 -> ../../sda1
ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part2 -> ../../sda2
wwn-0x50000395f1e0380e -> ../../sda
wwn-0x50000395f1e0380e-part1 -> ../../sda1
wwn-0x50000395f1e0380e-part2 -> ../../sda2
The Toshiba HDD Ids linked to /dev/sda

Using permanent disk Id for the boot process

Basically I replaced /dev/sda and /dev/sda* by their permanent disk Id in the configuration files used in the boot process: /etc/lilo.conf and /etc/fstab.

I removed the second HDD and booted again my system to make the changes.

As I use the generic kernel, I first had to recreate the initrd file.
Code:
mkinitrd -c -k 3.10.17 -m ext4 -f ext4 -r /dev/disk/by-id/ata-ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part2 -o /boot/initrd.gz
The important change, here, is the -r option.

I then edited /etc/lilo.conf:
Code:
[...]
#boot = /dev/sda
boot = /dev/disk/by-id/ata-ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT
[...]
# Linux bootable partition config begins
image = /boot/vmlinuz-generic-3.10.17
# root = /dev/sda2
  root = /dev/disk/by-id/ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part2
  initrd = /boot/initrd.gz
  label = Slackware
  read-only
# Linux bootable partition config ends
and ran lilo to apply the changes.

Finally, I changed /etc/fstab:
Code:
/dev/disk/by-id/ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part1        swap             swap        defaults         0   0
/dev/disk/by-id/ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part2        /                ext4        defaults         1   1
[...]
I put back the second HDD and the boot process with two HDDs completed successfully.

Directory /dev/disk/by-id now shows:
Code:
ata-Hitachi_HTS541612J9SA00_SB3D04EWGDP29E -> ../../sda
ata-Hitachi_HTS541612J9SA00_SB3D04EWGDP29E-part1 -> ../../sda1
ata-Hitachi_HTS541612J9SA00_SB3D04EWGDP29E-part2 -> ../../sda2
ata-Hitachi_HTS541612J9SA00_SB3D04EWGDP29E-part3 -> ../../sda3
ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT -> ../../sdb
ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part1 -> ../../sdb1
ata-TOSHIBA_MQ01ABF050_Z4ATT4FPT-part2 -> ../../sdb2
wwn-0x50000395f1e0380e -> ../../sdb
wwn-0x50000395f1e0380e-part1 -> ../../sdb1
wwn-0x50000395f1e0380e-part2 -> ../../sdb2
wwn-0x5000cca54dc5c390 -> ../../sda
wwn-0x5000cca54dc5c390-part1 -> ../../sda1
wwn-0x5000cca54dc5c390-part2 -> ../../sda2
wwn-0x5000cca54dc5c390-part3 -> ../../sda3
The Toshiba HDD Ids now link to /dev/sdb
Posted in Uncategorized
Views 2814 Comments 0
« Prev     Main     Next »
Total Comments 0

Comments

 

  



All times are GMT -5. The time now is 02:37 PM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration