I am running Kubuntu from External Hard Drive. My Internal Hard Drive has Windows on it. I don't want to use it while on Ubuntu and want to turn it off to produce less heat as well consume lower battery. I think spinning down hard drive isn't an option for me. Because, it wear out the hard drive and I don't plan to spend on HDD's :)
Asked
Active
Viewed 4.4k times
3 Answers
44
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.

muru
- 197,895
- 55
- 485
- 740

earthmeLon
- 11,247
-
-
1This command did turn off the hard disk drive, but running
sudo hdparm -C /dev/sdX
to query the status will turn on the drive again then goes to stand by (a soft reset, I guess). Does the job for power saving, but not for simulating installation without the hard disk drive. – Aug 04 '19 at 17:23
17
You likely have the udisks2
package installed; you can use
udisksctl power-off -b /dev/sdX
where /dev/sdX
is the device you'd like to turn off.
From udisksctl
man page (version 2.7.6):
power-off
Arranges for the drive to be safely removed and powered off. On the OS
side this includes ensuring that no process is using the drive, then
requesting that in-flight buffers and caches are committed to stable
storage. The exact steps for powering off the drive depends on the
drive itself and the interconnect used. For drives connected through
USB, the effect is that the USB device will be deconfigured followed
by disabling the upstream hub port it is connected to.
Note that as some physical devices contain multiple drives (for
example 4-in-1 flash card reader USB devices) powering off one drive
may affect other drives. As such there are not a lot of guarantees
associated with performing this action. Usually the effect is that the
drive disappears as if it was unplugged.

Taylor R
- 546
- 4
- 14
-
-
1@Sven I believe that the poweroff command literally tells the hardware to power down, so it won't accept any commands after that point. You will likely need to power on your device manually after that; and that's likely device-dependent (disconnect / reconnect power supply, etc) – Taylor R Oct 13 '20 at 20:40
-
do you know natively on low level command what it actually does? sorry just for learning purpose – stackunderflow Jun 20 '21 at 16:11
-
-
It seems the command works for USB drives only? I got "Error powering off drive: No usb device (udisks-error-quark, 0)" – Kenji Noguchi Jul 18 '22 at 05:59
12
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

Tomilov Anatoliy
- 679
-
3+1 This works as expected to prevent the installer from detecting the hard disk drive at all. Must run the commands as root (not sudo). – Aug 04 '19 at 17:15
-
4I think the same is feasible using
sudo
:sudo bash -c 'echo 1 > /sys/block/sdc/device/delete'
. – Tomilov Anatoliy Aug 05 '19 at 15:44 -
1It worked perfectly for a Linux Mint 19.1 installation from a USB stick. – Matt Mello Jun 02 '20 at 23:01
-
1This should be the accepted answer, because it works for any internal (e.g. SATA) and external (e.g. USB) HD (hard disk), SSD (solid state drive), flash drive (aka pendrive, aka thumb drive), SD card etc. – Yuri Sucupira Aug 27 '21 at 02:40
-
This did not actually power off my USB hard drive, just made it disappear from the system. The accepted answer with hdparm worked. – blade Aug 29 '22 at 08:06
man hdparm
sudo hdparm -Y /dev/sdX
– earthmeLon Sep 08 '15 at 21:08