Problem Removing External Hard Drive

I recently acquired a SanDisk ArmorATD external hard drive. It comes formatted for Apple, but the manufacturer says it is ‘Windows’ compatible by reformatting. I reformatted it to GPT with btrfs filesystem. I created only one partition.

When I plug in the drive (USB-C jack on laptop), this is what I see in /dev:

brw-rw----. 1 root disk 8, 0 Oct 5 14:11 sda
brw-rw----. 1 root disk 8, 1 Oct 5 14:11 sda1
crw-rw----. 1 root disk 21, 0 Oct 5 14:10 sg0
crw-------. 1 root root 21, 1 Oct 5 14:10 sg1

I can mount the partition using the Plasma widget that immediately appears in the system tray with a prompt to mount. However, when I try to ‘safely remove’ the drive using the Plasma widget, it hangs for a time, then finally indicates that the external drive is removed… BUT the drive busy/activity lamp (or whatever it is) is now endlessly flashing. The widget indicates that the drive is removed. At this point I can apparently pull the cable. If I want to remount the drive, I MUST pull the cable and reinsert it, otherwise the widget will not recognize the presence of the drive.

Conversely, when I umount the drive manually (it will not work unless I use sudo!):

sudo umount /run/media/peter/archive

Now, the drive light does not flash endlessly, but is simply on steadily, which appears to be the normal state when the drive is plugged in. AND, the widget recognizes that the drive is still plugged in and I can remount it again using the widget, if I want to.

The other thing that is odd about this drive is the presence in /dev:

crw-------. 1 root root 21, 1 Oct 5 14:29 sg1

I have another external drive, a Western Digital Red desktop drive that I mounted into an external case, GPT label and a single btrfs partition, exactly the same as the SanDisk ArmorATD. When I plug that drive in, I get only /dev/sg0 (root:disk) but no /dev/sg1 (root:root).

Furthermore, I also have a Samsung SSD drive, unfortunately of necessity formatted with exFat (otherwise my androd phone cannot read it). When I plug it in, again, only sg0 (root:disk), but not sg1 (root:root) appear in /dev.

I have even joined the disk group to see if the SanDisk ArmorATD would display in /dev like the other 2 drives do, but it does not: sg1 is still present and the odd lag in removing and the persistently flashing lamp on the drive are all still present.

Why is the SanDisk ArmorATD drive behaving like this? Why does the lamp flash endlessly? Why does only it have /dev/sg1 (root:root), while the other drives do not?

sg_map responds:

/dev/sg0 /dev/sda
/dev/sg1

cat /sys/block/sda/removable responds:

0

So, what does one do to solve this?

I used the udiskctl (u)mount commands. They work; however, they do not address the problem with the removable drive being handled by the system as non-removable.

I created /etc/udev/rules.d/10-local.rules:

KERNEL==“sda”, ATTRS{vendor}==“G-TECH”, ATTRS{model}==“WDC_WD20JMRM-59CGRS1”, ATTRS{removable}==“1”

I rebooted the computer. I do not know if the system accessed 10-local.rules, nor whether it was able to identify my drive by the information. Is there a way to find out?

Also, /sys/block/sda/removable is still set to ‘0’. I tried to manually write to the file, but it is unwritable. I do not know how to set it to ‘1’.

How would I create and test the proper rules.local file to uniquely address my drive and apply the desired setting?

I followed some instructions from elsewhere that had me create a trigger file with a timestamp, so I know that my rules file is being read. It is now located at /etc/udev/rules.d/80-local.rules. The rest was up to me. So far, I have:

KERNEL==“sda”, ATTR{removable}=“1”, SUBSYSTEMS==“scsi”, ATTRS{vendor}=="G-TECH "

I could use SUBSYSTEM==“block” instead. This would guard against there already being an sda (unlikely on my personal computer).

I checked the journal. It says (manually edited for legibility; might be backwards??? as I used journalctl -r):

(udev-worker)[3902]: sda: /etc/udev/rules.d/80-local.rules:1 Failed to write ATTR{/sys/devices/pci0000:00/0000:00:0d.0/usb2/2>
kernel: ses 1:0:0:1: Attached Enclosure device
kernel: scsi 1:0:0:1: Failed to bind enclosure -19
kernel: scsi 1:0:0:1: Failed to get diagnostic page 0x1
kernel: scsi 1:0:0:1: Wrong diagnostic page; asked for 1 got 8
kernel: sd 1:0:0:0: [sda] Attached SCSI disk
kernel: sda: sda1
kernel: sd 1:0:0:0: [sda] Optimal transfer size 1048576 bytes
kernel: sd 1:0:0:0: [sda] Preferred minimum I/O size 4096 bytes
kernel: sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
kernel: sd 1:0:0:0: [sda] Mode Sense: 5f 00 10 00

It seems I am on the right track, but I need more assistance.

P: /devices/pci0000:00/0000:00:0d.0/usb2/2-1/2-1:1.0/host1/target1:0:0/1:0:0:0/block/>
M: sda
U: block
T: disk
D: b 8:0
N: sda
L: 0
S: disk/by-path/pci-0000:00:0d.0-usb-0:1:1.0-scsi-0:0:0:0
S: disk/by-id/scsi-350014ee26b8bb345
S: disk/by-path/pci-0000:00:0d.0-usbv3-0:1:1.0-scsi-0:0:0:0
S: disk/by-id/ata-WDC_WD20JMRM-59CGRS1_WD-WX32AC376Z85
S: disk/by-id/usb-G-TECH_ArmorATD_5758333241433337365A3835-0:0
S: disk/by-id/wwn-0x50014ee26b8bb345
S: disk/by-diskseq/3
Q: 3
E: DEVPATH=/devices/pci0000:00/0000:00:0d.0/usb2/2-1/2-1:1.0/host1/target1:0:0/1:0:0:>
E: DEVNAME=/dev/sda
E: DEVTYPE=disk
E: DISKSEQ=3
E: MAJOR=8
E: MINOR=0
E: SUBSYSTEM=block
E: USEC_INITIALIZED=7388480752
E: ID_ATA=1
E: ID_TYPE=disk
E: ID_BUS=ata
E: ID_MODEL=WDC_WD20JMRM-59CGRS1
E: ID_MODEL_ENC=WDC\x20WD20JMRM-59CGRS1\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x>
E: ID_REVISION=01.01A01
E: ID_SERIAL=WDC_WD20JMRM-59CGRS1_WD-WX32AC376Z85
E: ID_SERIAL_SHORT=WD-WX32AC376Z85
E: ID_ATA_WRITE_CACHE=1
E: ID_ATA_WRITE_CACHE_ENABLED=1
E: ID_ATA_FEATURE_SET_PM=1
E: ID_ATA_FEATURE_SET_PM_ENABLED=1
E: ID_ATA_FEATURE_SET_SECURITY=1
E: ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
E: ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=392
E: ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=392
E: ID_ATA_FEATURE_SET_SMART=1
E: ID_ATA_FEATURE_SET_SMART_ENABLED=1
E: ID_ATA_FEATURE_SET_PUIS=1
E: ID_ATA_FEATURE_SET_PUIS_ENABLED=0
E: ID_ATA_FEATURE_SET_APM=1
E: ID_ATA_FEATURE_SET_APM_ENABLED=1
E: ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=128
E: ID_ATA_DOWNLOAD_MICROCODE=1
E: ID_ATA_SATA=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN2=1
E: ID_ATA_SATA_SIGNAL_RATE_GEN1=1
E: ID_ATA_ROTATION_RATE_RPM=4800
E: ID_WWN=0x50014ee26b8bb345
E: ID_WWN_WITH_EXTENSION=0x50014ee26b8bb345
E: ID_ATA_PERIPHERAL_DEVICE_TYPE=0
E: ID_USB_MODEL=ArmorATD
E: ID_USB_MODEL_ENC=ArmorATD\x20\x20\x20\x20\x20\x20\x20\x20
E: ID_USB_MODEL_ID=205a
E: ID_USB_SERIAL=G-TECH_ArmorATD_5758333241433337365A3835-0:0
E: ID_USB_SERIAL_SHORT=5758333241433337365A3835
E: ID_USB_VENDOR=G-TECH
E: ID_USB_VENDOR_ENC=G-TECH\x20\x20
E: ID_USB_VENDOR_ID=4791
E: ID_USB_REVISION=2007
E: ID_USB_TYPE=disk
E: ID_USB_INSTANCE=0:0
E: ID_USB_INTERFACES=:080650:080662:
E: ID_USB_INTERFACE_NUM=00
E: ID_USB_DRIVER=uas
E: ID_PATH_WITH_USB_REVISION=pci-0000:00:0d.0-usbv3-0:1:1.0-scsi-0:0:0:0
E: ID_PATH=pci-0000:00:0d.0-usb-0:1:1.0-scsi-0:0:0:0
E: ID_PATH_TAG=pci-0000_00_0d_0-usb-0_1_1_0-scsi-0_0_0_0
E: ID_PART_TABLE_UUID=ff3bee4b-b0d0-4bda-b724-741123e56cbc
E: ID_PART_TABLE_TYPE=gpt
E: SCSI_TPGS=0
E: SCSI_TYPE=disk
E: SCSI_VENDOR=G-TECH
E: SCSI_VENDOR_ENC=G-TECH\x20\x20
E: ID_SCSI=1
E: ID_SCSI_INQUIRY=1
E: SCSI_IDENT_SERIAL=WX32AC376Z85
E: SCSI_IDENT_LUN_NAA_REG=50014ee26b8bb345
E: SCSI_IDENT_TARGET_NAA_REG=50014ee26b8bb345
E: SCSI_IDENT_PORT_NAA_REG=50014ee26b8bb345
E: SCSI_IDENT_LUN_T10=G-TECH_ArmorATD_WX32AC376Z85
E: ID_VENDOR=G-TECH
E: ID_VENDOR_ENC=G-TECH\x20\x20
E: ID_SCSI_SERIAL=WX32AC376Z85
E: DEVLINKS=/dev/disk/by-path/pci-0000:00:0d.0-usb-0:1:1.0-scsi-0:0:0:0 /dev/disk/by->
E: TAGS=:systemd:
E: CURRENT_TAGS=:systemd:

I did exactly as you said, removed my local.rules and put in yours, including the new title. journalctl -r (backwards listing I beieve and edited for legibility):

kernel: sd 1:0:0:0: [sda] Attached SCSI disk
kernel: sda: sda1
kernel: sd 1:0:0:0: [sda] Optimal transfer size 1048576 bytes
kernel: sd 1:0:0:0: [sda] Preferred minimum I/O size 4096 bytes
kernel: sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
kernel: sd 1:0:0:0: [sda] Mode Sense: 5f 00 10 00
kernel: sd 1:0:0:0: [sda] Write Protect is off
kernel: sd 1:0:0:0: [sda] 4096-byte physical blocks
kernel: sd 1:0:0:0: [sda] 3906963456 512-byte logical blocks: (2.00 TB/1.82 TiB)
kernel: …ready
mtp-probe[4215]: bus: 2, device: 4 was not an MTP device
mtp-probe[4215]: checking bus 2, device 4: “/sys/devices/pci0000:00/0000:00:0d.0/usb2/2-1”
mtp-probe[4214]: bus: 2, device: 4 was not an MTP device
mtp-probe[4214]: checking bus 2, device 4: “/sys/devices/pci0000:00/0000:00:0d.0/usb2/2-1”
kernel: ses 1:0:0:1: Failed to bind enclosure -19
kernel: ses 1:0:0:1: Failed to get diagnostic page 0x1
kernel: ses 1:0:0:1: Wrong diagnostic page; asked for 1 got 8
kernel: ses 1:0:0:1: Attached scsi generic sg1 type 13
kernel: ses 1:0:0:1: Attached Enclosure device
kernel: sd 1:0:0:0: [sda] Spinning up disk…
kernel: sd 1:0:0:0: Attached scsi generic sg0 type 0
kernel: scsi 1:0:0:1: Enclosure G-TECH SES Device 2007 PQ: 0 ANSI: 6
kernel: scsi 1:0:0:0: Direct-Access G-TECH ArmorATD 2007 PQ: 0 ANSI: 6
kernel: scsi host1: uas
kernel: usb 2-1: SerialNumber: 5758333241433337365A3835
kernel: usb 2-1: Manufacturer: G-Technology
kernel: usb 2-1: Product: ArmorATD
kernel: usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
kernel: usb 2-1: New USB device found, idVendor=4791, idProduct=205a, bcdDevice=20.07
kernel: usb 2-1: new SuperSpeed USB device number 4 using xhci_hcd

I checked the value of /sys/block/sda/removable and it is still ‘0’.

Just to see if this new set of rules made any difference, I renamed it to .bak and rebooted the machine. I plugged in the drive. This time I experimented with journalctl -e (hoping to more easily navigate the output, so it is now in the opposite order to previous snippet, I think???). This is what is shows:

kernel: usb 2-1: new SuperSpeed USB device number 2 using xhci_hcd
kernel: usb 2-1: New USB device found, idVendor=4791, idProduct=205a, bcdDevice=20.07
kernel: usb 2-1: New USB device strings: Mfr=2, Product=3, SerialNumber=1
kernel: usb 2-1: Product: ArmorATD
kernel: usb 2-1: Manufacturer: G-Technology
kernel: usb 2-1: SerialNumber: 5758333241433337365A3835
mtp-probe[3235]: checking bus 2, device 2: “/sys/devices/pci0000:00/0000:00:0d.0/usb2/2-1”
mtp-probe[3235]: bus: 2, device: 2 was not an MTP device
kernel: usbcore: registered new interface driver usb-storage
kernel: scsi host1: uas
kernel: usbcore: registered new interface driver uas
kernel: scsi 1:0:0:0: Direct-Access G-TECH ArmorATD 2007 PQ: 0 ANSI: 6
kernel: scsi 1:0:0:1: Enclosure G-TECH SES Device 2007 PQ: 0 ANSI: 6
kernel: sd 1:0:0:0: Attached scsi generic sg0 type 0
kernel: sd 1:0:0:0: [sda] Spinning up disk…
kernel: scsi 1:0:0:1: Attached scsi generic sg1 type 13
kernel: …ready
kernel: sd 1:0:0:0: [sda] 3906963456 512-byte logical blocks: (2.00 TB/1.82 TiB)
kernel: sd 1:0:0:0: [sda] 4096-byte physical blocks
kernel: sd 1:0:0:0: [sda] Write Protect is off
kernel: sd 1:0:0:0: [sda] Mode Sense: 5f 00 10 00
kernel: sd 1:0:0:0: [sda] Write cache: enabled, read cache: enabled, supports DPO and FUA
kernel: sd 1:0:0:0: [sda] Preferred minimum I/O size 4096 bytes
kernel: sd 1:0:0:0: [sda] Optimal transfer size 1048576 bytes
kernel: sda: sda1
kernel: sd 1:0:0:0: [sda] Attached SCSI disk
mtp-probe[3244]: checking bus 2, device 2: “/sys/devices/pci0000:00/0000:00:0d.0/usb2/2-1”
mtp-probe[3244]: bus: 2, device: 2 was not an MTP device
kernel: scsi 1:0:0:1: Wrong diagnostic page; asked for 1 got 8
kernel: scsi 1:0:0:1: Failed to get diagnostic page 0x1
kernel: scsi 1:0:0:1: Failed to bind enclosure -19
kernel: ses 1:0:0:1: Attached Enclosure device

I’m not certain, but I cannot detect any significant difference. Can you? Does this new set of rules change anything?

I mounted the drive with the new rules and, just as before I opened this request for help, it mounts fine, but when I remove the drive, the light flashes nonstop. Nothing appears to have changed. Even the journal doesn’t show any difference. I don’t think the new rules do anything at all, do they?

I never knew about the udisksctl power-off command. This tells the system that the device is now off and the plug can be pulled out. I can now tell the system that I am unmounting the parition, but the power is still on (I have seen this: the devices are still present in /dev) and I can remount anew without un/replugging. When I am done, I tell the system to power off the drive. It’s not just a brutal yank and it’s gone. I like this!

I think you are onto something with the 2-device theory. That would explain why there is /dev/sg0 and /dev/sg1.

However, the widget seems to do things it’s own way. I will test the Plasma widget’s response to the new rules.

Just rebooted. Your custom rules file is in place. Plugged in external drive. As always, the widget correctly responds by asking whether I’d like to mount the partition on the drive. It mounts correctly, opens dolphin etc. I can also remove using the widget (always could). The partition is unmounted, there is a short beep, then a long pause, then a second beep. The devices in /dev (sda,sda1, sg0, sg1) are all gone. The drive’s light is insistently flashing rapidly. All this is as it has always been. I need to remove the plug and reinsert, should I want to reuse the drive.

Using the udisksctl commands: I can mount the partition (dolphin does not automatically open to the top level, I have to do this manually, of course); I can unmount the partition (lamp is just on, not insistently flashing); I can remount, if I want to; AND, ah-ha!!! When I use udisksctl power-off the devices in /dev disappear and the drive’s lamp flashes insistently! Power is not completely turned off, but the devices are removed.

It would seem that the Plasma widget is unmounting and powering off in one step. (I like the udisksctl method better: it is more elegant, allowing a remount).

So, maybe there is no problem at all!? What do you think? The flashing lamp just tells the user to pull the cable. It was the persistently flashing lamp, the lengthy pause between the beeps when using the Plasma widget and the mysterious /dev/sg1 (not present with the other external drives I have) that made me think there was something wrong with how this drive is being managed by the system.

Keep me posted on your progress.

Odd about the USB power. Yes, removable=1 would be nice, but, as you said, it could be the firmware… and it is safe to pull the cable once it is unmounted and powered off.