[SOLVED] How to format block sizes of 4026 from a 50GB device using parted?
Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.