LINUX.ORG.RU

История изменений

Исправление mandala, (текущая версия) :

https://unix.stackexchange.com/questions/178899/optimizing-logical-sector-siz...

512 byte is not really the default sector size. It depends on you hardware.

You can display what physical/logical sector sizes your disk reports via the /sys pseudo filesystem, e.g.:

# cat /sys/block/sda/queue/physical_block_size
4096
# cat  /sys/block/sda/queue/logical_block_size
512
What is the difference between those two values? The physical_block_size is the minimal size of a block the drive is able to write in an atomic operation, and the logical_block_size is the smallest size the drive is able to write (cf. the linux kernel documentation). Thus, if you have a 4k drive it makes sense that your storage stack (filesystem etc.) uses something equal or greater than the physical sector size.

Those values are also displayed in recent versions of fdisk, e.g.:

# fdisk -l /dev/sda
[..]
Sector size (logical/physical): 512 bytes / 4096 bytes
On current linux distributions, programs (that should care about the optimal sector size) like mkfs.xfs will pick the optimal sector size by default (e.g. 4096 bytes).

But you can also explicitly specify it via an option, e.g.:

# mkfs.xfs -f -s size=4096 /dev/sda
Or:

# mkfs.ext4 -F -b 4096 /dev/sda
In any case, most mkfs variants will also display the used block size during execution.

For an existing filesystem the block size can be determined with a command like:

# xfs_info /mnt
[..]
meta-data=                       sectsz=4096
data     =                       bsize=4096
naming   =version 2              bsize=4096
log      =internal               bsize=4096
         =                       sectsz=4096
realtime =none                   extsz=4096
Or:

# tune2fs -l /dev/sda
Block size:               4096
Fragment size:            4096

Исходная версия mandala, :