Hard drives boot

I have 2 drives Western Digital 3Tb - WD30EFRX-68EUZN0 on Manjaro current.

The problem is that regularly, the drive letters swap.
/dev/sda becomes /dev/sdb and /dev/sdb becomes /dev/sda.

My system works but this is bugging me. How can I fix it so that /drive-b/ is as /dev/sdb and /boot, /, /home are on /dev/sda? Like it used to be…

Do I have a wrong setting?

Here’s my inxi

$ inxi -Fxxxz
System:    Kernel: 5.4.67-1-MANJARO x86_64 bits: 64 compiler: gcc v: 10.2.0 
           Desktop: KDE Plasma 5.19.5 tk: Qt 5.15.1 wm: kwin_x11 dm: SDDM 
           Distro: Manjaro Linux 
Machine:   Type: Desktop Mobo: MSI model: 970A-G46 (MS-7693) v: 2.0 serial: <filter> 
           BIOS: American Megatrends v: 2.8 date: 01/08/2016 
CPU:       Topology: 8-Core model: AMD FX-8350 bits: 64 type: MCP arch: Bulldozer 
           L2 cache: 2048 KiB 
           flags: avx lm nx pae sse sse2 sse3 sse4_1 sse4_2 sse4a ssse3 svm bogomips: 64028 
           Speed: 3663 MHz min/max: 1400/4000 MHz boost: enabled Core speeds (MHz): 1: 3663 
           2: 2401 3: 3295 4: 3153 5: 2405 6: 2768 7: 2339 8: 2574 
Graphics:  Device-1: AMD Ellesmere [Radeon RX 470/480/570/570X/580/580X/590] 
           vendor: Micro-Star MSI driver: amdgpu v: kernel bus ID: 01:00.0 
           chip ID: 1002:67df 
           Display: x11 server: X.Org 1.20.9 compositor: kwin_x11 driver: amdgpu 
           FAILED: ati unloaded: modesetting,radeon alternate: fbdev,vesa resolution: 
           1: 1920x1080~60Hz 2: 1920x1080 s-dpi: 96 
           OpenGL: renderer: Radeon RX 570 Series (POLARIS10 DRM 3.35.0 5.4.67-1-MANJARO 
           LLVM 10.0.1) 
           v: 4.6 Mesa 20.1.8 direct render: Yes 
Audio:     Device-1: AMD SBx00 Azalia vendor: Micro-Star MSI driver: snd_hda_intel 
           v: kernel bus ID: 00:14.2 chip ID: 1002:4383 
           Device-2: AMD Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590] 
           vendor: Micro-Star MSI driver: snd_hda_intel v: kernel bus ID: 01:00.1 
           chip ID: 1002:aaf0 
           Sound Server: ALSA v: k5.4.67-1-MANJARO 
Network:   Device-1: Realtek RTL8111/8168/8411 PCI Express Gigabit Ethernet 
           vendor: Micro-Star MSI driver: r8169 v: kernel port: d000 bus ID: 04:00.0 
           chip ID: 10ec:8168 
           IF: enp4s0 state: up speed: 1000 Mbps duplex: full mac: <filter> 
Drives:    Local Storage: total: 5.46 TiB used: 2.57 TiB (47.1%) 
           ID-1: /dev/sda vendor: Western Digital model: WD30EFRX-68EUZN0 size: 2.73 TiB 
           speed: 6.0 Gb/s rotation: 5400 rpm serial: <filter> rev: 0A82 scheme: GPT 
           ID-2: /dev/sdb vendor: Western Digital model: WD30EFRX-68EUZN0 size: 2.73 TiB 
           speed: 6.0 Gb/s rotation: 5400 rpm serial: <filter> rev: 0A82 scheme: GPT 
Partition: ID-1: / size: 826.19 GiB used: 15.67 GiB (1.9%) fs: ext4 dev: /dev/sdb2 
           ID-2: /boot size: 975.9 MiB used: 56.4 MiB (5.8%) fs: ext4 dev: /dev/sdb1 
           ID-3: /home size: 1.86 TiB used: 537.66 GiB (28.2%) fs: ext4 dev: /dev/sdb3 
Swap:      ID-1: swap-1 type: partition size: 14.65 GiB used: 0 KiB (0.0%) priority: -2 
           dev: /dev/sdb5 
Sensors:   System Temperatures: cpu: 34.2 C mobo: N/A gpu: amdgpu temp: 35 C 
           Fan Speeds (RPM): N/A gpu: amdgpu fan: 1002 
Info:      Processes: 217 Uptime: 19m Memory: 11.65 GiB used: 2.34 GiB (20.0%) 
           Init: systemd v: 246 Compilers: gcc: 10.2.0 Packages: pacman: 1440 Shell: Bash 
           v: 5.0.18 running in: konsole inxi: 3.1.05 

here’s my lsblk

$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   2.7T  0 disk 
└─sda1   8:1    0   2.7T  0 part /drive-b
sdb      8:16   0   2.7T  0 disk 
├─sdb1   8:17   0     1G  0 part /boot
├─sdb2   8:18   0 840.4G  0 part /
├─sdb3   8:19   0   1.9T  0 part /home
├─sdb4   8:20   0     8M  0 part 
└─sdb5   8:21   0  14.7G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom  

and here’s my fstab

$ cat /etc/fstab 
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a device; this may
# be used with UUID= as a more robust way to name devices that works even if
# disks are added and removed. See fstab(5).
#
# <file system>             <mount point>  <type>  <options>  <dump>  <pass>
UUID=0e97cff0-f85d-4988-b17c-71bb23006521 /boot          ext4    defaults,noatime 0 2
UUID=463767c5-0644-4b77-acc5-a49e7b8c3429 /              ext4    defaults,noatime 0 1
UUID=9a80c605-d075-48c3-bd5a-cda588c782d4 /home          ext4    defaults,noatime 0 2
UUID=c9a7ada7-bbd5-46d0-bd56-52440973b6e0 none           swap    defaults,noatime 0 0

UUID=48946de2-efca-4e0c-abcc-fcd8b565273b /drive-b       ext4    defaults,noatime 0 2

Hello :wave:

I don’t know what you mean with “swapping”, but Linux reads the EFI/BIOS and when the EFI/BIOS says that the first hard drive is on SATA port 1, then it will be /dev/sda, SATA Port 2, then it will be /dev/sdb, and so on.

Easy fix would be then plugging the Manjaro HDD to SATA Port 1.

I don’t think that’s what he means. He means on consecutive reboots, the system see physical drives with different /dev/sdXX
I have seen that too on a friend system (made sure I installed Manjaro on the drive at /dev/sda but then after reboots and/or adding other drives it changed everything). Never found the ‘reason’ (actually there are but whatever) or a ‘fix’.

But in the first post I see, what I was going to suggest, that you are using the UUID instead of /dev/sdXX so that doesn’t even matter. Maybe you didn’t explain fully the issue here? What is the issue exactly? Is it that the /dev/sdXX change randomly (but without any other issue)?

Where the system sees the drives is not really a problem or important.

So again, can you elaborate more on the actual issue you’re having?

This can be done with a udev rule. For example /etc/udev/rules.d/50-local-persistent-disks.rules:

SUBSYSTEM=="block", ATTRS{model}=="Yoyodine HD9001", \
  ATTRS{serial}=="123-456-789", \
  NAME="sda"

You can run udevadm info -a /dev/sda to view the available ATTRS{***} values for a certain device.

To put it simply … thats how it works.
Thats why in examples like /etc/fstab you should always use UUID instead of partition name/descriptors.

https://wiki.archlinux.org/index.php/Fstab#Identifying_filesystems

Warning: Kernel name descriptors are not persistent and can change each boot, they should not be used in configuration files.

If you need to force tame it for some reason or for some extra info… see this:

https://wiki.archlinux.org/index.php/Persistent_block_device_naming

1 Like

Yes, exactly

Like I said, I use UUID and it works, but that bugs me

It’s just bugging me. I don’t like when things change without any reason (there’s always one but I don’t know what it is)

Thanks

OK then I can’t help more. I think the ‘issue’ is how the motherboard initialize hardware or something like that, happening during the boot process and if my instinct is right, then not really anything we can do about it.

//EDIT: and a quick google reminds me of all these threads about the topic linux /dev/sd changing after reboot - بحث Google‏ there are plenty

What is the purpose of needing them to be the same? If you mount one drive as home and another drive as a folder somewhere then you should be able to do whatever you want using the folder.

Whatever drive is home should already be mounted based on UUID in fstab but any other drive you can mount in fstab with the UUID to a specific folder.

For instance I have an SSD that is mounted as Home and I have 4 HDD’s mounted as folders under /mnt such as /mnt/storage /mnt/backup etc.

If you want to do it that way go into the directory you want to create the folder then type sudo mkdir foldername
then give it ownership to your user with sudo chown yourusername:yourusername foldername
there are a couple ways to do the next step either edit the fstab file manually with say nano
or use a program like gnome disks to do it for you.
If your DE comes with the program in accessories Disks enter that program find the drive you want to mount. Click on the drive, click on the gear icon and go into Edit Mount options. tick on mount at startup.
If you want to still be able to see it as a device tick on show in user interface
Find line Mount Point and change it to the folder you created.

From then on your HDD will be mounted as a folder whenever you startup your computer. You can then use that folder name for any scripts or links you want to create.

For instance on my storage drive I keep my pictures, videos, music and documents folders but use sym links to the home folder.

Or is there some other reason you need it to be constant?

As he said it bothers him, their is no issue.

//EDIT: weird I didn’t see replies #4 and #5 when I previously replied, didn’t have their notification either.
This would be your solution @elfroggio if you didn’t see it either:

I think the reason is that the devices are named in the order they are being detected. And that depends on the time the HD needs to spin up and respond “ready”. sda is the first drive responding “ready”, sdb is the second drive and so forth.

The time it takes a drive to respond “ready” is not 100 % reproducible. It can vary by milliseconds. That is just natural. Therefore some times the order of drives can change.

But that is not a problem. Nobody needs drive names like sda, sdb, etc. All drives have a unique identifier and this UUID is supported by all relevant Linux tools who deal with drives.

1 Like