How to successfully change blocksize of disk on Azure?

Michał Czajkowski 0 Reputation points
2025-02-22T08:45:57.4733333+00:00

Im trying to change blocksize on Azure disk, to store multiple small files:

sudo mkfs -t ext4 -b 1024 /dev/sdd

Warning: specified blocksize 1024 is less than device physical sectorsize 4096 Discarding device blocks: done Creating filesystem with 268435456 1k blocks and 16777216 inodes Filesystem UUID: ***************************** Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409, 663553, 1024001, 1990657, 2809857, 5120001, 5971969, 17915905, 19668993, 25600001, 53747713, 128000001, 137682945, 161243137

Allocating group tables: done Writing inode tables: done Creating journal (262144 blocks): done Writing superblocks and filesystem accounting information: done

Looks more or less ok, but when checked :

azureuser@***************:~$ sudo blockdev --getbsz /dev/sdd

4096

Any workaround ?

Azure Disk Storage
Azure Disk Storage
A high-performance, durable block storage designed to be used with Azure Virtual Machines and Azure VMware Solution.
664 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vinodh247 28,371 Reputation points MVP
    2025-02-22T10:07:07.33+00:00

    Hi ,

    Thanks for reaching out to Microsoft Q&A.

    You are facing an issue where Azure disks enforce a physical sector size of 4096 bytes, which overrides your attempt to set a smaller block size (1024 bytes). The problem is that Azure-managed disks are based on SSDs, and most modern SSDs use 4K sectors natively, which makes it difficult to force a smaller block size.

    Workarounds & Solutions:

    Use a Loopback Device with a Smaller Blocksize

    Instead of formatting the disk directly, you can create a file-backed loop device that supports a 1024-byte block size

    Consider XFS Instead of EXT4

    If your goal is efficient storage of small files, XFS might be a better choice than EXT4 with a smaller block size, since it handles small files better due to its inode clustering.

    Use Filesystem-Level Optimizations

    If your goal is to store many small files efficiently, you can also tweak inode settings while formatting. This will optimize for smaller file sizes without changing the block size.

    Please feel free to click the 'Upvote' (Thumbs-up) button and 'Accept as Answer'. This helps the community by allowing others with similar queries to easily find the solution.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.