Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
gentoo ships buggy parted implementation [solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Thu Nov 19, 2015 9:52 pm    Post subject: gentoo ships buggy parted implementation [solved] Reply with quote

I try to create a backup medium and therefore I recreate a partiton table on a new SSD.

The thing is, regardless what i do, regardless on how often I follow the gentoo handbook, parted complains, partition is not aligned.

Code:
parted -a optimal /dev/sdc


Should align the stuff

What I want:

Code:
sgdisk -p /dev/sda
Disk /dev/sda: 250069680 sectors, 119.2 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): ...
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 250069646
Partitions will be aligned on 2048-sector boundaries
Total free space is 4029 sectors (2.0 MiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048            6143   2.0 MiB     EF02  grub
   2            6144          268287   128.0 MiB   EF00  boot
   3          268288          530431   128.0 MiB   8300  reserved_for_future...
   4          530432       250067631   119.0 GiB   8300  root_filesystem


The old SSD has 128GB, the new one has 120GB.

I would prefer nearly the same values of the parititon. partition 4 should be the new root volume and should be aligned. regardless i am unable to find a value where parted would say, partition aligned.


Partition 3 should be 128MB or so for emergency junks when i need that. can be a bit bigger.

partition 4 should be proper aligned on that 120gb ssd.

Please give me some sort of advise, because parted only complains ...

I will try to read a bit the web on how to solve that.


Code:
parted -a optimal /dev/sdc                             
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3146kB  2097kB  ext4         primary  bios_grub
 2      3146kB  134MB   131MB   ext2         primary
 3      134MB   671MB   537MB                primary
 4      671MB   120GB   119GB                primary

(parted) rm 3
(parted) rm 4                                                             
(parted) mkpart 1% -1                                                     
parted: invalid token: -1
File system type?  [ext2]? ^C                                             
Error: Expecting a file system type.
(parted) mkpart primary 1% -1                                             
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel?           


--

a try with gparted to create a partition, align to MIB. parted says not aligned, sigh

Code:
parted -a optimal /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3146kB  2097kB  ext4         primary  bios_grub
 2      3146kB  134MB   131MB   ext2         primary
 3      268MB   120GB   120GB                         lvm

(parted) align-check                                                     
alignment type(min/opt)  [optimal]/minimal?                               
Partition number? 3                                                       
3 not aligned
(parted) quit 


--

Code:
gdisk /dev/sdc
GPT fdisk (gdisk) version 1.0.1

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

Found valid GPT with protective MBR; using GPT.

Command (? for help): x

Expert command (? for help): d
Partitions will begin on 2048-sector boundaries.

Expert command (? for help): q


Well here is the culprit, 2048 instead of the bigger 4096B value

--

Code:
blockdev --getbsz /dev/sdc4
4096
ASUS-G75VW roman # blockdev --getalignoff /dev/sdc4
0
ASUS-G75VW roman # parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3146kB  2097kB  ext4         primary  bios_grub
 2      3146kB  134MB   131MB   ext2         primary
 3      134MB   268MB   134MB                primary
 4      268MB   120GB   120GB                primary

(parted) quit                                                             
ASUS-G75VW roman #


Code:
parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) h                                                               
  align-check TYPE N                        check partition N for TYPE(min|opt) alignment
  help [COMMAND]                           print general help, or help on COMMAND
  mklabel,mktable LABEL-TYPE               create a new disklabel (partition table)
  mkpart PART-TYPE [FS-TYPE] START END     make a partition
  name NUMBER NAME                         name partition NUMBER as NAME
  print [devices|free|list,all|NUMBER]     display the partition table, available devices, free space, all found partitions, or a particular partition
  quit                                     exit program
  rescue START END                         rescue a lost partition near START and END
  resizepart NUMBER END                    resize partition NUMBER
  rm NUMBER                                delete partition NUMBER
  select DEVICE                            choose the device to edit
  disk_set FLAG STATE                      change the FLAG on selected device
  disk_toggle [FLAG]                       toggle the state of FLAG on selected device
  set NUMBER FLAG STATE                    change the FLAG on partition NUMBER
  toggle [NUMBER [FLAG]]                   toggle the state of FLAG on partition NUMBER
  unit UNIT                                set the default unit to UNIT
  version                                  display the version number and copyright information of GNU Parted
