Partition misalignment on Windows+Linux dual boot

Discussion in 'all things UNIX' started by act8192, Feb 28, 2018.

  1. act8192

    act8192 Registered Member

    Joined:
    Nov 9, 2006
    Posts:
    1,789
    When I added Mint to Windows7 and 10, I told gparted to use cylinder alignment for Mint partitions. Looks like a big mistake of which effect I do not feel.
    Googling informs me that cylinder is for XP and/or old drives. Should've used MiB.
    I don't know what alignment original Windows 7 had. I suspect not cylinder. Drive I now use is a reimaged replacement.
    It's MBR on standard laptop spinner drive. Looks like logical/physical sectors are 512/4096 bytes.

    Problem: My extended partition is misaligned, but Windows volumes within it are OK.
    All three Mint partitions are misaligned. Mint says they don't start on physical sector boundary.

    How can I fix it without disturbing system_drv, Windows partitions and functions, grub2 booting it all?
    I've collected Windows sector info plus gparted screenie and fdisk info. Will they be helpful?
     
  2. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
  3. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
    If you want to align one of the Mint partitions to confirm there is no performance difference, let's do it. Or just leave it alone.
     
  4. act8192

    act8192 Registered Member

    Joined:
    Nov 9, 2006
    Posts:
    1,789
    Interesting Terabyte info, thank you.
    - I'd like to take a shot at it to learn if you're willing to hold my hand :). Might need it in the future if I were to go to SSD for instance.
    - But I must not ruin anything dealing with booting(via grub) and Windows since I do not have a sandbox computer.
    - I'm on Mint 18.3, freshly installed Jan.1, 12g RAM.
    - What should I time/observe to get an idea of performance? The only observable delays I now see is restarting to Mint, starting Vivaldi, and loading excel workbook from Windows(on sda5) into LibreOffice. Otherwise things happen as I click on them.
    - Can changing alignment be done in gparted? I hope it can. I'd prefer it over magical incantations in the terminal.
    - Will I need to edit grub-something when doing this?
    - Mint details:
    Between sda3 and 4 is unallocated gap of 6142 sectors (3.00MiB)- but Windows data partitions sda5 and 6 are OK, as are sda1,2,3.
    Between sda6 and 7 is unallocated gap of 11613 sectors (5.67MiB)- and the 3 Mint partitions aren't aliigned.
     
  5. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
    Let's fix the Linux partition where you are likely to see a measurable change. The principle of alignment fixing is to resize the partition so there is free space after the partition so the partition can slide.

    So, set the 1 MiB alignment option. Resize the partition to make it 5 MiB smaller. This creates 5 MiB of Free Space after the partition. This is fast.

    Slide (Move) the partition by changing the 5 MiB of Free Space following the partition to 2 MiB. Sliding with GParted is very slow. Maybe an hour or more. Now the start of the partition is 1 MiB aligned. There will be a few MiB of Free Space in front of the partition. Leave it alone.

    Resize the partition again so there is 1 MiB (or 2 or 3) of Free Space following the partition. This isn't essential but it will align the end of the partition.

    Success?
     
    Last edited: Mar 2, 2018
  6. act8192

    act8192 Registered Member

    Joined:
    Nov 9, 2006
    Posts:
    1,789
    1. Can you explain one thing, please. How come we're changing the right side (after) back and forth, when I would think that the start of the sda7 /root partition with all that unallocated 5.7MiB caused the trouble?
    2. Repeat the same procedure on swap and home?
    Powerful wind and snow storm is preventing me from doing it rightaway. The power keeps going out and I'd rather not do the brain surgery under the batteries. But it gives me time to think so not all is lost.
     
  7. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
    I missed that. As you already have Free Space in front of the partition reduce it to 1 MiB by sliding. You would think zero is ideal but sometimes it doesn't work. Now you will have Free Space in front of Swap so reduce it to 1 MiB by sliding. Now you will have Free Space in front of the final Linux partition so reduce it to 1 MiB by sliding. If the 3 partitions are 1 MiB aligned you could align the ends of the partitions but this is cosmetic and not for performance.

    Good idea about the power. Wait!!!!!!
     
  8. act8192

    act8192 Registered Member

    Joined:
    Nov 9, 2006
    Posts:
    1,789
    Success! Big THANK YOU :)
    View before and after in pictures
    Before
    DiskView-Before.png
    After
    DiskView-AfterMiB.png

    and fdisk new sector numbers:
    Mint partitions now have 1MiB before each and whatever small amounts after.
    The only thing I had to do extra was to do "swap off" before I could move the empty swap partition, and set it back after.

    Can't yet tell performance difference. So far everything I tried is fast as was before, EXCEPT BOOTING to Mint. It used to be about 30 seconds, now it's 1min50sec. Why would that be? Would updating grub help?

    When gparted was shifting the data it was doing it in 16MiB blocks. Surprise?
     
  9. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
    That's annoying. I don't know why Mint boots slower than before.
     
  10. act8192

    act8192 Registered Member

    Joined:
    Nov 9, 2006
    Posts:
    1,789
    Good news.
    From several posts in google school I learned that resizing/moving partitions might cause the looooong startup.
    Turns out that swap file's UUID gets changed. Display from 'sudo blkid' shows current UUID, which has to be copied (elevated) into 'etc/fstab' which showed UUID from the time of installation. (I preserved original fstab just in case. It's read-only). I guess gparted forgets to synch it with reality.

    From selecting Mint to login screen the startup time dropped from almost 2 minutes back to 28-29 seconds :)
     
  11. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
    Nice work. Thanks for the explanation.
     
  12. oliverjia

    oliverjia Registered Member

    Joined:
    Jul 21, 2005
    Posts:
    1,926
    care to report to GParted dev regarding this bug?
     
  13. act8192

    act8192 Registered Member

    Joined:
    Nov 9, 2006
    Posts:
    1,789
    I am not comfortable telling gparted dev. I don't know if it's a bug or feature that's been around for many years. My mention of "I guess gparted forgets to synch it with reality" is my conclusion from my baby steps in Linux. Might be presumptuous.
    It would be best if someone with a contact to the dev, or an expert, talked to gparted instead of me. Please.

    Just few links about UUIDs and resizing/moving that made me try it:
    https://forums.linuxmint.com/viewtopic.php?t=245195
    https://askubuntu.com/questions/625072/deleted-swap-now-boot-takes-forever
    https://forums.linuxmint.com/viewtopic.php?t=249833
    http://random.christopher.su/ubuntu-boot-slow-after-resizing-partition
    https://forums.linuxmint.com/viewtopic.php?t=242867
    post 6 by K0lO: https://www.wilderssecurity.com/threads/ubuntu-wont-boot-after-partitions-moved.244991/
     
  14. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
    Out of interest I created a Mint install with ESP, Root and Swap as cylinder aligned partitions on a GPT disk (SSD). An image was created so BIBM and GParted could be used in turn.

    Both apps were used to Slide (Move) the partitions to create 1 MiB alignment. GParted couldn't slide the ESP so it remained cylinder aligned for the GParted test.

    Boot time while cylinder aligned and after 1 MiB alignment with BIBM or GParted was 7 seconds. No difference. I didn't test a MBR Disk.
     
  15. act8192

    act8192 Registered Member

    Joined:
    Nov 9, 2006
    Posts:
    1,789
    Brian, Interesting.
    If you still have that Mint installed, could you check if your etc/fstab uses UUID notation of labels? Just curious.
    And what is ESP?
    Is your Mint 18.3 like mine?
     
  16. Brian K

    Brian K Imaging Specialist

    Joined:
    Jan 28, 2005
    Posts:
    12,183
    Location:
    NSW, Australia
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.