I’ve set up Samba once again, and it’s still not easy, especially with Cygwin in the mix. I still haven’t figured out Cygwin, but I did get the magic phrase that lets Windows machines run exe files without having to set the execute bit.

This is an option that’s not documented in the /etc/samba/smb.conf file, but that’s where it goes:
# Allow Windows machines to execute things that don't have
# the execute bit set
acl allow execute always = True

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 rather than fdisk/cfdisk to define the partitions, and parted version 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:

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.