(parted) align-check 3
parted: invalid token: 3
alignment type(min/opt)  [optimal]/minimal? optimal                       
Partition number? 3                                                       
3 not aligned
(parted) quit


So is parted broken?


Last edited by Roman_Gruber on Wed Nov 25, 2015 2:13 am; edited 1 time in total
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1368
Location: Montréal

PostPosted: Fri Nov 20, 2015 2:46 am    Post subject: Reply with quote

Try an other Gpt partitions tool like Gdisk and see if the partitions are aligned.
_________________
Paul
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Fri Nov 20, 2015 10:02 am    Post subject: Re: problems aligning gpt / SSD Reply with quote

tw04l124 wrote:

Code:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3146kB  2097kB  ext4         primary  bios_grub
 2      3146kB  134MB   131MB   ext2         primary
 3      134MB   268MB   134MB                primary
 4      268MB   120GB   120GB                primary


Switch unit to s, and look that your sectors are starting at a value you can divide per 8.
I think parted should do that, but you are confusing parted yourself with misuse of mkpart

Code:
(parted) mkpart 1% -1                                                     

if that 1% is taken from start of disk, that's a weird value to gives
if that 1% is taken from "next free area", then you better use 0% -> 100% as numbers

I would then create it with mkpart 0% 100%
And if it is from start of disk, mkpart 268MB 100%
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Fri Nov 20, 2015 3:09 pm    Post subject: Reply with quote

Okay thanks, I will try with the s unit of parted. And I will report back.

Honestly I tried around a lot.

the web claims that parted tool is right when it says it is not aligned and blockdev is broken, according to arch wiki


I am not sure, but I think mkpart things is a command of parted. I do not use that quite often. I just copied over the cli output.

and that %1 till to the end with -1 was just something i tried out.

I tried several ways not sure if i tried with s, but i will do that.

It just annoys me that there is no align mode of parted, or it is broken. or i am just unable to utilize it.

Only root the last biggest partitiotn needs to be aligned i do not care for other partitions.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Fri Nov 20, 2015 3:33 pm    Post subject: Reply with quote

Code:
parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3146kB  2097kB  ext4         primary  bios_grub
 2      3146kB  134MB   131MB   ext2         primary
 4      134MB   268MB   134MB
 3      268MB   120GB   120GB                         lvm

(parted) unit s
(parted) print
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 234441648s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start    End         Size        File system  Name     Flags
 1      2048s    6143s       4096s       ext4         primary  bios_grub
 2      6144s    262143s     256000s     ext2         primary
 4      262144s  524287s     262144s
 3      524288s  234440703s  233916416s                        lvm

(parted) align-check 3                                                   
parted: invalid token: 3
alignment type(min/opt)  [optimal]/minimal?                               
Partition number? 3                                                       
3 not aligned
(parted) rm 3
(parted) mkpart primary 524288 234440696                                 
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore                                                     
(parted) align-check 3                                                   
parted: invalid token: 3
alignment type(min/opt)  [optimal]/minimal?                               
Partition number? 3                                                       
3 not aligned
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 234441648s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start    End         Size        File system  Name     Flags
 1      2048s    6143s       4096s       ext4         primary  bios_grub
 2      6144s    262143s     256000s     ext2         primary
 4      262144s  524287s     262144s
 3      524288s  234440696s  233916409s               primary

(parted) 


524288/8 = multiple

234440696/8 = multiple

do i miss something...

but the size may be an issue right?

233916409


Lets rephrase it, maybe I dit not grasp it.

Startsector has to be a multiple of 8.
And how about the size itself? same right? I assume the size has to be a multiple of 8 too right?
so the endsize can be anything right?
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Fri Nov 20, 2015 3:40 pm    Post subject: Reply with quote

