Bug 161720 - bsdinstall(8): partition editor does not put partitions on even 4K boundaries
Summary: bsdinstall(8): partition editor does not put partitions on even 4K boundaries
Status: Closed Not A Bug
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 9.0-BETA3
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-sysinstall (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-16 19:00 UTC by Warren Block
Modified: 2014-11-22 03:33 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Warren Block 2011-10-16 19:00:28 UTC
Partitions created by the Auto option of bsdinstall's partition editor do not start on even 4K boundaries.  This will seriously compromise performance on drives with 4K-byte blocks.

gpart show ada0
=>      34  25694141  ada0  GPT  (12G)
        34       128     1  freebsd-boot  (64k)
       162  23068544     2  freebsd-ufs  (11G)
  23068706   1284096     3  freebsd-swap  (627M)
  24352802   1341373        - free -  (655M)

Partition 2 starts at block 162.  Instead, it should start at 1M as with
gpart add -t freebsd-ufs -b 1M -s 11G ada0

Note: at present, FreeBSD boot code fails when freebsd-boot partitions are larger than 512K, so making the freebsd-boot partition 1M is not the simple fix it appears to be.

Reported by je33 in http://forums.freebsd.org/showthread.php?t=27044

Fix: 

FreeBSD partition types other than freebsd-boot should start at the next even multiple of 1M for good performance on Advanced Format (4K block) drives without harming performance of 512 byte drives.
How-To-Repeat: Install FreeBSD 9.0-BETA3 with bsdinstall and Auto partitioning.
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2011-10-16 23:50:58 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-sysinstall

over to maintainer
Comment 2 Dennis Yusupoff 2011-10-25 10:27:02 UTC
While I agree with you in need of aligning [first] partition, I'd like
to behold, that gpart show size in blocks, not in megabytes, so to align
partition to 1 mbyte on 4K-align HDDs you might execute "gpart add -b
2048 -s 64K -t freebsd-boot ada0" ( 2048 blocks * 4096 kbytes = 8 Mbyte,
in case of "plain" HDD 2048 blocks * 512 bytes = 1 Mbyte, which, I
think, is a pretty good).
Moreover, I don't see why freebsd-boot partition should be more than
512K, if even 64K are currently just enough for FreeBSD. Looks like old
and famous Bill Gates's sentence, I know, but however :)

-- 
With best regards,
Dennis Yusupoff,
network engineer of
Smart-Telecom ISP
Russia, Saint-Petersburg 

Comment 3 Warren Block 2011-10-25 14:17:24 UTC
On Tue, 25 Oct 2011, Dennis Yusupoff wrote:

> While I agree with you in need of aligning [first] partition, I'd like
> to behold, that gpart show size in blocks, not in megabytes, so to align
> partition to 1 mbyte on 4K-align HDDs you might execute "gpart add -b
> 2048 -s 64K -t freebsd-boot ada0" ( 2048 blocks * 4096 kbytes = 8 Mbyte,
> in case of "plain" HDD 2048 blocks * 512 bytes = 1 Mbyte, which, I
> think, is a pretty good).

The -b option to 'gpart add' also accepts a size like "1M", so 'gpart 
add -t freebsd-ufs -b 1M ...' should work on any drive with a block size 
all the way up to 1M.  Tested and works on 512-byte drives, but I have 
not tested it on a 4K drive.

There's also the -a option, which attempts to align partitions to the 
value given.  '-a 4096' should work on both 512-byte and 4k-byte drives.

(bsdinstall's partition editor and wizard do not run gpart(8) but make 
lower-level calls to libgeom.  Still, the functionality of the -a or -b 
options could be duplicated.)

> Moreover, I don't see why freebsd-boot partition should be more than
> 512K, if even 64K are currently just enough for FreeBSD. Looks like old
> and famous Bill Gates's sentence, I know, but however :)

FreeBSD bootcode has problems with a freebsd-boot partition larger than 
512K, so that's the current limit.

However, starting the first filesystem partition at 1M works for both 
alignment and compatibility with other systems.  From the -current 
mailing list:

http://lists.freebsd.org/pipermail/freebsd-current/2011-September/027547.html
http://lists.freebsd.org/pipermail/freebsd-current/2011-September/027548.html
http://lists.freebsd.org/pipermail/freebsd-current/2011-September/027550.html
http://lists.freebsd.org/pipermail/freebsd-current/2011-September/027563.html
http://lists.freebsd.org/pipermail/freebsd-current/2011-September/027626.html
Comment 4 Dennis Yusupoff 2011-10-25 14:36:44 UTC
25.10.2011 17:17, Warren Block пиÑеÑ:
>
> The -b option to 'gpart add' also accepts a size like "1M", so 'gpart
> add -t freebsd-ufs -b 1M ...' should work on any drive with a block
> size all the way up to 1M. Tested and works on 512-byte drives, but I
> have not tested it on a 4K drive.
>
> There's also the -a option, which attempts to align partitions to the
> value given. '-a 4096' should work on both 512-byte and 4k-byte drives.

I haven't knew it, thanks.

>
>> Moreover, I don't see why freebsd-boot partition should be more than
>> 512K, if even 64K are currently just enough for FreeBSD. Looks like old
>> and famous Bill Gates's sentence, I know, but however :)
>
> FreeBSD bootcode has problems with a freebsd-boot partition larger
> than 512K, so that's the current limit.
>
> However, starting the first filesystem partition at 1M works for both
> alignment and compatibility with other systems. From the -current
> mailing list:
>

[...skipped...]

Yeah, I agree with you, but aligning shift size hasn't relation with
partition size - so works with aligned partition doesn't need to
increase freebsd-boot partition larger 512K since it's work.

P.S. My home server:
===
[dyr@server ~]$ gpart show ada0
=> 34 3907029101 ada0 GPT (1.8T)
34 2014 - free - (1M)
2048 128 1 freebsd-boot (64k)
2176 8388608 2 freebsd-swap (4.0G)
8390784 41943040 3 freebsd-zfs (20G)
50333824 3856695311 4 freebsd-zfs (1.8T)

[dyr@server ~]$
===
Works fine...



-- 
With best regards,
Dennis Yusupoff,
network engineer of
Smart-Telecom ISP
Russia, Saint-Petersburg 

Comment 5 Nathan Whitehorn freebsd_committer freebsd_triage 2014-11-21 22:40:47 UTC
The installer aligns to the physical block (or RAID stripe) size reported by the kernel for the device being formatted. For 4K disks, it aligns at 4K. For 512-byte disks (as in the example here, I think), it aligns at 512 bytes.
Comment 6 Kimmo Paasiala 2014-11-22 01:28:07 UTC
I think would be quite safe to default to 4k alignment on GPT partitioned disks, this would not break anything. On MBR disks it's not possible because some old BIOSes still insist on the CHS geometry alignment and might not work with 4k aligned partitions.

How about getting this fixed as an errata fix for 10.1?
Comment 7 Nathan Whitehorn freebsd_committer freebsd_triage 2014-11-22 03:33:26 UTC
It would be easy enough to change, but is unnecessary for disks with 512 byte sectors, which are the only ones affected. Since there isn't any bug, there is no need to change anything.