How to format block sizes of 4026 from a 50GB device using parted?
So I recently got asked this question on a test (LFCS) and I am wondering how to go about it?
I know that the basic command for just formating is: parted -s /dev/sdb mklabel gpt parted -s /dev/sdb mkpart primary ext4 0 52000000 How do I make it so it uses blocks of 4026? |
Parted Instruction Manaual'
|
Quote:
First command creates a partition table, second command creates a partition. Blocksize is a parameter of filesystem - which is not created by these two commands. |
As far as I'm aware, ext4 will only support block sizes that are powers of 2 between 1KiB and 64KiB. You may have some difficulty creating 4026-byte blocks on an ext4 filesystem.
|
What if there were no filesystem constraint? How would I go about accomplishing 4096 block size?
|
Modern disks operate with a physical low-level format of 4096 bytes.
They are able to report a 512 byte logical format, for compatibility with old software. Everytime you write a 512 byte block the disk reads 4096 bytes, alters the appropriate 512 bytes and then rewrites the whole 4096 bytes. I assume, if you found a file system that could use 4026 byte blocks, it would just zero fill the last 70 bytes of each 4096 byte block. |
I just did some research and found out
mkfs.ext4 -b 4096 /dev/sdb2 Or if already formatted do blockdev -setbsz 4096 /dev/sdb2 |
Quote:
Why? Well, firstly you asked about a block size of 4026, which I now assume was a mistake on your part. Secondly you asked for a solution using parted. The solution you have offered, using mkfs.ext4, is the obvious one and would have been suggested to you from the off if that is what you had asked. By the way, the blockdev solution is not correct. From the notes in one version of man blockdev: Code:
Note that the block size is specific to the current file descriptor opening the block device, so the change of block size only persists for as long as blockdev has the device open, and is lost once blockdev exits. |
To make it permanent, I just need to make a rule in udevadm.
You could have said that mkfs had a -b option for bit size of device. |
Quote:
You asked how you could format a filesystem with a specific block size using parted (see thread title). The answer to that wouldn't be how you can format it using mkfs (which sets the block size of a filesystem, not the bit size of a device). |
All times are GMT -5. The time now is 05:04 PM. |