Unable to mount SATA disk by UUID or LABEL


(Giovanni) #1

Hi, I’m trying to set it up as a NAS with a single SATA ssd (whith debian 9 or ubuntu 18.04, 4.9.119-BPI-W2-Kernel), but it seems impossible to mount the sata disk by UUID or LABEL by putting the usual line on /etc/fstab (or with systemd-mount too)

UUID="4b81920f-b3a6-4f6f-90c0-d9ce87e81270"	/mnt/ssd1	ext4	defaults,noatime,nodiratime 0 0

The system hangs forever at boot waiting for the device.

This is the output of blkid

pi@bpi-iot-ros-ai:~$ sudo blkid
/dev/mmcblk1: PTTYPE="dos"
/dev/sataa1: LABEL="DATI" UUID="4b81920f-b3a6-4f6f-90c0-d9ce87e81270" TYPE="ext4" PARTUUID="8f663f8e-01"
/dev/mmcblk0: PTUUID="9201e809" PTTYPE="dos"
/dev/mmcblk0p1: SEC_TYPE="msdos" LABEL="BPI-BOOT" UUID="D81E-6C83" TYPE="vfat" PARTUUID="9201e809-01"
/dev/mmcblk0p2: LABEL="BPI-ROOT" UUID="166d2b20-4897-4f06-8343-78638cc36091" TYPE="ext4" PARTUUID="9201e809-02"

And this is the content of /dev/disk/by-uuid/

pi@bpi-iot-ros-ai:~$ ls -la /dev/disk/by-uuid/
total 0
drwxr-xr-x 2 root root  80 Dec  1 23:55 .
drwxr-xr-x 7 root root 140 Dec  1 23:55 ..
lrwxrwxrwx 1 root root  15 Dec  1 23:55 166d2b20-4897-4f06-8343-78638cc36091 -> ../../mmcblk0p2
lrwxrwxrwx 1 root root  15 Dec  1 23:55 D81E-6C83 -> ../../mmcblk0p1

As you can see, my SATA disk is missing from /dev/disk/by-uuid/ and from /dev/disk/by-id and /dev/disk/by-label too.

As a workaround I can put /dev/sataa1 on fstab. It works, but under some cases, when I insert a USB multi card reader, the real block device changes to /dev/satab1 and the fstab mount fails.

Why does it hangs at boot? Is the missing /dev/disk/by-uuid entry blocking the boot? If yes, why there is no /dev/disk/by-uuid entry ? A bug on the sata driver?

Thank you


#2

Try the following line:

UUID=4b81920f-b3a6-4f6f-90c0-d9ce87e81270	/mnt/ssd1	ext4	defaults,noatime,nodiratime 0 0

UUID should not be quoted in fstab.


(Giovanni) #3

I tested removing quotes, but it still hangs at boot with two complete 1min 30s cicles, and after 3 minutes it drops to emergency mode (press Control-D to continue). Exactly the same behabior I had with quotes.

A start job is running for dev-disk��…9ce87e81270.device (7s / 1min 30s)[AO][_AO_if_video_HDMI_mode]HDMI not enable

I cannot use systemd-mount instead of fstab, because with .mount unit files, an entry into /dev/disk/by-uuid/ seems to be mandatory.


#4

edit -> /lib/udev/rules.d/60-persistent-storage.rules # sd* -> sata*


(Giovanni) #5

Thank you @jofri for the workaround. It worked.

I’m a bit scared for this comment line on 60-persistent-storage.rules:

# do not edit this file, it will be overwritten on update

And I also think I disabled all sd* devices as side effect.

So I created a customized version of 60-persistent-storage.rules in /etc/udev/rules.d, but it’s quite complex to publish here.


#6

Hello,

I was facing the same problem weeks ago.

There are several solutions.

1.) edit 60-persistent-storage.rules wherever /lib/udev/rules.d/ or /etc/udev/rules.d

--- 60-persistent-storage.rules 2018-10-28 18:02:10.000000000 +0100
+++ /lib/udev/rules.d/60-persistent-storage.rules       2018-11-16 20:16:32.953614969 +0100
@@ -7,7 +7,7 @@ ACTION=="remove", GOTO="persistent_stora
 ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}=="1", GOTO="persistent_storage_end"

 SUBSYSTEM!="block", GOTO="persistent_storage_end"
-KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sr*|vd*|xvd*|bcache*|cciss*|dasd*|ubd*|scm*|pmem*|nbd*", GOTO="persistent_storage_end"
+KERNEL!="loop*|mmcblk*[0-9]|msblk*[0-9]|mspblk*[0-9]|nvme*|sd*|sata*|sr*|vd*|xvd*|bcache*|cciss*|dasd*|ubd*|scm*|pmem*|nbd*", GOTO="persistent_storage_end"

 # ignore partitions that span the entire disk
 TEST=="whole_disk", GOTO="persistent_storage_end"
@@ -42,10 +42,10 @@ KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!
 KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"

 # SCSI devices
-KERNEL=="sd*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi"
+KERNEL=="sd*[!0-9]|sata*[!0-9]|sr*", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi"
 KERNEL=="cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="cciss"
-KERNEL=="sd*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
-KERNEL=="sd*|cciss*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"
+KERNEL=="sd*|sata*|sr*|cciss*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
+KERNEL=="sd*|sata*|cciss*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"

 # FireWire
 KERNEL=="sd*[!0-9]|sr*", ATTRS{ieee1394_id}=="?*", SYMLINK+="disk/by-id/ieee1394-$attr{ieee1394_id}"

2.) Change the driver ahci_rtk for normal usual naming satax-> sdx

