Sector Alignment on 9.1 Release

I'm installing FreeBSD 9.1 on a PC with a 1 TB Western Digital Green drive with 4K sectors.

Disk details from dmesg:
Code:
ada0 at ata3 bus 0 scbus2 target 0 lun 0
ada0: <WDC WD1001FALS-00J7B1 05.00K05> ATA-8 SATA 2.x device
ada0: 150.000MB/s transfers (SATA, UDMA5, PIO 8192bytes)
ada0: 953869MB (1953525168 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad6

I was following the instructions from the handbook chapter for allocating disk space and it said that using even multiples of 1M or 1G helps to ensure proper alignment. However, the boot sector can only be 512K which will throw off the rest of the partitions. What it the best way to get around this? Can I create an unused 512K partition after the boot partition and then create the rest of the partitions that I want to use?
 
Thanks for posting your Disk Setup Guide. It was very helpful. I found another article for on partition alignment during install which was also useful.

Just for reference, here is a list of partitions, mount points and sizes that I'm using:
Code:
ada0p1	boot	512K
ada0p2	/	2G
ada0p3	swap	4G
ada0p4	/var	2G
ada0p5	/tmp	1G
ada0p6	/usr	922G

I've been tinkering with this machine over the past few days but still can't get it partitioned and installed correctly. I'm booting 9.1 Release from a USB thumb drive. I run the installer and select shell in the partitioning screen. I ran the following commands:
Code:
gpart destroy -F ada0
gpart create -s gpt ada0
gpart add -t freebsd-boot -b 40 -s 512K ada0
gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
gpart add -t freebsd-ufs -b 1M -s 2G ada0
gpart add -t freebsd-swap -s 4G ada0
gpart add -t freebsd-ufs -s 2G ada0
gpart add -t freebsd-ufs -s 1G ada0
gpart add -t freebsd-ufs ada0

This configuration matches the sample configuration from the handbook for partition sizes. I chose to not use labels just to keep this operation as simple as possible.

I then formatted the filesystems:
Code:
newfs -U /dev/ada0p2
newfs -U /dev/ada0p4
newfs -U /dev/ada0p5
newfs -U /dev/ada0p6

I then mounted the new root partition:
Code:
mount /dev/ada0p2 /mnt

Next I created an fstab file as per the instructions that were given when I entered the shell and saved it as /tmp/bsdinstall_etc/fstab.

Code:
#Device		Mount Point	FSType	Options	Dump	Pass#
/dev/ada0p3	none		swap	sw	0	0
/dev/ada0p2	/		ufs	rw	1	1
/dev/ada0p5	/tmp		ufs	rw	2	2
/dev/ada0p6	/usr		ufs	rw	2	2
/dev/ada0p4	/var		ufs	rw	2	2

I then exited from the shell and resumed the installation. The installation completes successfully and I reboot without the USB thumb drive.

Upon boot I see "Starting filesystem checks" and everything looks OK there. The first indication of a problem is the following line:
Code:
mount: /dev/ada0p6: Device busy
This is the /usr partition. The boot process then tries to run other programs which fail, most likely because they're located under /usr. I can't get to a prompt.

I rebooted from the USB thumb drive and ran a shell. I mounted /usr and saw that there were no files in that partition. The same thing for /, /var and /tmp.

It appears that the installation program is not writing the files to the correct partition. The strange thing is that I can see it extracting the source code, docs, etc. and it seems to run fine. I can hear disk activity so I know it's getting written somewhere.

I can't figure out what is going wrong and hope that somebody on this forum has some words of wisdom!
 
This is a guess. But I notice you are only mounting the root partition and none of the others. Therefore what I think might be happening is that usr, var, and tmp are being installed into ada0p2. Then when the system boots it mounts all the others over the top of where they were actually installed into and therefore they appear empty.

I would say what you need to do is to mount all of the partitions before you exit the shell in the installer. So mount ada0p6 as /mnt/usr for example.
 
Xtaz- you were right. I created a var, tmp and usr directory under /mnt, mounted the partitions, and everything installed and booted correctly. Thanks for the advice!

Now I'm trying to confirm that the sector size is 4K instead of 512B. gpart list shows 512B sectors, is this right?

Code:
Geom name: ada0
modified: false
state: OK
fwheads: 16
fwsectors: 63
last: 1953525134
first: 34
entries: 128
scheme: GPT
Providers:
1. Name: ada0p1
   Mediasize: 524288 (512k)
   [B]Sectorsize: 512[/B]
   Stripesize: 0
   Stripeoffset: 20480
   Mode: r0w0e0
   rawuuid: 9fb6eb4d-63d3-11e2-a3df-001cc0e0a98c
   rawtype: 83bd6b9d-7f41-11dc-be0b-001560b84f0f
   label: (null)
   length: 524288
   offset: 20480
   type: freebsd-boot
   index: 1
   end: 1063
   start: 40
2. Name: ada0p2
   Mediasize: 2147483648 (2.0G)
   [B]Sectorsize: 512[/B]
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   rawuuid: bba5bd64-63d3-11e2-a3df-001cc0e0a98c
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 2147483648
   offset: 1048576
   type: freebsd-ufs
   index: 2
   end: 4196351
   start: 2048
3. Name: ada0p3
   Mediasize: 4294967296 (4.0G)
   [B]Sectorsize: 512[/B]
   Stripesize: 0
   Stripeoffset: 2148532224
   Mode: r1w1e0
   rawuuid: c3b12805-63d3-11e2-a3df-001cc0e0a98c
   rawtype: 516e7cb5-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 4294967296
   offset: 2148532224
   type: freebsd-swap
   index: 3
   end: 12584959
   start: 4196352
4. Name: ada0p4
   Mediasize: 2147483648 (2.0G)
   [B]Sectorsize: 512[/B]
   Stripesize: 0
   Stripeoffset: 2148532224
   Mode: r1w1e1
   rawuuid: cd270f5b-63d3-11e2-a3df-001cc0e0a98c
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 2147483648
   offset: 6443499520
   type: freebsd-ufs
   index: 4
   end: 16779263
   start: 12584960
5. Name: ada0p5
   Mediasize: 1073741824 (1.0G)
   [B]Sectorsize: 512[/B]
   Stripesize: 0
   Stripeoffset: 1048576
   Mode: r1w1e1
   rawuuid: cfca3e87-63d3-11e2-a3df-001cc0e0a98c
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 1073741824
   offset: 8590983168
   type: freebsd-ufs
   index: 5
   end: 18876415
   start: 16779264
6. Name: ada0p6
   Mediasize: 990540144128 (922G)
   [B]Sectorsize: 512[/B]
   Stripesize: 0
   Stripeoffset: 1074790400
   Mode: r1w1e1
   rawuuid: d1dc2c1a-63d3-11e2-a3df-001cc0e0a98c
   rawtype: 516e7cb6-6ecf-11d6-8ff8-00022d09712b
   label: (null)
   length: 990540144128
   offset: 9664724992
   type: freebsd-ufs
   index: 6
   end: 1953525134
   start: 18876416
Consumers:
1. Name: ada0
   Mediasize: 1000204886016 (931G)
   [B]Sectorsize: 512[/B]
   Mode: r5w5e9
 
Benchmarks

I'm thinking that the steps I performed in message #4 of this thread did not properly align the partitions. I ran bonnie++ on a clean, generic installation and again on the same system with manually aligned partitions. Most of the throughput statistics are slower on the aligned partition installation.


Unaligned partitions:
Code:
Version  1.97       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
omni             4G    90  99 87598  44 40280  30   212  99 89283  24 244.2  12
Latency             92875us   66773us    1053ms   44501us   38977us     387ms
Version  1.97       ------Sequential Create------ --------Random Create--------
omni                -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
             files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                16 10092  82 +++++ +++ 24294  95 11286  90 +++++ +++ 25291  97
Latency               117ms      52us     133us     135ms     160us      81us

Aligned partitions:
Code:
Version  1.97       ------Sequential Output------ --Sequential Input- --Random-
Concurrency   1     -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine        Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP  /sec %CP
omni             4G    90  99 78942  41 34839  26   208  99 79639  24 237.6  12
Latency             94096us   75886us    1222ms   80826us   96035us    2136ms
Version  1.97       ------Sequential Create------ --------Random Create--------
omni                -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
              files  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP  /sec %CP
                 16  9759  78 +++++ +++ 25602  99 12109  93 +++++ +++ 25922  99
Latency               128ms     110us      81us   89148us      72us     124us
 
If there is a misalignment, speeds will be dramatically slower, not just a little. Drives aren't the same speed all across the platters. The outer, larger tracks have more data, so that part of the disk goes faster. That 11% difference is well in that range, and a read speed of 80-90M/second on those drives is believable. Misaligned, speed can be half of normal.

bonnie++ gives realistic speeds as opposed to many other benchmarks. If you want to see the raw transfer rate of the drive, use diskinfo(8):
% diskinfo -tv ada0

It will be faster, as fast as that drive can read blocks. Since it does not go through a filesystem, it will be as fast as that drive will go.

If you don't have any other operating systems sharing that system, see if the BIOS has an option for AHCI mode for the drive controller. That should give 5-15% more speed.
 
What I don't understand is why was there very little difference between the bonnie++ benchmarks for an unaligned partitions compared to properly aligned partitions. I thought I would see a significant increase in throughput once the partitions were configured correctly.

I ran diskinfo and the numbers from it seems to match up with the bonnie++ stats.

Code:
# diskinfo -tv ada0
ada0
        512             # sectorsize
        1000204886016   # mediasize in bytes (931G)
        1953525168      # mediasize in sectors
        0               # stripesize
        0               # stripeoffset
        1938021         # Cylinders according to firmware.
        16              # Heads according to firmware.
        63              # Sectors according to firmware.
        WD-WMATV2181379 # Disk ident.

Seek times:
        Full stroke:      250 iter in   5.124517 sec =   20.498 msec
        Half stroke:      250 iter in   3.515140 sec =   14.061 msec
        Quarter stroke:   500 iter in   5.738681 sec =   11.477 msec
        Short forward:    400 iter in   2.036119 sec =    5.090 msec
        Short backward:   400 iter in   2.219360 sec =    5.548 msec
        Seq outer:       2048 iter in   0.406940 sec =    0.199 msec
        Seq inner:       2048 iter in   0.366437 sec =    0.179 msec
Transfer rates:
        outside:       102400 kbytes in   0.965449 sec =   106065 kbytes/sec
        middle:        102400 kbytes in   1.077707 sec =    95017 kbytes/sec
        inside:        102400 kbytes in   1.786794 sec =    57309 kbytes/sec
 
Here is the output from gpart show without manual partition editing. I ran [CMD=""]gpart destroy -F ada0[/CMD] to be sure that the partitions I created manually were removed before reinstalling to run benchmarks.

Code:
# gpart show
=>        34  1953525101  ada0  GPT  (931G)
          34         128     1  freebsd-boot  (64k)
         162  1944059776     2  freebsd-ufs  (927G)
  1944059938     8388608     3  freebsd-swap  (4.0G)
  1952448546     1076589        - free -  (525M)

I'll recreate the partitions properly tomorrow and post the output from the same command.
 
That one is definitely misaligned. The only UFS partition starts at block 162. Those are 512-byte blocks. (162*512)/4096= 20.25. Run bonnie++ on that before repartitioning.
 
Back
Top