4KN drive issues

Notice: Page may contain affiliate links for which we may earn a small commission through services like Amazon Affiliates or Skimlinks.

foureight84

Well-Known Member
Jun 26, 2018
276
252
63
I am hoping someone could help me understand what's going on. I have two HGST HUS726060ALN610 6TB 4kn drives and I'm trying to create a btrfs raid1 (in Ubuntu 22.04).

fdisk -l:
Bash:
Disk /dev/sdc: 5.46 TiB, 6001175126016 bytes, 1465130646 sectors
Disk model: 726060ALN610
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/sdd: 5.46 TiB, 6001175126016 bytes, 1465130646 sectors
Disk model: 726060ALN610
Units: sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
First I've noticed that mkfs.btrfs -d raid1 -m raid1 did not complete in over an hour, I didn't check for dmesg errors at the time but saw console output that the journalctl could not restart. I ended up doing a hard reset and wiped the drives. This time around I decided to create partitions on the drives first using cfdisk. It was while writing partition to one of the harddrives that started checking dmesg. This is the error I received:
Bash:
[  897.888213] sd 2:0:0:0: [sdc] tag#0 CDB: Write(10) 2a 00 57 54 1e 91 00 00 01 00
[  897.888474] sd 2:0:0:0: [sdc] Unaligned partial completion (resid=3584, sector_sz=4096)
I've not worked with 4kn drives before but I was under the impression that they are fully supported since kernel 2.6.x? The other thing is that the drives are in a USB enclosure (SYBA SY-ENC50104) using the JMicron JMS567 chipset. I wasn't able to find any mentions of compatibility issues and the drives seem to work fine on Windows in the same enclosure.
 

foureight84

Well-Known Member
Jun 26, 2018
276
252
63
pretty sure that's a sector size mismatch. Is it in 512e mode? 4096 - 3584 = 512
It doesn't seem like it. fdisk shows that both logical and physical sectors are 4096.

This is the lsblk -t output:

Bash:
NAME         ALIGNMENT MIN-IO OPT-IO PHY-SEC LOG-SEC ROTA SCHED       RQ-SIZE  RA WSAME
sda                  0    512      0     512     512    0 mq-deadline      64 128    0B
├─sda1               0    512      0     512     512    0 mq-deadline      64 128    0B
└─sda2               0    512      0     512     512    0 mq-deadline      64 128    0B
sdb                  0   4096      0    4096     512    1 mq-deadline      60 128   32M
sdc                  0   4096      0    4096    4096    1 mq-deadline       2 128    0B
sdd                  0   4096      0    4096    4096    1 mq-deadline       2 128    0B
mmcblk0              0    512      0     512     512    0 mq-deadline      64 128    0B
mmcblk0boot0         0    512      0     512     512    0 mq-deadline      64 128    0B
mmcblk0boot1         0    512      0     512     512    0 mq-deadline      64 128    0B
 

CyklonDX

Well-Known Member
Nov 8, 2022
823
267
63
you need to run your command with proper sector sizing.
mkfs.btrfs --sectorsize.
 

foureight84

Well-Known Member
Jun 26, 2018
276
252
63
you need to run your command with proper sector sizing.
mkfs.btrfs --sectorsize.
That doesn't work. dmesg error:

Bash:
[ 1992.464436] systemd-journald[408]: /dev/kmsg buffer overrun, some messages lost.
[ 1992.464721] sd 2:0:0:0: [sdc] Unaligned partial completion (resid=25088, sector_sz=4096)
[ 1992.464724] sd 2:0:0:0: [sdc] tag#0 CDB: Write(10) 2a 00 00 00 00 f9 00 00 07 00
 

foureight84

Well-Known Member
Jun 26, 2018
276
252
63
Windows format is always using 512 sector format, and GPT hardly takes any advantage of 4Kn.

Can you see if this still happens when you use disk 512 sector, and then retry formatting in brtfs as 512? (just to exclude any other potential issues)

(might be related)
Can you swap 4kn to 512e when they're native 4kn? To my knowledge, these drives do not have 512e mode.
 

foureight84

Well-Known Member
Jun 26, 2018
276
252
63
I would say it's the sata to USB Controller
Looks like you're right. I am seeing various issues with JMS567 UAS support in Linux but no specific case of anyone trying 4Kn drives on this particular bridge controller.
 

foureight84

Well-Known Member
Jun 26, 2018
276
252
63
Bash:
$ sudo sg_format --size=512 -v /dev/sdc
    HGST HUS  726060ALN610      0103   peripheral_type: disk [0x0]
      PROTECT=0
      Unit serial number: DD202206140045
      LU name: 3044202206140045
    mode sense(10) cdb: [5a 00 01 00 00 00 00 00 fc 00]
mode sense(10):
Fixed format, current; Sense key: Illegal Request
Additional sense: Invalid field in cdb
bad field in MODE SENSE (10) [mode_page 1 not supported?]
There's no way to change this drive to 512b. It looks like the issue might be with the SATA to USB bridge supporting 4Kn on linux.