diff --git a/linux-rt/drivers/scsi/sd.c b/linux-rt/drivers/scsi/sd.c
index e48809129..2ab928511 100644
--- a/linux-rt/drivers/scsi/sd.c
+++ b/linux-rt/drivers/scsi/sd.c
@@ -3108,6 +3108,7 @@ static int sd_probe(struct device *dev)
                goto out_put;
        }

+/*
 #ifdef CONFIG_AHCI_RTK
        if( sdp->host && sdp->host->hostt ) {
                if( strncmp(sdp->host->hostt->name, "ahci", 4 ) == 0 ) {
@@ -3119,6 +3120,7 @@ static int sd_probe(struct device *dev)
        }
        else
 #endif
+*/
        error = sd_format_disk_name("sd", index, gd->disk_name, DISK_NAME_LEN);
        if (error) {
                sdev_printk(KERN_WARNING, sdp, "SCSI disk (sd) name length exceeded.\n");

but you have to take into account that normally udisk be initialized before sata disk. But you can prevent that by compiling USB_STORAGE as a module.

CONFIG_USB_STORAGE = m

CONFIG_USB_STORAGE_REALTEK = m


#7

I have a suggestion: to mount my SATA drive, I use gnome-disks-utility, it has all the necessary options. The drawback is strictly one, you need a GUI interface, but if you have another Linux computer with a GUI, you can use “ssh -XYC” to make the configuration via SSH

I apologize in advance if I understood the situation incorrectly, as my English level is not very high, and I use an auto-translator


#8

If you add ,nofail to the options section of the line in /etc/fstab it would boot I presume, and would it then get mounted automatically later on?


(Giovanni) #9

Yes, with nofail it booted. But at runtime mount refused to mount it silently, without errors. Maybe the kerenel is remembering the boot mount failure?

In any case, the working solution to make it recognized at boot for /etc/fstab and maybe systemd-mount, is to create this file:

/etc/udev/rules.d/62-bpiw2-persistent-storage.rules

with this content

# 

ACTION=="remove", GOTO="persistent_storage_end_w2"
ENV{UDEV_DISABLE_PERSISTENT_STORAGE_RULES_FLAG}=="1", GOTO="persistent_storage_end_w2"

SUBSYSTEM!="block", GOTO="persistent_storage_end_w2"
KERNEL!="sata*", GOTO="persistent_storage_end_w2"

# ignore partitions that span the entire disk
TEST=="whole_disk", GOTO="persistent_storage_end_w2"

# for partitions import parent information
ENV{DEVTYPE}=="partition", IMPORT{parent}="ID_*"

# ATA
KERNEL=="sata*[!0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{vendor}=="ATA", IMPORT{program}="ata_id --export $devnode"

# ATAPI devices (SPC-3 or later)
KERNEL=="sata*[!0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="scsi", ATTRS{type}=="5", ATTRS{scsi_level}=="[6-9]*", IMPORT{program}="ata_id --export $devnode"

# Run ata_id on non-removable USB Mass Storage (SATA/PATA disks in enclosures)
KERNEL=="sata*[!0-9]", ENV{ID_SERIAL}!="?*", ATTR{removable}=="0", SUBSYSTEMS=="usb", IMPORT{program}="ata_id --export $devnode"

# Fall back usb_id for USB devices
KERNEL=="sata*[!0-9]", ENV{ID_SERIAL}!="?*", SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"

# SCSI devices
KERNEL=="sata*[!0-9]", ENV{ID_SERIAL}!="?*", IMPORT{program}="scsi_id --export --whitelisted -d $devnode", ENV{ID_BUS}="scsi"
KERNEL=="sata*", ENV{DEVTYPE}=="disk", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}"
KERNEL=="sata*", ENV{DEVTYPE}=="partition", ENV{ID_SERIAL}=="?*", SYMLINK+="disk/by-id/$env{ID_BUS}-$env{ID_SERIAL}-part%n"

# by-path
ENV{DEVTYPE}=="disk", DEVPATH!="*/virtual/*", IMPORT{builtin}="path_id"
KERNEL!="mmcblk[0-9]boot[0-9]", ENV{DEVTYPE}=="disk", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}"
ENV{DEVTYPE}=="partition", ENV{ID_PATH}=="?*", SYMLINK+="disk/by-path/$env{ID_PATH}-part%n"

# probe filesystem metadata of disks
KERNEL!="sr*", IMPORT{builtin}="blkid"

# by-label/by-uuid links (filesystem metadata)
ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}"
ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}"

# by-id (World Wide Name)
ENV{DEVTYPE}=="disk", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}"
ENV{DEVTYPE}=="partition", ENV{ID_WWN_WITH_EXTENSION}=="?*", SYMLINK+="disk/by-id/wwn-$env{ID_WWN_WITH_EXTENSION}-part%n"

# by-partlabel/by-partuuid links (partition metadata)
ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}"
ENV{ID_PART_ENTRY_SCHEME}=="gpt", ENV{ID_PART_ENTRY_NAME}=="?*", SYMLINK+="disk/by-partlabel/$env{ID_PART_ENTRY_NAME}"

LABEL="persistent_storage_end_w2"

Reboot and your /dev/sata* disks will be available in the standard udev link dirs (/dev/disk-by*), and you can use UUID and other similar references on /etc/fstab.

I hope the kernel driver developers will rename /dev/sata into /dev/sd as soon a s possible.


#10

That is a beast of a file…! Is it the kernel people that need to rename, or the udev people that need to add rules??


(Giovanni) #11

Yes, this is a beast of a file, but I admit that I’m not an expert of udev, and I don’t really know if it could be optimized.

Your question is legitimate: is the kernel people that need to rename or udev people that need to ad rules? I don’t know. And I’m not a kernel expert too: kernel ethernet interfaces can be renamed. Maybe a stupid smaller udev .rules file that renames sataX into sdY will do the job? Really, I don’t know ;(