I doubt gparted creates unaligned partiton.

When i choose align to MIB

https://en.wikipedia.org/wiki/Mebibyte

afaik MIB => a multiple of those 4k sectors which most drives use these days and also this ssd uses

so I do not get the comment of parted, its not aligned when i aligned to mib, and its 4k sectors

---

In the worst case it is not aligned but i do not care much anymore.

Regardless what i tried and read, parted complains. blockdev claims its aligned.
arch wiki says blockdev reports it wrong

Quote:
The mebibyte is a multiple of the unit byte for digital information.[1] The binary prefix mebi means 220, therefore one mebibyte is equal to 1048576bytes. The unit symbol for the mebibyte is MiB.


1048576/4096 = multiple = 256 afaik

i think parted is broken or something else the case

--

I will later destroy the hole partition and generate it with gparted and leave it that way than.

Than I will try to move on.

Thanks everyone
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Sat Nov 21, 2015 6:58 am    Post subject: Reply with quote

You didn't get why i ask you to use sector unit.

But you still can see a not align partition that looks good because of the range of MIB.

Here's a sample:
268MB is /8 but if you display sectors...
524287s is not, but you will see 268MB
524288s is align, again 268MB

So i have no doubt parted should and is doing it right ; but switching to sector, you can check by yourself it has/is doing it right.

If you look at all partitions where it doesn't complain, partition are all of /8 size.
So i doubt it's some luck, but more a need...

And if start sector is /8 and size must be also /8, it mean you cannot have an ending sector that is /8, as an ending /8 would mean size will not be /8
(parted) mkpart primary 524288 234440696
start : 524288 is /8 ok
end: 234440696 is /8 mean it's not ok
Don't get me wrong, having an end sector not /8 doesn't mean size will be /8 and valid. But if you gave it an end sector that is /8, you are just sure the size cannot end up /8 and will be invalid.

Just tried to ask something to gparted that it will answer for you instead.
mkpart 524288 100%
This way it will take what 100% is, and i think it will nicely pickup a good ending value for you.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Sat Nov 21, 2015 7:10 pm    Post subject: Reply with quote

Code:
parted /dev/sdc
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 120GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  3146kB  2097kB  ext4         primary  bios_grub
 2      3146kB  134MB   131MB   ext2         primary
 4      134MB   268MB   134MB
 3      268MB   120GB   120GB                primary

(parted) unit s
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 234441648s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start    End         Size        File system  Name     Flags
 1      2048s    6143s       4096s       ext4         primary  bios_grub
 2      6144s    262143s     256000s     ext2         primary
 4      262144s  524287s     262144s
 3      524288s  234440696s  233916409s               primary

(parted) rm 3                                                             
(parted) mkpart primary 524288 100%                                               
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore                                                     
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 234441648s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start    End         Size        File system  Name     Flags
 1      2048s    6143s       4096s       ext4         primary  bios_grub
 2      6144s    262143s     256000s     ext2         primary
 4      262144s  524287s     262144s
 3      524288s  234441614s  233917327s               primary

(parted) align-check 3                                                   
parted: invalid token: 3
alignment type(min/opt)  [optimal]/minimal?                               
Partition number? 3                                                       
3 not aligned
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 234441648s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start    End         Size        File system  Name     Flags
 1      2048s    6143s       4096s       ext4         primary  bios_grub
 2      6144s    262143s     256000s     ext2         primary
 4      262144s  524287s     262144s
 3      524288s  234441614s  233917327s               primary

(parted) quit                                                             
Information: You may need to update /etc/fstab.


I did as you suggested. I just assume i need that primary thing so i added it.

mkpart primary 524288 100%


It seems still not aligned ... TBH I have not really thought any further. Just checked any replies and did as you suggested.
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Sat Nov 21, 2015 7:14 pm    Post subject: Reply with quote

Code:
parted /dev/sdc                             
GNU Parted 3.2
Using /dev/sdc
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) unit s                                                           
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 234441648s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start    End         Size        File system  Name     Flags
 1      2048s    6143s       4096s       ext4         primary  bios_grub
 2      6144s    262143s     256000s     ext2         primary
 4      262144s  524287s     262144s
 3      524288s  234441614s  233917327s               primary

(parted) rm 3                                                             
(parted) mkpart primary 3 524288 234441608
Warning: You requested a partition from 3s to 524288s (sectors 3..524288).
The closest location we can manage is 34s to 2047s (sectors 34..2047).
Is this still acceptable to you?
parted: invalid token: 234441608                                         
Yes/No? ^C                                                               
(parted) mkpart primary 524288 234441608                               
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore                                                     
(parted) print                                                           
Model: ADplus SuperVer (scsi)
Disk /dev/sdc: 234441648s
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start    End         Size        File system  Name     Flags
 1      2048s    6143s       4096s       ext4         primary  bios_grub
 2      6144s    262143s     256000s     ext2         primary
 4      262144s  524287s     262144s
 3      524288s  234441608s  233917321s               primary

(parted) align-check                                                     
alignment type(min/opt)  [optimal]/minimal?                               
Partition number? 3                                                       
3 not aligned
(parted) quit                                                             
Information: You may need to update /etc/fstab.


why

29239665*8+524288 = 234441608

round down of last sector divided by 8 plus the startsector.
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2970
Location: Germany

PostPosted: Sat Nov 21, 2015 7:25 pm    Post subject: Reply with quote

Those partitions seem fine, they are all MiB aligned and that's the best you can do for any device.

The only strange thing here is the partition order (4 is located before 3), but that probably won't matter in practice (but it might cause confusion and in turn human error).

Easiest way to get alignment right in parted is to use unit mib for everything.

Code:

(parted) mkpart primary 1MiB 128MiB
(parted) mkpart primary 128MiB 512MiB
(parted) mkpart primary 512MiB 1024MiB                                   


Or you can use 'unit mib' first and then just use numbers w/o repeating MiB every time.

Just use MiB alignment which works for all devices (single exception: HDD with off-by-one jumper set, i.e. that horrendous solution that was supposed to make windows sector 63 aligned).

The align-check may give idiotic results (may claim aligned for unaligned partitions or vice versa). Just don't use that one.

If in doubt, use 'parted /dev/disk unit s print'. If start sector divides by 2048, it's MiB alignment (for 512 byte sectors). If it divides by 8, it's 4K alignment, which is fine too for 4K sector HDDs. If it's off-by-one you would notice...
Back to top
View user's profile Send private message
krinn
Watchman
Watchman


Joined: 02 May 2003
Posts: 7071

PostPosted: Mon Nov 23, 2015 5:13 am    Post subject: Reply with quote

maybe you have some bugs like frostschutz said, as i don't see why it doesn't create one align (and also that ending sector is not the range from 234441643 to 234441647s)
Back to top
View user's profile Send private message
Roman_Gruber
Advocate
Advocate


Joined: 03 Oct 2006
Posts: 3806
Location: Austro Bavaria

PostPosted: Wed Nov 25, 2015 2:09 am    Post subject: Reply with quote

So

I started my previous notebook, Asus g70sg, portage tree 7 october of 2015

alignmet check partitoin 3

and it says aligned.

conclusion:

my previous gentoo installation works

this gentoo installation has a broken parted implementation

both are from teh same source, i just reused the previous installation and adapted it.

means somewhere between 7th october till now parted got broken.

I did changed nothing. i created the partitions as suggestd by krinn. my asus g75vw says its not aligned. than i was upset and left it aside

now i plugged it in in my previous notebook with usb 2.0 instaed of usb 3.0 and an outdated gentoo installation. and it says aligned.

i doubt usb 3.0 is the cause !

--

Thanks krinn. Your input is appreciated.

--

Conclusio: Portage parted is broken as of now on this box, and i would say its broken on any gentoo ~amd64 installation.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum