0

I'm experimenting with a software defined device, trying to force it to work with block size = 512 bytes, but it looks like the Linux doesn't want that.

I've forced the device to report minimal blocks numbers for the SCSI INQUIRY command:

hekto@ubuntu3:~$ sudo sg_inq -p 0xb0 /dev/sde
VPD INQUIRY: Block limits page (SBC)
  Maximum compare and write length: 255 blocks
  Optimal transfer length granularity: 1 blocks
  Maximum transfer length: 1 blocks
  Optimal transfer length: 1 blocks
  Maximum prefetch transfer length: 0 blocks
  Maximum unmap LBA count: 0
  Maximum unmap block descriptor count: 0
  Optimal unmap granularity: 0
  Unmap granularity alignment valid: 0
  Unmap granularity alignment: 0
  Maximum write same length: 0x0 blocks
  Maximum atomic transfer length: 0
  Atomic alignment: 0
  Atomic transfer length granularity: 0

But the fdisk -l still reports physical block size = 4096:

hekto@ubuntu3:~$ sudo fdisk -l /dev/sde

Disk /dev/sde: 5 MB, 5120000 bytes
1 heads, 10 sectors/track, 1000 cylinders, total 10000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes  <== see here
I/O size (minimum/optimal): 4096 bytes / 524288 bytes.  <== and here  

Where do these numbers (see above) come from?

OS: Ubuntu 14.04.5 LTS with kernel 3.19.0-78-generic

(working as virtual machine under VMware Fusion 8.5.8 on MacBook)

7
  • 2
    Try strace fdisk -l /dev/sde Sep 26, 2017 at 17:26
  • @BasileStarynkevitch - great idea, thanks! I see ioctl calls with BLKIOMIN and BLKPBSZGET, which return 4096. Any way to affect these parameters? Or they are hard-coded in Linux?
    – HEKTO
    Sep 26, 2017 at 17:56
  • I have no idea, but that should go into the question Sep 26, 2017 at 18:03
  • what did parted say? Sep 26, 2017 at 18:22
  • The question is answered by @BasileStarynkevitch and the Poster
    – ILMostro_7
    Sep 26, 2017 at 18:54

1 Answer 1

1

I suggested to use strace(1) to understand the syscalls(2) done by your fdisk command, i.e. to run as root:

  strace fdisk -l /dev/sde

you have discovered that it uses some ioctl like BLKIOMIN and BLKPBSZGET

I don't know how the kernel computes these parameters; perhaps read sd(4).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.