LinuxQuestions.org
Review your favorite Linux distribution.
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, 01: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 01:58 PM.
 
Old 02-07-2016, 02:12 PM   #2
BW-userx
Senior Member
 
Registered: Sep 2013
Location: MID-SOUTH USA
Distribution: Void Linux / Slackware 14.2
Posts: 2,091

Rep: Reputation: Disabled
Parted Instruction Manaual'
 
Old 02-07-2016, 02:13 PM   #3
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,872

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, 02:22 PM   #4
hydrurga
Senior Member
 
Registered: Nov 2008
Distribution: Linux Mint 18 MATE
Posts: 1,212

Rep: Reputation: 341Reputation: 341Reputation: 341Reputation: 341
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, 09: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, 08:41 PM   #6
JeremyBoden
Member
 
Registered: Nov 2011
Posts: 939

Rep: Reputation: 174Reputation: 174
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, 09: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, 06:24 AM   #8
hydrurga
Senior Member
 
Registered: Nov 2008
Distribution: Linux Mint 18 MATE
Posts: 1,212

Rep: Reputation: 341Reputation: 341Reputation: 341Reputation: 341
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, 02: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, 04:33 PM   #10
hydrurga
Senior Member
 
Registered: Nov 2008
Distribution: Linux Mint 18 MATE
Posts: 1,212

Rep: Reputation: 341Reputation: 341Reputation: 341Reputation: 341
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 03:45 PM
[SOLVED] Block Sizes billvance Linux - Newbie 11 09-16-2013 03:39 AM
Set custom block sizes (512-4096 bytes) in Gparted? permissive Linux - General 5 08-23-2013 05:27 AM
Anyone has experience running parted on raid device with LVM ? jkl555 Linux - Newbie 3 03-28-2011 10:09 PM
changing block sizes on mount djgerbavore Slackware 2 05-30-2005 10:12 PM


All times are GMT -5. The time now is 12:58 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration