LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 08-10-2017, 09:41 PM   #1
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Rep: Reputation: 177Reputation: 177
alignment is offset by 512 bytes. This may result in very poor performance


I just created and formatted a 5TB drive:
Code:
# parted /dev/sde mklabel gpt
# parted -a opt /dev/sde mkpart primary 0% 5000G
fdisk gives:
Code:
# mkfs.ext4 /dev/sde1
Disk /dev/sde: 4.6 TiB, 5000981077504 bytes, 9767541167 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 33553920 bytes
Disklabel type: gpt
Disk identifier: 95E1A3B8-DC2A-4FE6-B523-185BB88396DD

Device     Start        End    Sectors  Size Type
/dev/sde1  65535 9765632489 9765566955  4.6T Linux filesystem
Partition 1 does not start on physical sector boundary.
when I went to format, I got:
Code:
# mkfs.ext4 /dev/sde1
mke2fs 1.43.1 (08-Jun-2016)
/dev/sde1 alignment is offset by 512 bytes.
This may result in very poor performance, (re)-partitioning suggested.
It formatted successfully, but I'm concerned about the performance warning. How would I better re-partition as suggested?
 
Old 08-10-2017, 09:56 PM   #2
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Code:
Device     Start        End    Sectors  Size Type
/dev/sde1  65535 9765632489 9765566955  4.6T Linux filesystem
Partition 1 does not start on physical sector boundary.
I think that happens because sector 65535 is not a multiple of 8, 65536 is. Start the partition at sector 4096 or 2048. I have a 3TB HDD with one partition starting at sector 2048, and never got that message when I created the partition:

Code:
# fdisk -l /dev/sdc
Disk /dev/sdc: 2.7 TiB, 3000592982016 bytes, 5860533168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: D0070DA0-049B-4D51-8EB4-685954188CA2

Device     Start        End    Sectors  Size Type
/dev/sdc1   2048 5860533134 5860531087  2.7T Linux filesystem
 
Old 08-10-2017, 11:02 PM   #3
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
I've always used fdisk or gdisk, which now will automatically select the best starting point for the drive to make sure it is aligned (I think older versions of at least fdisk didn't do proper alignment on the relatively new 4k sectored disks). It seems that parted doesn't do that automatically (or at least not with the way you called it... there might be different options that will attempt proper alignment).

But that's interesting that mkfs catches the misalignment. I didn't know it did that.

To give more information on Diantre's post, if you look at the fdisk output, it shows that your physical sector size is 4096. That means you need to have all your partition splits be on multiples of 4096. If you divide 65535 (your starting sector) by 4096, you get 15.9997, which means it's not properly aligned. For it to be aligned, you'd want it in multiples of 4096. So if we take 4096 and multiply it by 16 (which that first space is typically reserved for the partition table), you get the 65535 sector that Diantre provided.

However, using multiples of 8 could hurt because it may still not be aligned by the 4096 sector size, you want to make sure it is in multiples of your physical sector size, which in the case of this drive, is 4096.
 
Old 08-10-2017, 11:58 PM   #4
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
Quote:
Originally Posted by Diantre View Post
[CODE]I think that happens because sector 65535 is not a multiple of 8, 65536 is. Start the partition at sector 4096 or 2048. I have a 3TB HDD with one partition starting at sector 2048, and never got that message when I created the partition:
So, in my parted command, for the offset I have "0%" (I just monkey-typed from an example). Should I explicitly set that to 4096? E.g.:
Code:
# parted -a opt /dev/sde mkpart primary 4096 5000G
The man page has:
Quote:
mkpart part-type [fs-type] start end
Make a part-type partition for filesystem fs-type (if specified), beginning at start and ending at end (by
default in megabytes). part-type should be one of "primary", "logical", or "extended".
I read this as the start/end parameters are in megabytes, not sectors. Confused!

Supposedly, the "-a opt" parameter is supposed to "aligns to a multiple of the physical block size in a way that guarantees optimal performance." But I guess it's not doing that!

Last edited by mfoley; 08-11-2017 at 12:04 AM.
 
Old 08-11-2017, 12:42 AM   #5
bassmadrigal
LQ Guru
 
Registered: Nov 2003
Location: West Jordan, UT, USA
Distribution: Slackware
Posts: 8,792

Rep: Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656Reputation: 6656
I've never used parted, but from what I've read online, it seems like your command should've worked and provided the proper alignment. I don't know why it didn't. That might be something to raise to the parted developers. In the meantime, it may be wise to use something like gdisk to partition your drive as I've never had alignment issues with that.
 
Old 08-11-2017, 12:55 AM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,126

Rep: Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120Reputation: 4120
I have vague memories of 0% not doing what it might be imagined to. I think if you do it interactively (with -a opt) it'll tell you what to use. Try 1M.
 
Old 08-11-2017, 12:59 AM   #7
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
I've never used parted either, but after reading the manual, I think the command should be:

Code:
parted -a optimal /dev/sde mkpart primary 4096s 5000GB
Sometimes I like to try these things in a VM, just to be sure I'm understanding the tool, it's easy to get confused.
 
1 members found this post helpful.
Old 08-11-2017, 01:30 AM   #8
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
I tried parted interactively:
Code:
(parted) select /dev/sde                                                  
Using /dev/sde
(parted) align-check opt                                                  
Partition number? 1                                                       
1 aligned
(parted) print                                                            
Model: Seagate BUP SL (scsi)
Disk /dev/sde: 5001GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name     Flags
 1      33.6MB  5000GB  5000GB  ext4         primary
The align-check says it's aligned. The `print` shows the start at 33.6M. When I tried "1M" manually, it said the closet offset would be 33.6M - did I want to try that.

Maybe it's OK after all? Hmmmm ...

running gdisk and taking defaults gives me a starting sector of 40:
Code:
Command (? for help): p
Disk /dev/sde: 9767541167 sectors, 4.5 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 95E1A3B8-DC2A-4FE6-B523-185BB88396DD
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 9767541133
Partitions will be aligned on 8-sector boundaries
Total free space is 6 sectors (3.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40      9767541133   4.5 TiB     8300  Linux filesystem
There is a job running against this drive at the moment, but perhaps I'll try the gdisk settings tomorrow and see what happens.
 
Old 08-11-2017, 09:16 AM   #9
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,779

Rep: Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212Reputation: 2212
Quote:
Originally Posted by bassmadrigal View Post
To give more information on Diantre's post, if you look at the fdisk output, it shows that your physical sector size is 4096. That means you need to have all your partition splits be on multiples of 4096. If you divide 65535 (your starting sector) by 4096, you get 15.9997, which means it's not properly aligned. For it to be aligned, you'd want it in multiples of 4096. So if we take 4096 and multiply it by 16 (which that first space is typically reserved for the partition table), you get the 65535 sector that Diantre provided.

However, using multiples of 8 could hurt because it may still not be aligned by the 4096 sector size, you want to make sure it is in multiples of your physical sector size, which in the case of this drive, is 4096.
That "4096" physical sector size is in bytes. The "65535" starting offset is in units of 512-byte logical sectors. You just need the starting offset to be a multiple of 8. (8*512 = 4096)
 
Old 08-11-2017, 09:50 AM   #10
mfoley
Senior Member
 
Registered: Oct 2008
Location: Columbus, Ohio USA
Distribution: Slackware
Posts: 2,555

Original Poster
Rep: Reputation: 177Reputation: 177
OK, I repartitioned the disk using gdisk and took the defaults:
Code:
# gdisk -l /dev/sde
GPT fdisk (gdisk) version 1.0.0

Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present

Found valid GPT with protective MBR; using GPT.
Disk /dev/sde: 9767541167 sectors, 4.5 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 95E1A3B8-DC2A-4FE6-B523-185BB88396DD
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 9767541133
Partitions will be aligned on 8-sector boundaries
Total free space is 6 sectors (3.0 KiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              40      9767541133   4.5 TiB     8300  Linux filesystem
It put the starting sector at 40 (40* 512 = 20480). I got no warnings about alignment issues either from gdisk or mkfs.

I didn't know about gdisk and have been using parted for my GPT drives. gdisk is great! Works just like fdisk and is therefore familiar and less complex that parted. Plus, it apparently works better and doesn't create mis-aligned sectors by default!
 
Old 12-29-2017, 06:53 PM   #11
MykeC
LQ Newbie
 
Registered: Dec 2017
Posts: 2

Rep: Reputation: Disabled
[SOLVED] alignment is offset by 512 bytes. This may result in very poor performance

I encountered this same weird issue this evening when attempting format a brand new, pre-NTSC-formatted 8TB Seagate external USB HD using Linux Mint 18.1.

Notice how the error occurred when I targeted "/dev/sdc1" (i.e. the 1st partition on the drive) but the error does not occur when I target simply "/dev/sdc" (i.e. the whole drive itself).

Code:
$ sudo mkfs.ext4 -T largefile4 -L 'The Sweet Stuff' /dev/sdc1
mke2fs 1.42.13 (17-May-2015)
/dev/sdc1 alignment is offset by 3072 bytes.
This may result in very poor performance, (re)-partitioning suggested.
Code:
$ sudo mkfs.ext4 -T largefile4 -L 'The Sweet Stuff' /dev/sdc
mke2fs 1.42.13 (17-May-2015)
Creating filesystem with 1953506645 4k blocks and 1907744 inodes
Filesystem UUID: a00ea132-b188-404d-af6f-8ca0451e0d1d
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
	102400000, 214990848, 512000000, 550731776, 644972544, 1934917632

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
 
  


Reply

Tags
alignment, parted, partition



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
Is it okay if my sector size is "512 bytes / 4096 bytes" Altiris Slackware 5 07-31-2015 03:19 AM
Set custom block sizes (512-4096 bytes) in Gparted? permissive Linux - General 5 08-23-2013 04:27 AM
Why MBR is limited to 512 bytes? RaviTezu Linux - Newbie 8 11-21-2012 07:47 AM
iSCSI write performance very poor while read performance is excellent dinominant Linux - Server 1 10-10-2012 10:51 AM
Software Raid 6 - poor read performance / fast write performance Kvothe Linux - Server 0 02-28-2011 03:11 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 10:57 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
Open Source Consulting | Domain Registration