--------------------
Useful tips about IO
--------------------

## AHCI ##

For full utilization of the drive, the IO controller must support AHCI
and NCQ, and AHCI must be enabled in the BIOS. Then, searching for NCQ
in dmesg should result in:

    [    2.550267] ata6.00: 156301488 sectors, multi 1: LBA48 NCQ (depth 31/32)

Searching for pio/PIO in dmesg should return nothing, and searching
for ahci/AHCI should return results.

## Security ##

-- Set a password --
hdparm --user-master u --security-set-pass [PASSWORD] /dev/sd[X]

-- Issue erase command --
hdparm --user-master u --security-erase [PASSWORD] /dev/sd[X]

## AIO ##

The depth of AIO queue (i.e. number of outstanding requests before
io_submit returns -EAGAIN) is equal to min(nrevents, nr_requests),
where nrevents is passed to io_setup, and nr_requests can be found in
/sys/block/sda/queue/nr_requests.

/proc/sys/fs/aio-nr shows the sum of all aio_context sizes (each
context size is passed during io_setup).

## Scheduler ##

*** Check IO scheduler ***
$ cat /sys/block/{SDX}/queue/scheduler

*** Set IO scheduler ***
# echo {SCHEDULER-NAME} > /sys/block/{SDX}/queue/scheduler

## Tracing ##

The following command allows tracing all IO queue operations in real
time:

sudo btrace /dev/sdX

We can limit the trace to include only requests issued to the device
driver like this:

sudo btrace -a issue /dev/sdX

## IOAT ##

Enable Intel DMA technology for the network stack

- Enable IOAT and DCA in BIOS (two separate options).
- Run modprobe ioatdma
- (Ensure successful ioat initialization - check dmesg).
- See the ioat readme

## Partitioning ##

*** Partition the disk with alignment ***
After partitioning:

x - for expert command
b - to move data in the partition
After selecting the partition:
128 - to move the first cylinder to 64k aligned block

*** List partitions in dump format ***
sfdisk -d /dev/sdX > partition.dump

*** Partition the disk ***
sfdisk /dev/sdX < partition.dump

