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 :)
3 Answers
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.
-
-
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.– user37165Aug 4, 2019 at 17:23
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.
-
-
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 ROct 13, 2020 at 20:40
-
do you know natively on low level command what it actually does? sorry just for learning purpose Jun 20, 2021 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)" Jul 18, 2022 at 5:59
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
-
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).– user37165Aug 4, 2019 at 17:15
-
4I think the same is feasible using
sudo
:sudo bash -c 'echo 1 > /sys/block/sdc/device/delete'
. Aug 5, 2019 at 15:44 -
1It worked perfectly for a Linux Mint 19.1 installation from a USB stick. Jun 2, 2020 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. Aug 27, 2021 at 2:40
-
This did not actually power off my USB hard drive, just made it disappear from the system. The accepted answer with hdparm worked.– bladeAug 29, 2022 at 8:06
man hdparm
sudo hdparm -Y /dev/sdX