LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Manually assign a device name to a specific HDD (http://www.linuxquestions.org/questions/slackware-14/manually-assign-a-device-name-to-a-specific-hdd-4175425877/)

Barx 09-06-2012 02:00 AM

Manually assign a device name to a specific HDD
 
Hi all

I have a PC that I use to clone HDDs, recover and copy data, ecc ecc.

The PC has slackware installed onto an IDE drive. Normally I work on SATA drives so I'm happy to have the OS on the IDE hdd so I have all SATA ports free.

But I have a problem: the IDE drive always gets the last letter after all the sata disks. If it's the only one it becomes sda, with 1 sata disk becomes sdb, with 2 sata disks sdc and so on.

Of course I get a kernel panic on every boot until I pass 'mount root=/dev/sdx' option each time to lilo with the actual IDE drive name

So I would like to stick manually a name to the disk so it will always be /dev/sda (or /dev/sdz or /dev/drivewithacustomname ) so I don't have more troubles on every boot.

I always tried to play with /dev/root (telling lilo to boot from /dev/root ) in various attempts, but without any result (I think that beacuse /dev/root is a symlink and lilo uses the link target, that will change moving drives)

Any hint??

Thank you all

Bye

Alessandro

bormant 09-06-2012 03:26 AM

You can try to assign label to your Slackware root partition, for ex. swroot
Code:

e2label /dev/sda1 swroot
, and then pass it instead of device name to kernel as
Code:

root=LABEL=swroot
in LILO prompt or as
Code:

root = "LABEL=swroot"
in /etc/lilo.conf. Note, that any changes in lilo.conf require to run lilo.

Does it help?

Barx 09-06-2012 04:16 AM

Great idea!

I'm trying. I've labeled the root partition and the swap partition

Then I've edited lilo.conf and fstab telling them to use labeled partitions.

But I can't boot the system. I also tried to pass the option to lilo (Linux mount root=label=slackware), no way.

But if I pass mount root=/dev/sda2 the system boots correctly, and mounts root and swap partitions, so the labeling and syntax used in fstab both works.

But I can't tell to lilo to use labels ... now I do some other tests..

diwljina 09-06-2012 04:40 AM

You can use UUIDs. They are unique to every partition.

Code:

ls -l /dev/disk/by-uuid
will give you UUIDs of your disks.

Then, you can use them in fstab and lilo.conf.

fstab:
Code:

UUID={YOUR-UID}    {/path/to/mount/point}              {file-system-type}    defaults 0      1
But, it seems that you have to have initrd for this to work.

This should be helpful:
http://nil-techno.blogspot.com/2012/...s-by-uuid.html

Didier Spaier 09-06-2012 05:39 AM

I add to what diwljina wrote that the "blkid" command will give you the file types in addition.

And using an initd is not mandatory.

Barx 09-06-2012 06:10 AM

No way

Always get kernel panic

I'm not using an initrd

But I can see a strange behaviour: on the kernel panic screen, I can see the list of all drives and partitions, each one has an hex code with a structure similar to an UUID, but this codes are DIFFERENT from the ones seen by blkid, and for the IDE disk these codes are 00000000-0000-0000-0000-00000000000 for both partitions ..

I don't know if this may help..

Thank you for yout effort, I'll go trying other options...

turtleli 09-06-2012 06:46 AM

This page from the ArchLinux wiki might be what you are looking for: https://wiki.archlinux.org/index.php..._device_naming

Didier Spaier 09-06-2012 07:37 AM

You may just need to allow a delay before your SATA disk become available.

In the relevant stanza of lilo.conf add:
Code:

append = "rootdelay=30"
Of course adapt as needed, 30 means 30 seconds.

bormant 09-06-2012 10:38 AM

Quote:

Originally Posted by Barx (Post 4773945)
Linux mount root=label=slackware

Please, try this literally at LILO prompt:
Code:

Linux root="LABEL=slackware"
Does it help?

ps.
/usr/src/linux/Documentation/kernel-parameters.txt says to see about kernel root= parameter name_to_dev_t comment in init/do_mounts.c.
This comment says nothing about "LABEL=", so it is initrd sripts magic. It also says that PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF accepted by kernel itself but if partition table provides it.

Barx 09-07-2012 12:01 PM

Thank you all fro your efforts.

Sorry but today I was out of office and I had no time to test, I'll restart testing this monday

I'll try to deal with rootdelay, but I don't think this will fix because using the device name like /dev/sde1

here you can find the relevant parts of my testbed, just to view if something is wrong

partition labels and UUIDs:

Code:

root@server:~# blkid
/dev/sde1: UUID="c347c1e4-e49f-4b7b-914d-b8f681c03428" TYPE="swap" LABEL="slackswap"
/dev/sde2: LABEL="slackware" UUID="8563d7da-09d8-4956-a6a4-77e2e3eb341e" TYPE="ext4"

fstab (perfectly working):

Code:

LABEL=slackswap        swap            swap        defaults        0  0
LABEL=slackware        /                ext4        defaults        1  1

lilo.conf

Code:

image = /boot/vmlinuz
 # root="LABEL=slackware"
 # append = "root=UUID=8563d7da-09d8-4956-a6a4-77e2e3eb341e"
 # append = "root=LABEL=slackware"
 label = Linux_test
 read-only

I tried the three commented line (only one for time) without results

Monday I will do further tests

Thank you all

Alessandro Barisone

gezley 09-07-2012 03:28 PM

Quote:

Originally Posted by Barx (Post 4775133)
here you can find the relevant parts of my testbed, just to view if something is wrong

partition labels and UUIDs:

Code:

root@server:~# blkid
/dev/sde1: UUID="c347c1e4-e49f-4b7b-914d-b8f681c03428" TYPE="swap" LABEL="slackswap"
/dev/sde2: LABEL="slackware" UUID="8563d7da-09d8-4956-a6a4-77e2e3eb341e" TYPE="ext4"

fstab (perfectly working):

Code:

LABEL=slackswap        swap            swap        defaults        0  0
LABEL=slackware        /                ext4        defaults        1  1


This is how your fstab should look with UUIDs:

Code:

UUID=c347c1e4-e49f-4b7b-914d-b8f681c03428  swap  swap  defaults  0 0
UUID=8563d7da-09d8-4956-a6a4-77e2e3eb341e  /    ext4  defaults  1 1

When you specified UUIDs in your fstab did you perhaps neglect to remove the quotation marks around them?

turtleli 09-07-2012 04:32 PM

Seems you do need an initrd if you use the UUID or LABEL method. See http://www.linuxquestions.org/questi...uid%3D-929098/ for someone who had a similar problem.

Barx 10-29-2012 03:43 AM

OK it works!

initrd is required to do the trick. I think that the label (or UUID) is seen only if the module for the root file system is loaded via initrd.

I've used a 'simple' initrd containing only ext3 module (the one used for root file system in my testbed) created with

Code:

mkinitrd -c -k 3.2.29 -m ext3 -f ext3 -r /dev/sda1
then added this line

Code:

append = "root=LABEL=slackware"
(put in the correct lilo entry, not in common section)

and now system boots perfectly!

Thank you all for your help!


All times are GMT -5. The time now is 09:34 AM.