From nobody@FreeBSD.org  Wed Jan 13 15:07:36 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 5ECF8106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 13 Jan 2010 15:07:36 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id F19048FC13
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 13 Jan 2010 15:07:35 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id o0DF7Zx1097115
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 13 Jan 2010 15:07:35 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id o0DF7ZEx097114;
	Wed, 13 Jan 2010 15:07:35 GMT
	(envelope-from nobody)
Message-Id: <201001131507.o0DF7ZEx097114@www.freebsd.org>
Date: Wed, 13 Jan 2010 15:07:35 GMT
From: Dan Naumov <dan.naumov@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: gpart should recognize NAND media and suggest partition alignment
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         142786
>Category:       bin
>Synopsis:       [request] [geom_part] gpart(8) should recognize NAND media and suggest partition alignment
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          suspended
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jan 13 15:10:01 UTC 2010
>Closed-Date:    
>Last-Modified:  Sun Sep 05 15:47:21 UTC 2010
>Originator:     Dan Naumov
>Release:        FreeBSD 8.0-RELEASE
>Organization:
>Environment:
>Description:
Due to the way most, if not all SSDs work, it is highly recommended the disk partitions be properly aligned to the NAND Erase Block Size. If this is not followed, it causes degraded random write performance, because instead of writing to 1 physical block, writes often have to be done to 2 blocks instead. As a additional consequence, this also has the effect of increasing the amount of writes to the SSD, increasing the wear and decreasing the usable lifetime of the SSD, because NAND has a finite limited amount of write cycles it can withstand. In additional to SSD disks, this same problem applies to more traditional Flash media, like USB memory sticks and CF cards.

Windows 7 and Windows Server 2008 R2 recognize this issue and when the installation process detects that Windows is being installed on an SSD disk, it automatically creates the first partition at a 1MB offset. Why 1MB? Different SSD manufacturers use different NAND Erase Block Sizes. Some use 512kb, some use 1Mb, making 1Mb the offset for the first partition work with both and is the best choice for having the compatibility with the biggest amount of SSDs on the market.

This is all relatively simple when only 1 single partition is used on the entire disk, because you only have to worry about the offset for that partition alone. However, the problem is magnified when it is intended to have multiple partitions on an SSD as ALL of them must be properly aligned to fit within the blocks "just right".

I believe that when starting to create a new partition table using gpart, gpart should ask the user whether the disk being accessed is a traditional mechanical disk or an SSD/CF card/USB stick/other NAND media and if the user picks the latter option, gpart should suggest a "flash media mode" (or other suitable name). Picking this, gpart would still function almost as it normally would, except it would automatically create a proper offset for the first partition as well as round up user's size choices for multiple partitions in order for them to be aligned properly, creating small gaps between partitions if/when necessary.

Right now, manually creating properly aligned partitions for optimal use with NAND-based media is a truly painful process.
>How-To-Repeat:
Attach an SSD disk
Boot FreeBSD
Run gpart
>Fix:
No known fix, requesting additional functionality be added to gpart.

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->suspended 
State-Changed-By: linimon 
State-Changed-When: Wed Jan 13 23:06:48 UTC 2010 
State-Changed-Why:  
Mark suspended awaiting someone to take up implementing this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=142786 

From: Bruce Cran <bruce@cran.org.uk>
To: bug-followup@freebsd.org,
 dan.naumov@gmail.com
Cc:  
Subject: Re: bin/142786: [request] gpart(8) should recognize NAND media and suggest partition alignment
Date: Thu, 18 Mar 2010 21:49:58 +0000

 Apparently this is also an issue on new hard drives with large sector sizes; 
 without proper alignment performance suffers. See 
 http://lists.freebsd.org/pipermail/freebsd-hackers/2010-March/031154.html for 
 a recent discussion of the issues.
 
 -- 
 Bruce Cran
>Unformatted:
