LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to format block sizes of 4026 from a 50GB device using parted? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-format-block-sizes-of-4026-from-a-50gb-device-using-parted-4175571655/)

MrTux 02-07-2016 12:57 PM

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?

BW-userx 02-07-2016 01:12 PM

Parted Instruction Manaual'

Emerson 02-07-2016 01:13 PM

Quote:

Originally Posted by MrTux (Post 5496688)
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?

You are a little bit off here, none of these commands perform format, when we talk formatting we mean creating a filesystem.

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.

hydrurga 02-07-2016 01:22 PM

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.

MrTux 02-07-2016 08:29 PM

What if there were no filesystem constraint? How would I go about accomplishing 4096 block size?

JeremyBoden 02-08-2016 07:41 PM

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.

MrTux 02-08-2016 08:29 PM

I just did some research and found out


mkfs.ext4 -b 4096 /dev/sdb2

Or if already formatted do

blockdev -setbsz 4096 /dev/sdb2

hydrurga 02-09-2016 05:24 AM

Quote:

Originally Posted by MrTux (Post 5497332)
I just did some research and found out


mkfs.ext4 -b 4096 /dev/sdb2

Or if already formatted do

blockdev -setbsz 4096 /dev/sdb2

It's up to you of course whether you mark a thread as solved but I don't consider your original question solved at all (and I was intrigued to learn the answer ;-)).

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.
As far as I am aware, once your ext filesystem has been created, you can't change the size of the blocks, although you could certainly play around with block clusters (bigalloc) if you had a lot of large files and wanted to simulate the effects of a large block size.

MrTux 02-09-2016 01:13 PM

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.

hydrurga 02-09-2016 03:33 PM

Quote:

Originally Posted by MrTux (Post 5497658)
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.

How would you do that in udevadm? You do realize that you're not actually changing the underlying filesystem with blockdev, as far as I am aware, you're just changing how you handle it on the system you use the blockdev command on.

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.