12

Apparently, ntfs.mkfs counts one byte less when checking if the block device is large enough; or I have made some kind of mistake.

After creating a partition of 2048 512-byte sectors (exactly 1MiB total) on a GPT disk image file, I tried to make an NTFS filesystem on that partition. I ran

losetup my_image.img -f --show --offset $((2048 * 512))  # 2048 is the offset of the partiton
mkfs.ntfs /dev/loop0

. But mkfs.ntfs gave the following text:

The partition start sector was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. The number of sectors per track was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. The number of heads was not specified for /dev/loop0 and it could not be obtained automatically. It has been set to 0. Device is too small (1023kiB). Minimum NTFS volume size is 1MiB.

Basically counts one byte less than it should. And it is not a problem with the disk partitioning, as there can be no 1 byte error there. I know that this is not the proper way to do this, but I am more interested to know why this happens or what I am doing wrong. p.s. I also resized the partition explicitly to 1MiB in fdisk, so the problem isn't there.

1 Answer 1

16

It doesn’t count one byte less, it counts at least 512 bytes less —mkfs.ntfs reserves at least 512 bytes for a backup boot sector:

Reserve the last sector for the backup boot sector unless the sector size is less than 512 bytes in which case reserve 512 bytes worth of sectors.

So your 1MiB partition ends up with 2047 usable sectors, not 2048, and the volume ends up being too small for an NTFS volume. If you create a partition that’s 1049088 bytes in size, mkfs.ntfs will create an NTFS volume on it.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.