BASH: Test and optimise external drives

# Show filesystem details:
lsblk -f

# Test write Speed:
dd if=/dev/zero of=/path/to/your/external/drive/testfile bs=1G count=1 oflag=direct

# Test read Speed:
dd if=/path/to/your/external/drive/testfile of=/dev/null bs=1G count=1 iflag=direct

# Cleanup:
rm /path/to/your/external/drive/testfile

# Show device details:
sudo apt install hdparm smartmontools

sudo hdparm -i /dev/sda
or
sudo smartctl -i /dev/sda

# Show current I/O scheduler:
cat /sys/block/sda/queue/scheduler

# Test for database operation efficiency:
sudo apt install fio

#Full test (approx 30 mins for 1TB drive)
fio --name=random-rw --ioengine=libaio --rw=randrw --rwmixread=70 --bs=4k --size=1G --directory=/media/stimresp/stimdump --iodepth=64 --group_reporting

# Short test (1 minute)
fio --name=random-rw --ioengine=libaio --rw=randrw --rwmixread=70 --bs=4k --size=1G --directory=/media/stimresp/stimdump --iodepth=64 --group_reporting --runtime=60s

# Format drive to Linux ext4 filesytem:
sudo umount /dev/sda1
sudo mkfs.ext4 -L toxbox_db /dev/sda1

# Find the new UUID:
lsblk -f

# Create a dedicated mount point (edit fstab)
sudo nano /etc/fstab

# ...add this line to the end. Note the 'noifail' flag - without it boot time will be increased 
# by 90 seconds default while the system waits for the drive to be ready!
UUID=a4f5ce99-2786-498c-b5e8-e81a807a940c  /data  ext4  defaults,nofail,noatime,nodiratime,barrier=1  0  2

# Reload fstab
sudo systemctl daemon-reload

# make sure you create a directory to mount into:
sudo mkdir /data

# Mount the drive:
sudo mount /data

# Reclaim ownership
sudo chown <user>:<group> /data

"What in God's holy name are you blathering about?"