Is the default 512 byte physical sector size appropriate for SSD disks under Linux?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







9















GSmartControl and any other command line tool (like fdisk, smartctl, cat /sys/block/sd*/queue/hw_sector_size, cat /sys/block/sd*/queue/physical_block_size) I had used report the same for both of my disks:



Sector Size: 512 bytes logical/physical


This is a default Ubuntu 18.10 (later upgraded to 19.04) installation. However, the stat -f command on both disks reports:



Block size: 4096       Fundamental block size: 4096


Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something? Does the information returned by stat (=4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?



Please note the following output (sdb2 is my root partition, sda is my /home disk):



# fdisk -l /dev/sd?
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SanDisk SDSSDH35
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: ADATA SU800NS38
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxx....

Device Start End Sectors Size Type
/dev/sdb1 2048 1050623 1048576 512M EFI System
/dev/sdb2 1050624 500117503 499066880 238G Linux filesystem

# df / /home
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb2 244568380 17799136 214276188 8% /
/dev/sda 479670976 129685112 325550152 29% /home









share|improve this question

























  • Yes. It does contain helpful information. But, I have not found an authoritative answer to the question: Does the information returned by stat (4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?

    – FedonKadifeli
    May 21 at 15:40













  • I don't know what "stat (4K)" is. But most modern OS's know how to deal with native 4K I/O transfers. And no, it doesn't mean that blocks will never cross 4K boundries on the disk unless the partitions are aligned properly. Use fdisk -l to check for alignment issues. And apparently SSD's work slightly different, because of their physical construction, but I'm not an expert in that area.

    – heynnema
    May 21 at 15:49




















9















GSmartControl and any other command line tool (like fdisk, smartctl, cat /sys/block/sd*/queue/hw_sector_size, cat /sys/block/sd*/queue/physical_block_size) I had used report the same for both of my disks:



Sector Size: 512 bytes logical/physical


This is a default Ubuntu 18.10 (later upgraded to 19.04) installation. However, the stat -f command on both disks reports:



Block size: 4096       Fundamental block size: 4096


Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something? Does the information returned by stat (=4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?



Please note the following output (sdb2 is my root partition, sda is my /home disk):



# fdisk -l /dev/sd?
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SanDisk SDSSDH35
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: ADATA SU800NS38
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxx....

Device Start End Sectors Size Type
/dev/sdb1 2048 1050623 1048576 512M EFI System
/dev/sdb2 1050624 500117503 499066880 238G Linux filesystem

# df / /home
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb2 244568380 17799136 214276188 8% /
/dev/sda 479670976 129685112 325550152 29% /home









share|improve this question

























  • Yes. It does contain helpful information. But, I have not found an authoritative answer to the question: Does the information returned by stat (4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?

    – FedonKadifeli
    May 21 at 15:40













  • I don't know what "stat (4K)" is. But most modern OS's know how to deal with native 4K I/O transfers. And no, it doesn't mean that blocks will never cross 4K boundries on the disk unless the partitions are aligned properly. Use fdisk -l to check for alignment issues. And apparently SSD's work slightly different, because of their physical construction, but I'm not an expert in that area.

    – heynnema
    May 21 at 15:49
















9












9








9








GSmartControl and any other command line tool (like fdisk, smartctl, cat /sys/block/sd*/queue/hw_sector_size, cat /sys/block/sd*/queue/physical_block_size) I had used report the same for both of my disks:



Sector Size: 512 bytes logical/physical


This is a default Ubuntu 18.10 (later upgraded to 19.04) installation. However, the stat -f command on both disks reports:



Block size: 4096       Fundamental block size: 4096


Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something? Does the information returned by stat (=4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?



Please note the following output (sdb2 is my root partition, sda is my /home disk):



# fdisk -l /dev/sd?
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SanDisk SDSSDH35
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: ADATA SU800NS38
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxx....

Device Start End Sectors Size Type
/dev/sdb1 2048 1050623 1048576 512M EFI System
/dev/sdb2 1050624 500117503 499066880 238G Linux filesystem

# df / /home
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb2 244568380 17799136 214276188 8% /
/dev/sda 479670976 129685112 325550152 29% /home









share|improve this question
















GSmartControl and any other command line tool (like fdisk, smartctl, cat /sys/block/sd*/queue/hw_sector_size, cat /sys/block/sd*/queue/physical_block_size) I had used report the same for both of my disks:



Sector Size: 512 bytes logical/physical


This is a default Ubuntu 18.10 (later upgraded to 19.04) installation. However, the stat -f command on both disks reports:



Block size: 4096       Fundamental block size: 4096


Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something? Does the information returned by stat (=4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?



Please note the following output (sdb2 is my root partition, sda is my /home disk):



# fdisk -l /dev/sd?
Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: SanDisk SDSSDH35
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: ADATA SU800NS38
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: xxxx....

Device Start End Sectors Size Type
/dev/sdb1 2048 1050623 1048576 512M EFI System
/dev/sdb2 1050624 500117503 499066880 238G Linux filesystem

# df / /home
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sdb2 244568380 17799136 214276188 8% /
/dev/sda 479670976 129685112 325550152 29% /home






ssd disk io sector-size






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited May 23 at 17:24









Community

1




1










asked May 19 at 16:04









FedonKadifeliFedonKadifeli

4541 silver badge20 bronze badges




4541 silver badge20 bronze badges













  • Yes. It does contain helpful information. But, I have not found an authoritative answer to the question: Does the information returned by stat (4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?

    – FedonKadifeli
    May 21 at 15:40













  • I don't know what "stat (4K)" is. But most modern OS's know how to deal with native 4K I/O transfers. And no, it doesn't mean that blocks will never cross 4K boundries on the disk unless the partitions are aligned properly. Use fdisk -l to check for alignment issues. And apparently SSD's work slightly different, because of their physical construction, but I'm not an expert in that area.

    – heynnema
    May 21 at 15:49





















  • Yes. It does contain helpful information. But, I have not found an authoritative answer to the question: Does the information returned by stat (4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?

    – FedonKadifeli
    May 21 at 15:40













  • I don't know what "stat (4K)" is. But most modern OS's know how to deal with native 4K I/O transfers. And no, it doesn't mean that blocks will never cross 4K boundries on the disk unless the partitions are aligned properly. Use fdisk -l to check for alignment issues. And apparently SSD's work slightly different, because of their physical construction, but I'm not an expert in that area.

    – heynnema
    May 21 at 15:49



















Yes. It does contain helpful information. But, I have not found an authoritative answer to the question: Does the information returned by stat (4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?

– FedonKadifeli
May 21 at 15:40







Yes. It does contain helpful information. But, I have not found an authoritative answer to the question: Does the information returned by stat (4K) ensure that the OS will always send IOs to the disk in multiple of 4K and these blocks will never cross 4K boundaries (IO blocks will always be aligned to 4K)?

– FedonKadifeli
May 21 at 15:40















I don't know what "stat (4K)" is. But most modern OS's know how to deal with native 4K I/O transfers. And no, it doesn't mean that blocks will never cross 4K boundries on the disk unless the partitions are aligned properly. Use fdisk -l to check for alignment issues. And apparently SSD's work slightly different, because of their physical construction, but I'm not an expert in that area.

– heynnema
May 21 at 15:49







I don't know what "stat (4K)" is. But most modern OS's know how to deal with native 4K I/O transfers. And no, it doesn't mean that blocks will never cross 4K boundries on the disk unless the partitions are aligned properly. Use fdisk -l to check for alignment issues. And apparently SSD's work slightly different, because of their physical construction, but I'm not an expert in that area.

– heynnema
May 21 at 15:49












3 Answers
3






active

oldest

votes


















7














In the old days, 512 byte sectors was the norm for disks. The system used to read/write sectors only one sector at a time, and that was the best that the old hard drives could do.



Now, with modern drives being so dense, and so fast, and so smart, reading/writing sectors only one sector at a time really slows down total throughput.



The trick was... how do you speed up total throughput, but still maintain compatibility with old/standard disk subsystems? You create a 4096 block size that are made up of eight 512 byte physical sectors. 4096 is now the minimum read/write transfer to/from the disk, but it's handed off in compatible 512 byte chucks to the OS.



This means that even if the system only needs one 512 byte sector of information, the drive reads eight 512 byte sectors to get it. If however, the system needs the next seven sectors, it's already read them, so no disk I/O needs to occur... hence a speed increase in total throughput.



Modern operating systems can fully take advantage of native 4K block sizes of modern drives.






share|improve this answer


























  • +1 but 4096/512=8, so I think there should be 8 (logical) sectors of 512 b in one physical sector of 4096 b. I use parted to show both the logical and physical sector size.

    – sudodus
    May 19 at 17:40













  • @sudodus Good catch. Edit performed.

    – heynnema
    May 19 at 17:48











  • This is why it's important to align your partitions to a 4k boundary, otherwise every 4k block load/store actually touches two hardware sectors. (Filesystems inside partitions often use 4k blocks aligned to the start of the partition). Some formatting tools align the first partition by 1MiB, leaving a whole MiB unused except for the partition table. Modern drives do report their physical sector size as 4k, separate from their logical sector size which is still 512B.

    – Peter Cordes
    May 20 at 8:42













  • @PeterCordes, Not only the boot sector and the partition table (in the first 512 bytes) are stored in the first Mibibyte. In an MSDOS partition table, grub puts additional code into the first Mibibyte for booting in BIOS mode. (In a GPT, grub needs a small partition with the bios_grub flag for that code to boot in BIOS mode).

    – sudodus
    May 20 at 9:32



















4














According to Wikipedia "Advanced Format (AF) is any disk sector format used to store data in disk drives that exceeds 512, 520, or 528 bytes per sector, such as the 4096-byte sectors of an Advanced Format Drive (AFD)." Advanced Format (AF) is a disk format that natively uses a sector size of 4,096 bytes instead of 512 bytes. To maintain compatibility with legacy systems, AF disks emulate a sector size of 512 bytes.



I got the same results as you got by running stat -f and smartctl on two SSDs. Both SSDs were automatically recognized by the OS when they were installed and required zero configuration, so it appears that the data you got is the default settings for block size and sector size.






share|improve this answer


























  • @heynnema I can't do anything about "4096-byte sectors" because it's copied from Wikipedia, so I have to leave it the same as it is in Wikipedia.

    – karel
    May 19 at 19:37








  • 2





    @heynnema: The physical size is far bigger. SSD's are built from NAND flash memory, "which is physically partitioned in so-called "erase blocks". Those can be far larger, 4MB is definitely possible.

    – MSalters
    May 20 at 7:23



















1















Is the default 512 byte physical sector size appropriate for SSD disks under Linux?



Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something?




Old hardware and Operating Systems used 512 byte sectors, since 2011 (almost) all storage hardware has 4096 (or larger) byte sectors; but some hardware supports emulation of 512 byte sectors for legacy systems. There are exceptions, the Samsung 840 EVO SSD has blocks of size 2048 KB.



An Error Correcting Code (ECC) is calculated for each 512 byte chunk, and as you can imagine, ECC data also requires storage space. It goes without saying that one 4096 byte sector requires less ECC information than eight 512 byte chunks if the ECC algorithms remain unchanged. In the end, the total storage capacity of a hard drive increases as a result of less ECC data overhead.



Using 4K sectors makes sense from an architectural standpoint, as other key figures (like x86 memory pages and many file system clusters) also employ the 4 KB size. The Advanced Format allows for more robust ECC algorithms, which is important in light of ever-increasing capacities. Controllers employ additional techniques beyond error correction through an understanding of the NAND flash memory error characteristics and the workload behavior.



Advanced Format (AF) is any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that exceeds 512, 520, or 528 bytes per sector, such as the 4096, 4112, 4160, and 4224-byte (4 KB) sectors of an Advanced Format Drive (AFD). Larger sectors enable the integration of stronger error correction algorithms to maintain data integrity at higher storage densities.



For SCSI (SAS) disks the RAID block size is larger than a JBOD block size due to the SCSI T10 standardized data integrity fields along with logical bad block checking stored on each block with the data. The SAS RAID adapters support disk blocks based on 512 Bytes of data or 4K Bytes of data. The RAID block size for the 512 disks is 528 Bytes per sector and the RAID block size for the 4K disks is 4224 bytes per sector.



Because you are writing to memory and not a spinning disk physical sector size has less effect than ensuring that your partitions are aligned with the erase block size. Even so it's best to have up to date software and hardware, and use 4K sector size.



The larger sector size is recommended by Intel - "Gain Optimal Performance by Changes to SSD Physical Sector Size".






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "89"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1144535%2fis-the-default-512-byte-physical-sector-size-appropriate-for-ssd-disks-under-lin%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    7














    In the old days, 512 byte sectors was the norm for disks. The system used to read/write sectors only one sector at a time, and that was the best that the old hard drives could do.



    Now, with modern drives being so dense, and so fast, and so smart, reading/writing sectors only one sector at a time really slows down total throughput.



    The trick was... how do you speed up total throughput, but still maintain compatibility with old/standard disk subsystems? You create a 4096 block size that are made up of eight 512 byte physical sectors. 4096 is now the minimum read/write transfer to/from the disk, but it's handed off in compatible 512 byte chucks to the OS.



    This means that even if the system only needs one 512 byte sector of information, the drive reads eight 512 byte sectors to get it. If however, the system needs the next seven sectors, it's already read them, so no disk I/O needs to occur... hence a speed increase in total throughput.



    Modern operating systems can fully take advantage of native 4K block sizes of modern drives.






    share|improve this answer


























    • +1 but 4096/512=8, so I think there should be 8 (logical) sectors of 512 b in one physical sector of 4096 b. I use parted to show both the logical and physical sector size.

      – sudodus
      May 19 at 17:40













    • @sudodus Good catch. Edit performed.

      – heynnema
      May 19 at 17:48











    • This is why it's important to align your partitions to a 4k boundary, otherwise every 4k block load/store actually touches two hardware sectors. (Filesystems inside partitions often use 4k blocks aligned to the start of the partition). Some formatting tools align the first partition by 1MiB, leaving a whole MiB unused except for the partition table. Modern drives do report their physical sector size as 4k, separate from their logical sector size which is still 512B.

      – Peter Cordes
      May 20 at 8:42













    • @PeterCordes, Not only the boot sector and the partition table (in the first 512 bytes) are stored in the first Mibibyte. In an MSDOS partition table, grub puts additional code into the first Mibibyte for booting in BIOS mode. (In a GPT, grub needs a small partition with the bios_grub flag for that code to boot in BIOS mode).

      – sudodus
      May 20 at 9:32
















    7














    In the old days, 512 byte sectors was the norm for disks. The system used to read/write sectors only one sector at a time, and that was the best that the old hard drives could do.



    Now, with modern drives being so dense, and so fast, and so smart, reading/writing sectors only one sector at a time really slows down total throughput.



    The trick was... how do you speed up total throughput, but still maintain compatibility with old/standard disk subsystems? You create a 4096 block size that are made up of eight 512 byte physical sectors. 4096 is now the minimum read/write transfer to/from the disk, but it's handed off in compatible 512 byte chucks to the OS.



    This means that even if the system only needs one 512 byte sector of information, the drive reads eight 512 byte sectors to get it. If however, the system needs the next seven sectors, it's already read them, so no disk I/O needs to occur... hence a speed increase in total throughput.



    Modern operating systems can fully take advantage of native 4K block sizes of modern drives.






    share|improve this answer


























    • +1 but 4096/512=8, so I think there should be 8 (logical) sectors of 512 b in one physical sector of 4096 b. I use parted to show both the logical and physical sector size.

      – sudodus
      May 19 at 17:40













    • @sudodus Good catch. Edit performed.

      – heynnema
      May 19 at 17:48











    • This is why it's important to align your partitions to a 4k boundary, otherwise every 4k block load/store actually touches two hardware sectors. (Filesystems inside partitions often use 4k blocks aligned to the start of the partition). Some formatting tools align the first partition by 1MiB, leaving a whole MiB unused except for the partition table. Modern drives do report their physical sector size as 4k, separate from their logical sector size which is still 512B.

      – Peter Cordes
      May 20 at 8:42













    • @PeterCordes, Not only the boot sector and the partition table (in the first 512 bytes) are stored in the first Mibibyte. In an MSDOS partition table, grub puts additional code into the first Mibibyte for booting in BIOS mode. (In a GPT, grub needs a small partition with the bios_grub flag for that code to boot in BIOS mode).

      – sudodus
      May 20 at 9:32














    7












    7








    7







    In the old days, 512 byte sectors was the norm for disks. The system used to read/write sectors only one sector at a time, and that was the best that the old hard drives could do.



    Now, with modern drives being so dense, and so fast, and so smart, reading/writing sectors only one sector at a time really slows down total throughput.



    The trick was... how do you speed up total throughput, but still maintain compatibility with old/standard disk subsystems? You create a 4096 block size that are made up of eight 512 byte physical sectors. 4096 is now the minimum read/write transfer to/from the disk, but it's handed off in compatible 512 byte chucks to the OS.



    This means that even if the system only needs one 512 byte sector of information, the drive reads eight 512 byte sectors to get it. If however, the system needs the next seven sectors, it's already read them, so no disk I/O needs to occur... hence a speed increase in total throughput.



    Modern operating systems can fully take advantage of native 4K block sizes of modern drives.






    share|improve this answer















    In the old days, 512 byte sectors was the norm for disks. The system used to read/write sectors only one sector at a time, and that was the best that the old hard drives could do.



    Now, with modern drives being so dense, and so fast, and so smart, reading/writing sectors only one sector at a time really slows down total throughput.



    The trick was... how do you speed up total throughput, but still maintain compatibility with old/standard disk subsystems? You create a 4096 block size that are made up of eight 512 byte physical sectors. 4096 is now the minimum read/write transfer to/from the disk, but it's handed off in compatible 512 byte chucks to the OS.



    This means that even if the system only needs one 512 byte sector of information, the drive reads eight 512 byte sectors to get it. If however, the system needs the next seven sectors, it's already read them, so no disk I/O needs to occur... hence a speed increase in total throughput.



    Modern operating systems can fully take advantage of native 4K block sizes of modern drives.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 19 at 19:45

























    answered May 19 at 17:28









    heynnemaheynnema

    24.9k3 gold badges25 silver badges67 bronze badges




    24.9k3 gold badges25 silver badges67 bronze badges













    • +1 but 4096/512=8, so I think there should be 8 (logical) sectors of 512 b in one physical sector of 4096 b. I use parted to show both the logical and physical sector size.

      – sudodus
      May 19 at 17:40













    • @sudodus Good catch. Edit performed.

      – heynnema
      May 19 at 17:48











    • This is why it's important to align your partitions to a 4k boundary, otherwise every 4k block load/store actually touches two hardware sectors. (Filesystems inside partitions often use 4k blocks aligned to the start of the partition). Some formatting tools align the first partition by 1MiB, leaving a whole MiB unused except for the partition table. Modern drives do report their physical sector size as 4k, separate from their logical sector size which is still 512B.

      – Peter Cordes
      May 20 at 8:42













    • @PeterCordes, Not only the boot sector and the partition table (in the first 512 bytes) are stored in the first Mibibyte. In an MSDOS partition table, grub puts additional code into the first Mibibyte for booting in BIOS mode. (In a GPT, grub needs a small partition with the bios_grub flag for that code to boot in BIOS mode).

      – sudodus
      May 20 at 9:32



















    • +1 but 4096/512=8, so I think there should be 8 (logical) sectors of 512 b in one physical sector of 4096 b. I use parted to show both the logical and physical sector size.

      – sudodus
      May 19 at 17:40













    • @sudodus Good catch. Edit performed.

      – heynnema
      May 19 at 17:48











    • This is why it's important to align your partitions to a 4k boundary, otherwise every 4k block load/store actually touches two hardware sectors. (Filesystems inside partitions often use 4k blocks aligned to the start of the partition). Some formatting tools align the first partition by 1MiB, leaving a whole MiB unused except for the partition table. Modern drives do report their physical sector size as 4k, separate from their logical sector size which is still 512B.

      – Peter Cordes
      May 20 at 8:42













    • @PeterCordes, Not only the boot sector and the partition table (in the first 512 bytes) are stored in the first Mibibyte. In an MSDOS partition table, grub puts additional code into the first Mibibyte for booting in BIOS mode. (In a GPT, grub needs a small partition with the bios_grub flag for that code to boot in BIOS mode).

      – sudodus
      May 20 at 9:32

















    +1 but 4096/512=8, so I think there should be 8 (logical) sectors of 512 b in one physical sector of 4096 b. I use parted to show both the logical and physical sector size.

    – sudodus
    May 19 at 17:40







    +1 but 4096/512=8, so I think there should be 8 (logical) sectors of 512 b in one physical sector of 4096 b. I use parted to show both the logical and physical sector size.

    – sudodus
    May 19 at 17:40















    @sudodus Good catch. Edit performed.

    – heynnema
    May 19 at 17:48





    @sudodus Good catch. Edit performed.

    – heynnema
    May 19 at 17:48













    This is why it's important to align your partitions to a 4k boundary, otherwise every 4k block load/store actually touches two hardware sectors. (Filesystems inside partitions often use 4k blocks aligned to the start of the partition). Some formatting tools align the first partition by 1MiB, leaving a whole MiB unused except for the partition table. Modern drives do report their physical sector size as 4k, separate from their logical sector size which is still 512B.

    – Peter Cordes
    May 20 at 8:42







    This is why it's important to align your partitions to a 4k boundary, otherwise every 4k block load/store actually touches two hardware sectors. (Filesystems inside partitions often use 4k blocks aligned to the start of the partition). Some formatting tools align the first partition by 1MiB, leaving a whole MiB unused except for the partition table. Modern drives do report their physical sector size as 4k, separate from their logical sector size which is still 512B.

    – Peter Cordes
    May 20 at 8:42















    @PeterCordes, Not only the boot sector and the partition table (in the first 512 bytes) are stored in the first Mibibyte. In an MSDOS partition table, grub puts additional code into the first Mibibyte for booting in BIOS mode. (In a GPT, grub needs a small partition with the bios_grub flag for that code to boot in BIOS mode).

    – sudodus
    May 20 at 9:32





    @PeterCordes, Not only the boot sector and the partition table (in the first 512 bytes) are stored in the first Mibibyte. In an MSDOS partition table, grub puts additional code into the first Mibibyte for booting in BIOS mode. (In a GPT, grub needs a small partition with the bios_grub flag for that code to boot in BIOS mode).

    – sudodus
    May 20 at 9:32













    4














    According to Wikipedia "Advanced Format (AF) is any disk sector format used to store data in disk drives that exceeds 512, 520, or 528 bytes per sector, such as the 4096-byte sectors of an Advanced Format Drive (AFD)." Advanced Format (AF) is a disk format that natively uses a sector size of 4,096 bytes instead of 512 bytes. To maintain compatibility with legacy systems, AF disks emulate a sector size of 512 bytes.



    I got the same results as you got by running stat -f and smartctl on two SSDs. Both SSDs were automatically recognized by the OS when they were installed and required zero configuration, so it appears that the data you got is the default settings for block size and sector size.






    share|improve this answer


























    • @heynnema I can't do anything about "4096-byte sectors" because it's copied from Wikipedia, so I have to leave it the same as it is in Wikipedia.

      – karel
      May 19 at 19:37








    • 2





      @heynnema: The physical size is far bigger. SSD's are built from NAND flash memory, "which is physically partitioned in so-called "erase blocks". Those can be far larger, 4MB is definitely possible.

      – MSalters
      May 20 at 7:23
















    4














    According to Wikipedia "Advanced Format (AF) is any disk sector format used to store data in disk drives that exceeds 512, 520, or 528 bytes per sector, such as the 4096-byte sectors of an Advanced Format Drive (AFD)." Advanced Format (AF) is a disk format that natively uses a sector size of 4,096 bytes instead of 512 bytes. To maintain compatibility with legacy systems, AF disks emulate a sector size of 512 bytes.



    I got the same results as you got by running stat -f and smartctl on two SSDs. Both SSDs were automatically recognized by the OS when they were installed and required zero configuration, so it appears that the data you got is the default settings for block size and sector size.






    share|improve this answer


























    • @heynnema I can't do anything about "4096-byte sectors" because it's copied from Wikipedia, so I have to leave it the same as it is in Wikipedia.

      – karel
      May 19 at 19:37








    • 2





      @heynnema: The physical size is far bigger. SSD's are built from NAND flash memory, "which is physically partitioned in so-called "erase blocks". Those can be far larger, 4MB is definitely possible.

      – MSalters
      May 20 at 7:23














    4












    4








    4







    According to Wikipedia "Advanced Format (AF) is any disk sector format used to store data in disk drives that exceeds 512, 520, or 528 bytes per sector, such as the 4096-byte sectors of an Advanced Format Drive (AFD)." Advanced Format (AF) is a disk format that natively uses a sector size of 4,096 bytes instead of 512 bytes. To maintain compatibility with legacy systems, AF disks emulate a sector size of 512 bytes.



    I got the same results as you got by running stat -f and smartctl on two SSDs. Both SSDs were automatically recognized by the OS when they were installed and required zero configuration, so it appears that the data you got is the default settings for block size and sector size.






    share|improve this answer















    According to Wikipedia "Advanced Format (AF) is any disk sector format used to store data in disk drives that exceeds 512, 520, or 528 bytes per sector, such as the 4096-byte sectors of an Advanced Format Drive (AFD)." Advanced Format (AF) is a disk format that natively uses a sector size of 4,096 bytes instead of 512 bytes. To maintain compatibility with legacy systems, AF disks emulate a sector size of 512 bytes.



    I got the same results as you got by running stat -f and smartctl on two SSDs. Both SSDs were automatically recognized by the OS when they were installed and required zero configuration, so it appears that the data you got is the default settings for block size and sector size.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited May 19 at 19:07

























    answered May 19 at 16:28









    karelkarel

    64.5k14 gold badges143 silver badges165 bronze badges




    64.5k14 gold badges143 silver badges165 bronze badges













    • @heynnema I can't do anything about "4096-byte sectors" because it's copied from Wikipedia, so I have to leave it the same as it is in Wikipedia.

      – karel
      May 19 at 19:37








    • 2





      @heynnema: The physical size is far bigger. SSD's are built from NAND flash memory, "which is physically partitioned in so-called "erase blocks". Those can be far larger, 4MB is definitely possible.

      – MSalters
      May 20 at 7:23



















    • @heynnema I can't do anything about "4096-byte sectors" because it's copied from Wikipedia, so I have to leave it the same as it is in Wikipedia.

      – karel
      May 19 at 19:37








    • 2





      @heynnema: The physical size is far bigger. SSD's are built from NAND flash memory, "which is physically partitioned in so-called "erase blocks". Those can be far larger, 4MB is definitely possible.

      – MSalters
      May 20 at 7:23

















    @heynnema I can't do anything about "4096-byte sectors" because it's copied from Wikipedia, so I have to leave it the same as it is in Wikipedia.

    – karel
    May 19 at 19:37







    @heynnema I can't do anything about "4096-byte sectors" because it's copied from Wikipedia, so I have to leave it the same as it is in Wikipedia.

    – karel
    May 19 at 19:37






    2




    2





    @heynnema: The physical size is far bigger. SSD's are built from NAND flash memory, "which is physically partitioned in so-called "erase blocks". Those can be far larger, 4MB is definitely possible.

    – MSalters
    May 20 at 7:23





    @heynnema: The physical size is far bigger. SSD's are built from NAND flash memory, "which is physically partitioned in so-called "erase blocks". Those can be far larger, 4MB is definitely possible.

    – MSalters
    May 20 at 7:23











    1















    Is the default 512 byte physical sector size appropriate for SSD disks under Linux?



    Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something?




    Old hardware and Operating Systems used 512 byte sectors, since 2011 (almost) all storage hardware has 4096 (or larger) byte sectors; but some hardware supports emulation of 512 byte sectors for legacy systems. There are exceptions, the Samsung 840 EVO SSD has blocks of size 2048 KB.



    An Error Correcting Code (ECC) is calculated for each 512 byte chunk, and as you can imagine, ECC data also requires storage space. It goes without saying that one 4096 byte sector requires less ECC information than eight 512 byte chunks if the ECC algorithms remain unchanged. In the end, the total storage capacity of a hard drive increases as a result of less ECC data overhead.



    Using 4K sectors makes sense from an architectural standpoint, as other key figures (like x86 memory pages and many file system clusters) also employ the 4 KB size. The Advanced Format allows for more robust ECC algorithms, which is important in light of ever-increasing capacities. Controllers employ additional techniques beyond error correction through an understanding of the NAND flash memory error characteristics and the workload behavior.



    Advanced Format (AF) is any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that exceeds 512, 520, or 528 bytes per sector, such as the 4096, 4112, 4160, and 4224-byte (4 KB) sectors of an Advanced Format Drive (AFD). Larger sectors enable the integration of stronger error correction algorithms to maintain data integrity at higher storage densities.



    For SCSI (SAS) disks the RAID block size is larger than a JBOD block size due to the SCSI T10 standardized data integrity fields along with logical bad block checking stored on each block with the data. The SAS RAID adapters support disk blocks based on 512 Bytes of data or 4K Bytes of data. The RAID block size for the 512 disks is 528 Bytes per sector and the RAID block size for the 4K disks is 4224 bytes per sector.



    Because you are writing to memory and not a spinning disk physical sector size has less effect than ensuring that your partitions are aligned with the erase block size. Even so it's best to have up to date software and hardware, and use 4K sector size.



    The larger sector size is recommended by Intel - "Gain Optimal Performance by Changes to SSD Physical Sector Size".






    share|improve this answer




























      1















      Is the default 512 byte physical sector size appropriate for SSD disks under Linux?



      Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something?




      Old hardware and Operating Systems used 512 byte sectors, since 2011 (almost) all storage hardware has 4096 (or larger) byte sectors; but some hardware supports emulation of 512 byte sectors for legacy systems. There are exceptions, the Samsung 840 EVO SSD has blocks of size 2048 KB.



      An Error Correcting Code (ECC) is calculated for each 512 byte chunk, and as you can imagine, ECC data also requires storage space. It goes without saying that one 4096 byte sector requires less ECC information than eight 512 byte chunks if the ECC algorithms remain unchanged. In the end, the total storage capacity of a hard drive increases as a result of less ECC data overhead.



      Using 4K sectors makes sense from an architectural standpoint, as other key figures (like x86 memory pages and many file system clusters) also employ the 4 KB size. The Advanced Format allows for more robust ECC algorithms, which is important in light of ever-increasing capacities. Controllers employ additional techniques beyond error correction through an understanding of the NAND flash memory error characteristics and the workload behavior.



      Advanced Format (AF) is any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that exceeds 512, 520, or 528 bytes per sector, such as the 4096, 4112, 4160, and 4224-byte (4 KB) sectors of an Advanced Format Drive (AFD). Larger sectors enable the integration of stronger error correction algorithms to maintain data integrity at higher storage densities.



      For SCSI (SAS) disks the RAID block size is larger than a JBOD block size due to the SCSI T10 standardized data integrity fields along with logical bad block checking stored on each block with the data. The SAS RAID adapters support disk blocks based on 512 Bytes of data or 4K Bytes of data. The RAID block size for the 512 disks is 528 Bytes per sector and the RAID block size for the 4K disks is 4224 bytes per sector.



      Because you are writing to memory and not a spinning disk physical sector size has less effect than ensuring that your partitions are aligned with the erase block size. Even so it's best to have up to date software and hardware, and use 4K sector size.



      The larger sector size is recommended by Intel - "Gain Optimal Performance by Changes to SSD Physical Sector Size".






      share|improve this answer


























        1












        1








        1








        Is the default 512 byte physical sector size appropriate for SSD disks under Linux?



        Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something?




        Old hardware and Operating Systems used 512 byte sectors, since 2011 (almost) all storage hardware has 4096 (or larger) byte sectors; but some hardware supports emulation of 512 byte sectors for legacy systems. There are exceptions, the Samsung 840 EVO SSD has blocks of size 2048 KB.



        An Error Correcting Code (ECC) is calculated for each 512 byte chunk, and as you can imagine, ECC data also requires storage space. It goes without saying that one 4096 byte sector requires less ECC information than eight 512 byte chunks if the ECC algorithms remain unchanged. In the end, the total storage capacity of a hard drive increases as a result of less ECC data overhead.



        Using 4K sectors makes sense from an architectural standpoint, as other key figures (like x86 memory pages and many file system clusters) also employ the 4 KB size. The Advanced Format allows for more robust ECC algorithms, which is important in light of ever-increasing capacities. Controllers employ additional techniques beyond error correction through an understanding of the NAND flash memory error characteristics and the workload behavior.



        Advanced Format (AF) is any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that exceeds 512, 520, or 528 bytes per sector, such as the 4096, 4112, 4160, and 4224-byte (4 KB) sectors of an Advanced Format Drive (AFD). Larger sectors enable the integration of stronger error correction algorithms to maintain data integrity at higher storage densities.



        For SCSI (SAS) disks the RAID block size is larger than a JBOD block size due to the SCSI T10 standardized data integrity fields along with logical bad block checking stored on each block with the data. The SAS RAID adapters support disk blocks based on 512 Bytes of data or 4K Bytes of data. The RAID block size for the 512 disks is 528 Bytes per sector and the RAID block size for the 4K disks is 4224 bytes per sector.



        Because you are writing to memory and not a spinning disk physical sector size has less effect than ensuring that your partitions are aligned with the erase block size. Even so it's best to have up to date software and hardware, and use 4K sector size.



        The larger sector size is recommended by Intel - "Gain Optimal Performance by Changes to SSD Physical Sector Size".






        share|improve this answer














        Is the default 512 byte physical sector size appropriate for SSD disks under Linux?



        Both of my disks are SSDs and AFAIK SSD disks require a sector size of 4K. Is this OK or am I missing something?




        Old hardware and Operating Systems used 512 byte sectors, since 2011 (almost) all storage hardware has 4096 (or larger) byte sectors; but some hardware supports emulation of 512 byte sectors for legacy systems. There are exceptions, the Samsung 840 EVO SSD has blocks of size 2048 KB.



        An Error Correcting Code (ECC) is calculated for each 512 byte chunk, and as you can imagine, ECC data also requires storage space. It goes without saying that one 4096 byte sector requires less ECC information than eight 512 byte chunks if the ECC algorithms remain unchanged. In the end, the total storage capacity of a hard drive increases as a result of less ECC data overhead.



        Using 4K sectors makes sense from an architectural standpoint, as other key figures (like x86 memory pages and many file system clusters) also employ the 4 KB size. The Advanced Format allows for more robust ECC algorithms, which is important in light of ever-increasing capacities. Controllers employ additional techniques beyond error correction through an understanding of the NAND flash memory error characteristics and the workload behavior.



        Advanced Format (AF) is any disk sector format used to store data on magnetic disks in hard disk drives (HDDs) that exceeds 512, 520, or 528 bytes per sector, such as the 4096, 4112, 4160, and 4224-byte (4 KB) sectors of an Advanced Format Drive (AFD). Larger sectors enable the integration of stronger error correction algorithms to maintain data integrity at higher storage densities.



        For SCSI (SAS) disks the RAID block size is larger than a JBOD block size due to the SCSI T10 standardized data integrity fields along with logical bad block checking stored on each block with the data. The SAS RAID adapters support disk blocks based on 512 Bytes of data or 4K Bytes of data. The RAID block size for the 512 disks is 528 Bytes per sector and the RAID block size for the 4K disks is 4224 bytes per sector.



        Because you are writing to memory and not a spinning disk physical sector size has less effect than ensuring that your partitions are aligned with the erase block size. Even so it's best to have up to date software and hardware, and use 4K sector size.



        The larger sector size is recommended by Intel - "Gain Optimal Performance by Changes to SSD Physical Sector Size".







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered May 21 at 6:05









        RobRob

        1316 bronze badges




        1316 bronze badges






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Ask Ubuntu!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1144535%2fis-the-default-512-byte-physical-sector-size-appropriate-for-ssd-disks-under-lin%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            He _____ here since 1970 . Answer needed [closed]What does “since he was so high” mean?Meaning of “catch birds for”?How do I ensure “since” takes the meaning I want?“Who cares here” meaningWhat does “right round toward” mean?the time tense (had now been detected)What does the phrase “ring around the roses” mean here?Correct usage of “visited upon”Meaning of “foiled rail sabotage bid”It was the third time I had gone to Rome or It is the third time I had been to Rome

            Bunad

            Færeyskur hestur Heimild | Tengill | Tilvísanir | LeiðsagnarvalRossið - síða um færeyska hrossið á færeyskuGott ár hjá færeyska hestinum