# disks very slow under FreeBSD



## Deleted member 2077 (Jul 10, 2010)

I've tried everything here:
http://forums.freebsd.org/showthread.php?t=15747
and here: http://forums.freebsd.org/showthread.php?t=15722
Also followed this: http://forums.freebsd.org/showpost.php?p=76148&postcount=38

I'm using UFS2.  One big partition for data.  No raid, nothing fancy.  I'm on FreeBSD 6.4 Release.

Under windows I can easily read/write about at ~75MB/s without doing nothing but formatting it.
My friend has the same drives in Linux, he says he can get ~50MB/s on his very low end system (crap cpu and only 256mb of ram).

Under FreeBSD, my write is at best ~6MB/s and read is about ~9MB/s.  The CPU, amount of ram, etc are all better than both the above boxes so don't think it's bound by anything externally like that.  From what I read, the partitions aren't aligned correctly?

What's going on here?  For start to finish, how should I partition and format these so they don't suck?



diskinfo:

```
[root@fire2 ~/drive]# diskinfo -v /dev/da3
/dev/da3
        512             # sectorsize
        2000396746752   # mediasize in bytes (1.8T)
        3907024896      # mediasize in sectors
        243201          # Cylinders according to firmware.
        255             # Heads according to firmware.
        63              # Sectors according to firmware.
```

dataconfig.cfg:

```
#http://forums.freebsd.org/showpost.php?p=76148&postcount=38
8 partitions:
#         size      offset     fstype     [fsize     bsize    bps/cpg]
a:  3906961408           1     4.2BSD       4096     32768
```

bsdlabel/newfs:

```
bsdlabel -R  /dev/da3 datadrive.cfg
newfs -S 4096 -b 32768 -f 4096 -O 2 -U -m 8 -o space -L u2 /dev/da3
```

fstab:

```
/dev/da3                /u3             ufs     rw              2       2
```


----------



## phoenix (Jul 10, 2010)

How are you testing it?


----------



## Deleted member 2077 (Jul 10, 2010)

phoenix said:
			
		

> How are you testing it?



Tried rsync (from much faster local disk), robocopy (from samba share) and DD (writing /dev/zero).  None break the ~6 mb barrier on writes.


----------



## phoenix (Jul 10, 2010)

dd is a piss-poor benchmarking tool.  By default, is you omit the *bs=* option, it uses 512 byte blocks, which gives absolutely abysmal throughput.  Using *bs=1M* is the minimum to use for harddrives, and bs=4M or more is required for some harddrives and SSDs.

Install bonnie++ or similar filesystem benchmarking app.  Be sure to read the man page, and use a dataset larger than your installed RAM (otherwise, you are just testing cache speeds).

How is the filesystem mounted?  SoftUpdates enabled?  SUJ enabled?  GEOM journaling in use?  All the defaults?


----------



## Deleted member 2077 (Jul 10, 2010)

phoenix said:
			
		

> dd is a piss-poor benchmarking tool.  By default, is you omit the *bs=* option, it uses 512 byte blocks, which gives absolutely abysmal throughput.  Using *bs=1M* is the minimum to use for harddrives, and bs=4M or more is required for some harddrives and SSDs.
> 
> Install bonnie++ or similar filesystem benchmarking app.  Be sure to read the man page, and use a dataset larger than your installed RAM (otherwise, you are just testing cache speeds).



I used 1M for DD.

I have 3 disks in the system.  The 2TB, a 80 gig (512 sectors) and a 360 gig (512 sectors).  All UFS2.

Coping for 80->360 and vis-versa is ~60MB/s, samba is a little slower, but still get decent speeds from it.  Coping from 80/360->2TB and vis-versa is 6|9MB/s.  

I don't need anything fancy here.  Heck, at this point I'd settle for ~30MB/s speeds.  Something is obviously wrong with 6|9 speeds.



> How is the filesystem mounted?  SoftUpdates enabled?  SUJ enabled?  GEOM journaling in use?  All the defaults?



UFS2 with soft updates. Don't think any SUJ or GEOM.  The commands in my original post are what is used.  I just want a big UFS2 slice with acceptable read/write speeds.


----------



## phoenix (Jul 10, 2010)

Is this 2 TB drive one that has 4K sectors?


----------



## Deleted member 2077 (Jul 10, 2010)

phoenix said:
			
		

> Is this 2 TB drive one that has 4K sectors?



