LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This 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


Reply
  Search this Thread
Old 02-07-2016, 12:57 PM   #1
MrTux
Member
 
Registered: Dec 2015
Posts: 131

Rep: Reputation: Disabled
Post 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?

Last edited by MrTux; 02-07-2016 at 12:58 PM.
 
Old 02-07-2016, 01:12 PM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Parted Instruction Manaual'
 
Old 02-07-2016, 01:13 PM   #3
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
Quote:
Originally Posted by MrTux View Post
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.
 
Old 02-07-2016, 01:22 PM   #4
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
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.
 
Old 02-07-2016, 08:29 PM   #5
MrTux
Member
 
Registered: Dec 2015
Posts: 131

Original Poster
Rep: Reputation: Disabled
What if there were no filesystem constraint? How would I go about accomplishing 4096 block size?
 
Old 02-08-2016, 07:41 PM   #6
JeremyBoden
Senior Member
 
Registered: Nov 2011
Location: London, UK
Distribution: Debian
Posts: 1,947

Rep: Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511Reputation: 511
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.
 
Old 02-08-2016, 08:29 PM   #7
MrTux
Member
 
Registered: Dec 2015
Posts: 131

Original Poster
Rep: Reputation: Disabled
I just did some research and found out


mkfs.ext4 -b 4096 /dev/sdb2

Or if already formatted do

blockdev -setbsz 4096 /dev/sdb2
 
Old 02-09-2016, 05:24 AM   #8
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by MrTux View Post
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.
 
Old 02-09-2016, 01:13 PM   #9
MrTux
Member
 
Registered: Dec 2015
Posts: 131

Original Poster
Rep: Reputation: Disabled
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.
 
Old 02-09-2016, 03:33 PM   #10
hydrurga
LQ Guru
 
Registered: Nov 2008
Location: Pictland
Distribution: Linux Mint 21 MATE
Posts: 8,048
Blog Entries: 5

Rep: Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925Reputation: 2925
Quote:
Originally Posted by MrTux View Post
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).
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Targetcli on block device looses configuration after reboot (device already in use) dimitrisz Linux - Server 0 10-11-2014 02:45 PM
[SOLVED] Block Sizes billvance Linux - Newbie 11 09-16-2013 02:39 AM
Set custom block sizes (512-4096 bytes) in Gparted? permissive Linux - General 5 08-23-2013 04:27 AM
Anyone has experience running parted on raid device with LVM ? jkl555 Linux - Newbie 3 03-28-2011 09:09 PM
changing block sizes on mount djgerbavore Slackware 2 05-30-2005 09:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration