You are not logged in.

#1 2011-10-06 14:47:06

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

[solved] Persistent storage device naming (ata & sata disk)

Once and for all I want to deal with this annoyance! I have one ata ("Maxtor 6Y120L0  " as seen by udev) and one sata ("WDC WD800JD-75JN") disk. What I want is to make sata disk sda and ata disk to be sdb. Please, give any info on how I can do it. Here's what I've tried so far:


I put file 02-disk.rules in /etc/udev/rules.d/:

SUBSYSTEM=="block", ATTRS{model}=="WDC WD800JD-75JN", KERNEL=="sda", SYMLINK+="sda%n"
SUBSYSTEM=="block", ATTRS{model}=="Maxtor 6Y120L0  ", KERNEL=="sdb", SYMLINK+="sdb%n"

Then I figured, this should go in initcpio, so I put the file in /lib/initcpio/udev. But still the same: disk order changes every boot!

Is there any possible way for the disks to retain their order?

coyotehelp.th.jpg


Edit: Solution here.

Last edited by Demon (2011-10-06 19:48:24)

Offline

#2 2011-10-06 17:22:36

zenlord
Member
From: Belgium
Registered: 2006-05-24
Posts: 1,221
Website

Re: [solved] Persistent storage device naming (ata & sata disk)

IMHO you did the right thing with those udev-rules. Be sure that you've used the right 'ATTRS{}', though.

The Arch wiki has this on the topic:
https://wiki.archlinux.org/index.php/Ud … _Each_Boot

It mentions that you could change the order of loading of your modules to influence the order of your devices.

/EDIT: 1000 posts - this one better be good smile

Last edited by zenlord (2011-10-06 17:23:17)

Offline

#3 2011-10-06 17:29:42

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: [solved] Persistent storage device naming (ata & sata disk)

zenlord wrote:

/EDIT: 1000 posts - this one better be good smile

Congratulations! big_smile And thanks for advice, I'll repost results. smile

Edit: This is valid only for devices that are not disks. Because, when udev starts to autoload, partitions are already mounted. So it's gotta be something related to initramfs.

Edit2: I think I have a solution!
https://wiki.archlinux.org/index.php/Mk … figuration

Just need to figure out which modules to put in configuration...

Last edited by Demon (2011-10-06 17:37:58)

Offline

#4 2011-10-06 19:37:46

.:B:.
Forum Fellow
Registered: 2006-11-26
Posts: 5,819
Website

Re: [solved] Persistent storage device naming (ata & sata disk)

You could also use UUIDs, those are persistent, no need to write extra udev rules for that.

I know, it's a bit late, but just so you know for the future. Who knows.


Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy

Offline

#5 2011-10-06 19:42:44

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: [solved] Persistent storage device naming (ata & sata disk)

Solution is, indeed, to put modules to preload in mkinitcpio.conf (in MODULES array):


First, check which disk is using which module by issuing following command(s):

udevadm info -a -p $(udevadm info -q path -n /dev/sda)
udevadm info -a -p $(udevadm info -q path -n /dev/sdb)

The output for the first command on my system is:

  looking at device '/devices/pci0000:00/0000:00:0a.0/host0/target0:0:0/0:0:0:0/block/sda':
    KERNEL=="sda"
    SUBSYSTEM=="block"
    DRIVER==""
    ATTR{range}=="16"
    ATTR{ext_range}=="256"
    ATTR{removable}=="0"
    ATTR{ro}=="0"
    ATTR{size}=="156250000"
    ATTR{alignment_offset}=="0"
    ATTR{discard_alignment}=="0"
    ATTR{capability}=="50"
    ATTR{stat}=="   11117    19401   624962   108730     1538     2156    59579   108713        0    60535   217410"
    ATTR{inflight}=="       0        0"
    ATTR{events}==""
    ATTR{events_async}==""
    ATTR{events_poll_msecs}=="-1"

  looking at parent device '/devices/pci0000:00/0000:00:0a.0/host0/target0:0:0/0:0:0:0':
    KERNELS=="0:0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS=="sd"
    ATTRS{device_blocked}=="0"
    ATTRS{type}=="0"
    ATTRS{scsi_level}=="6"
    ATTRS{vendor}=="ATA     "
    ATTRS{model}=="WDC WD800JD-75JN"
    ATTRS{rev}=="06.0"
    ATTRS{state}=="running"
    ATTRS{timeout}=="30"
    ATTRS{iocounterbits}=="32"
    ATTRS{iorequest_cnt}=="0x32a4"
    ATTRS{iodone_cnt}=="0x32a4"
    ATTRS{ioerr_cnt}=="0x31"
    ATTRS{evt_media_change}=="0"
    ATTRS{queue_depth}=="1"
    ATTRS{queue_ramp_up_period}=="120000"
    ATTRS{queue_type}=="none"

  looking at parent device '/devices/pci0000:00/0000:00:0a.0/host0/target0:0:0':
    KERNELS=="target0:0:0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:0a.0/host0':
    KERNELS=="host0"
    SUBSYSTEMS=="scsi"
    DRIVERS==""

  looking at parent device '/devices/pci0000:00/0000:00:0a.0':
    KERNELS=="0000:00:0a.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ahci"
    ATTRS{vendor}=="0x10de"
    ATTRS{device}=="0x044d"
    ATTRS{subsystem_vendor}=="0x1043"
    ATTRS{subsystem_device}=="0x8249"
    ATTRS{class}=="0x010601"
    ATTRS{irq}=="23"
    ATTRS{local_cpus}=="ffffffff,ffffffff"
    ATTRS{local_cpulist}=="0-63"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

If you take a closer look to this part:

looking at parent device '/devices/pci0000:00/0000:00:0a.0':
    KERNELS=="0000:00:0a.0"
    SUBSYSTEMS=="pci"
    DRIVERS=="ahci"
    ATTRS{vendor}=="0x10de"
    ATTRS{device}=="0x044d"
    ATTRS{subsystem_vendor}=="0x1043"
    ATTRS{subsystem_device}=="0x8249"
    ATTRS{class}=="0x010601"
    ATTRS{irq}=="23"
    ATTRS{local_cpus}=="ffffffff,ffffffff"
    ATTRS{local_cpulist}=="0-63"
    ATTRS{dma_mask_bits}=="64"
    ATTRS{consistent_dma_mask_bits}=="64"
    ATTRS{broken_parity_status}=="0"
    ATTRS{msi_bus}==""

You'll see the module to load is ahci. Examining the relative part of the output of the second command reveals that I need module pata_amd.
Next step is quite simple: put ahci and pata_amd to MODULES array in /etc/mkinitcpio.conf, in order you wish the two disks to load.

My example:

MODULES="ahci pata_amd"

meaning that SATA disk will be sda and the ATA disk will be sdb.

Then rebuild the initramfs and enjoy.

Last edited by Demon (2011-10-06 19:48:46)

Offline

#6 2011-10-06 19:45:52

Demon
Member
From: Republic of Srpska, BA
Registered: 2008-03-02
Posts: 246

Re: [solved] Persistent storage device naming (ata & sata disk)

.:B:. wrote:

You could also use UUIDs, those are persistent, no need to write extra udev rules for that.

Thanks for input, but this wouldn't help, because the issue is that I need a specific disk to be classified as sda after every boot. For this you need to load modules in order you want your disk(s) to initialize, meaning this has to be done in initramfs.

Last edited by Demon (2011-10-06 19:53:43)

Offline

Board footer

Powered by FluxBB