Yes, but shows up as 512.  They call it "Advanced Format".

edit: in some google searches, the Linux guys are saying to start at 64 (instead of 63) and format it with 4K sectors (instead of the default 512) and works just fine.



> I have it setup for a backup drive to a Debian Server. I treated as a 4k sector drive (bumping start from 63 to 64, and bumping sectors size from 512 to 4k).


----------



## phoenix (Jul 11, 2010)

Repartition the drive.  Start the first partition at 1 MB.  That will align the partition/filesystem correctly.  Otherwise, any write to the drive will require read sector 1, read sector 2, modify sector, write sector 1 and 2.  If it's aligned, a write would just be write sector.

Improperly aligned partition on the 4K drives will cause all kinds of slowdowns.


----------



## Deleted member 2077 (Jul 11, 2010)

phoenix said:
			
		

> Repartition the drive.  Start the first partition at 1 MB.  That will align the partition/filesystem correctly.  Otherwise, any write to the drive will require read sector 1, read sector 2, modify sector, write sector 1 and 2.  If it's aligned, a write would just be write sector.
> 
> Improperly aligned partition on the 4K drives will cause all kinds of slowdowns.




I've tried this a couple times: http://forums.freebsd.org/showpost.php?p=76148&postcount=38
No luck.

How do you start the partition at 1MB?


----------



## mk (Jul 11, 2010)

i had experienced such slow speeds when i attempted to set hw.ata.wc to 0, which disable your write cache. thus speed's gone between 1-3MB/s. by chance something to mess around with your cache?


----------



## phoenix (Jul 11, 2010)

@MK:  no, he underlying issue is the 4K physical sector size but the drives report a sector size of 512B to the OS.  Thus, it's a pain to get the alignment set correctly to allow things to work.  Especially with ZFS that has a variable block size.  If WD would just update the firmware for the drives so that it reports a physical sector size of 4K, these issues would disappear.

@feralape:  Look into gpart(8).  It allows you to better specify the exact starting sector/size of partitions.


----------



## kisscool-fr (Jul 20, 2010)

Does it help if you just create the filesystem over the physical disk ? 


```
newfs -L u2 /dev/da3
```


You could also try this to align the partition to 1MB. 

datadrive.cfg

```
#http://forums.freebsd.org/showpost.php?p=76148&postcount=38
8 partitions:
#         size      offset     fstype     [fsize     bsize    bps/cpg]
a:  3907022848        2048     unused          0         0
```


```
# bsdlabel -R da3 datadrive.cfg
```


```
# newfs -L u2 /dev/da3a
```

and


```
mount -t ufs /dev/da3a /u3
```

Do you see any difference in your transfer rates ?


----------



## Deleted member 2077 (Jul 21, 2010)

Sorry, I sent the drives back.  i tried it across the whole disk and didn't help.  also tried aligning it at differant spots without luck.


----------



## jem (Jul 22, 2010)

Other options for aligning the partition to the disk,

1. Use GPT partitioning, which enables you to easily specify partition offsets in blocks.  Just make the starting block a multiple of 8.

2. It's possible to newfs an entire unpartitioned disk device (just 'newfs /dev/ad1').  That might eliminate alignment problems.  Haven't tested this.


----------



## Deleted member 2077 (Jul 23, 2010)

jem said:
			
		

> Other options for aligning the partition to the disk,
> 
> 1. Use GPT partitioning, which enables you to easily specify partition offsets in blocks.  Just make the starting block a multiple of 8.



Yes, I tried bsdlabel, gpt and gpart (from ports I believe).  Tried aligning at defaults, 4096, 32768, 1 meg, with and without offsets.



> 2. It's possible to newfs an entire unpartitioned disk device (just 'newfs /dev/ad1').  That might eliminate alignment problems.  Haven't tested this.



Yes, I tried that: newfs /dev/da1

nothing really helped.  These were the WD "Advanced Format" drives.  Firmware reported 512, but internally they were 4096.

thanks for your help everyone; but we can close this.  I no longer have the drives so can't test anything further.  I went with some Seagate 2TB 5400 drives and they work like a dream compared to Western Digital's.  Don't buy WD drives!


----------



## wonslung (Jul 24, 2010)

I've boycotted WD until they fix the firmware in their drives....Since then i've fallen in love with hitachi drives...they are typically well priced and very fast.


I have 20 2TB hitachis and 20 1TB seagates....all are great


----------

