How to turn off hard drive in Ubuntu?
sudo hdparm -Y /dev/sdX
where /dev/sdX is the device you'd like to turn off. You can also run sudo blkid
to determine the device's 'fingerprint' (UUID), which would allow you to more reliably control which device is being turned off.
In this case, you'd run:
sudo hdparm -Y /dev/disk/by-uuid/DEVICE-IDENT-HERE
man hdparm
-Y Force an IDE drive to immediately enter the lowest power
consumption sleep mode, causing it to shut down completely. A
hard or soft reset is required before the drive can be accessed
again (the Linux IDE driver will automatically handle issuing a
reset if/when needed). The current power mode status can be
checked using the -C option.
You can use the following (here sdc
is the name of corresponding block device of interest):
sync
echo 1 > /sys/block/sdc/device/delete
or (from non-root user):
sync
echo 1 | sudo tee /sys/block/sdc/device/delete