It’s in bits and pieces all over the net, but I haven’t seen it all in one place yet. Western Digital Red drives have 4k (4096 byte) sectors rather than the old 512 byte sectors. In order to use them optimally, you need to format them aligned on those sectors.
The first trick is to use parted to define the partitions, and a version of 2.2 or higher, as described on this Western Digital support article.
Next, you need to decide what your partition table should look like. For maximum compatibility, use msdos. But if you have drives larger than 2G, you will probably want to use gpt instead.
Assuming you’re using /dev/sdd as your drive:
# parted -a optimal /dev/sdd (parted) mklabel msdos (parted) q
Next, you will want to add the partition. In my case, I wanted to create an ext4 partition that took up the whole disk. Here’s how:
# parted -a optimal /dev/sdd (parted) mkpart primary ext4 0% 100% (parted) p Model: ATA WDC WD20EFRX-68A (scsi) Disk /dev/sdd: 2000GB Sector size (logical/physical): 512B/4096B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 2000GB 2000GB primary ext3 (parted) q
The -a optimal is the magic bit that tells parted to partition on 4k boundaries for a 4k drive. My ext4 partition actually got created as an ext3 partition, since those are the same partition type.
Then you need to create a file system on the partition you just created. I add a label afterwards so I can mount it via label in /etc/fstab. (There’s a way to add a label in the mkfs command, but I can never remember it, so I do it in two steps.)
# mkfs -t ext4 /dev/sdd1 # e2label /dev/sdd1 mynewdrive
Then edit /etc/fstab to add the new drive to it:
LABEL=mynewdrive /newdrivemountpoint ext4 defaults 0 2
The label matches the label I specified on e2label, and the /newdrivemountpoint is the directory in the Unix file system that I want the drive to be mounted on. The last two numbers say “don’t dump” (0) and “do fsck after the root drive” (2). See the man page or the Ubuntu fstab page for more details on that.