# AF drive layout question



## ian-nai (Sep 26, 2011)

Does this seem right for a 4k drive?

[CMD=""]gpart show ada1[/CMD]

```
=>       34  976773101  ada1  GPT  (465G)
         34         30        - free -  (15k)
         64      32768     1  freebsd-boot  (16M)
      32832       4032        - free -  (2M)
      36864    4259840     2  freebsd-ufs  (2.0G)
    4296704      28672        - free -  (14M)
    4325376    4259840     3  freebsd-swap  (2.0G)
    8585216  968163328     4  freebsd-zfs  (461G)
  976748544      24591        - free -  (12M)
```

I've been learning how to properly align drives for longer than I'm comfortable admitting...so I'm hoping for a little insight.  Thanks!


----------



## wblock@ (Sep 26, 2011)

Seems a little weird.  Why skip the first 30 sectors?  16M for freebsd-boot is way, way larger than it needs to be, and in fact it was mentioned recently on the mailing lists that a bug didn't like it being even 1M.  Then another 2M skipped, a 2G partition, 14M skipped...

Why not just:

```
freebsd-boot  (512K)
freebsd-ufs  (2.0G) (starting at 1M mark with [file]-b 1M[/file])
freebsd-swap  (2.0G)
freebsd-zfs  (461G)
```


----------



## ian-nai (Sep 26, 2011)

I'm trying to align the partitions to 4k boundaries. IIUC (if I understand correctly - a rare statement on the internet), the partitions need to start at sectors divisible by 4096 (and 512 ? ). The partitions also need to be *sizes* dividable into 4096k blocks (or is it 512*4096?) You get the idea. The drive I'm using doesn't respond well to willy nilly partition geometry.

http://forums.freebsd.org/showthread.php?t=12088&highlight=align+partition&page=3


> How to align, partition and format a drive on 4k boundaries using gpt and newfs
> 
> This tutorial is for increasing performance of the new hard drives with native 4k sectors. Specifically, it illustrates how to set up a data drive with only one GPT partition that is NOT bootable.



I'd reply there, but it's 'old'...seemed like the thing to do.


----------



## wblock@ (Sep 27, 2011)

ian-nai said:
			
		

> I'm trying to align the partitions to 4k boundaries. IIUC (if I understand correctly - a rare statement on the internet), the partitions need to start at sectors divisible by 4096 (and 512 ? ).



The problem is that new drives lie about sector sizes.  They claim to have 512-byte sectors for compatibility.  For performance, though, things need to line up on the 4K real sector boundaries.

Note that both 1M and 1G are even multiples of 4K.  So start the first data partition at 1M, make it and all the others even multiple gigabytes, and the problem should be solved.



> The partitions also need to be *sizes* dividable into 4096k blocks (or is it 512*4096?)



That's 4096 bytes.  The partitions don't have to be even multiples of that, but they do need to start on even multiples of 4k to be aligned.



> You get the idea. The drive I'm using doesn't respond well to willy nilly partition geometry.



Yes.  But look back at what I suggested.  The right way to try this is to set up the partitions (see Disk Setup On FreeBSD), then benchmark it with something serious like benchmarks/bonnie++.  Then repartition, but start the first data partition at 1M plus one 512-byte block and benchmark again.  One way should be substantially faster than the other.

(gpart(8) has a -a option for add now, but I haven't tried it.)


----------

