[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: GPT and SSDs



On Mon, 19 May 2014 12:19:47 -0400
Gary Dale <garydale@torfree.net> wrote:

> On 19/05/14 09:04 AM, Henrique de Moraes Holschuh wrote:
> > On Mon, 19 May 2014, Gary Dale wrote:
> >> This led me into partitioning. I thought that GPT pretty much gave
> >> you proper partition alignment, but now I think I was mistaken on
> > Unfortunately, it doesn't :-(
> >
> >> that point. gdisk shows my first partition starting at 34, with the
> >> fdisk info showing 255 heads, 63 sectors/track. That doesn't come
> >> close to 4k alignment.
> > You're using a SSD.  You need 4KiB aligment, but you really want
> > erase-block alignment.  When in doubt, use the 1MiB default
> > alignment used by Debian (and most other Linux distros) and also by
> > MS Windows.
> >
> > Since Debian Wheezy, the Debian installer for x86 (i386 and amd64)
> > should have done this properly as long as you let it wipe any
> > preexisting partition tables (that might be incorrectly aligned).
> >
> > Unfortunately, the Debian installer for other arches (such as
> > powerpc) may be buggy and get it wrong (in fact, powerpc's
> > installer fails to align GPT partitions).
> >
> > BTW: you also need to align the data area of any LVM PVs (which
> > really can only be done at PV creation time), and create the
> > filesystem with the proper alignment for their internal
> > structures.  The debian installer for i386 and amd64 is known to do
> > this correctly, but YMMV on any of the other arches.
> >
> >> Before I haul out sysrescuecd and move my partitions around, I
> >> thought I'd ask for suggestions. Should I move the filesystem to
> >> something that is a multiple of 8, do something else, or look
> >> elsewhere for a solution to my problem?
> > Align everything to 1MiB (or, if you happen to know it, the erase
> > block size of your SSD, which will be a submultiple of 1MiB).
> >
> > You can ignore cylinder alignment: the BIOS would boot using LBA
> > information anyway and ignore the cylinder/sector/head crap, EFI
> > will grok the GPT natively, and you should not be letting any
> > operating systems old enought to not operate in LBA mode anywere
> > close to a raw device.
> >
> > Don't use half-assed tools to mess with the partitions.  Proper
> > tools known to get aligment right by default on Debian
> > stable/testing are: gdisk, cfdisk, mdadm, lvm, mke2fs (mkfs.ext4),
> > mkfs.xfs (for XFS).  "parted" gets it right only if you give it
> > fuzzy units (such as "0%" instead of "0" for the start of a
> > partition).  fdisk also aligns correctly when it is not trying to
> > be compatible with old DOS.
> When I use gparted with 1M alignment, it didn't change the 34 start 
> sector. In fact the only change was that gdisk now reports 2-sector 
> alignment:
> 
>    Found valid GPT with protective MBR; using GPT.
>    Disk /dev/sda: 234441648 sectors, 111.8 GiB
>    Logical sector size: 512 bytes
>    Disk identifier (GUID): 8017C70A-FA69-48DD-9227-825774B31816
>    Partition table holds up to 128 entries
>    First usable sector is 34, last usable sector is 234441614
>    Partitions will be aligned on 2-sector boundaries
>    Total free space is 911 sectors (455.5 KiB)
> 
>    Number  Start (sector)    End (sector)  Size       Code  Name
>       1              34       232343551   110.8 GiB   8300  Linux
> filesystem 2       232343552       234440703   1024.0 MiB  EF02
> 
> I then tried it by putting 1M free in front of the first partition.
> This changed the start sector to 4096, which is definitely on a 4k
> boundary, if slightly wasteful. This confirms your point that parted
> is somewhat flaky when dealing with alignments.

While slightly wasteful, in practice you don't want to fill up an SSD
anyway, and as a group they work best with no more than 75% of the disk
filled with data.

> Anyway, with this new alignment, my computer doesn't lock up for as 
> long. I'm still getting a few seconds here and there however. I have
> a network switch that may be going bad - my brother in law couldn't
> get it to work with his laptop, so maybe there's problem with it too.
> 

What mount options do you have for your SSD mounted partitions? I
vacilate on putting discard in mine, but currently I just have relatime
for /, and relatime,user_xattr for /home.  Discard will run the garbage
collection when you modify files, but after I install updates and I'm
ready to drop down to user I run 'fstrim -v /; fstrim -v /home; exit'.
The lock up that you're describing sounds like garbage collection
running.

-- 
Efraim Flashner    
efraim.flashner@gmail.com 4096R/CA3D8351 created: 2013-10-08
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351

Attachment: signature.asc
Description: PGP signature


Reply to: