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 :)

  • There are similar questions already asked (and answered): askubuntu.com/questions/39760/… Sep 8, 2015 at 11:01
  • 1
    man hdparm sudo hdparm -Y /dev/sdX
    – earthmeLon
    Sep 8, 2015 at 21:08
  • @GuilhemSoulas My question is not about spinning down hard drive. Mine is how to turn off hard drive.
    – AhmedBilal
    Sep 9, 2015 at 7:42

3 Answers 3

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.
  • What exactly is hard or soft reset, i. e. how to get the drive back?
    – Asalle
    May 19, 2019 at 18:18
  • 1
    This 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.
    – user37165
    Aug 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):

    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.
  • That works on Ubuntu 20.04. Is there a way to power on afterwards?
    – Sven
    Oct 13, 2020 at 12:52
  • 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, 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
  • I don't actually!
    – Taylor R
    Jun 21, 2021 at 5:45
  • 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):

echo 1 > /sys/block/sdc/device/delete

or (from non-root user):

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).
    – user37165
    Aug 4, 2019 at 17:15
  • 4
    I think the same is feasible using sudo: sudo bash -c 'echo 1 > /sys/block/sdc/device/delete'. Aug 5, 2019 at 15:44
  • 1
    It worked perfectly for a Linux Mint 19.1 installation from a USB stick.
    – Matt Mello
    Jun 2, 2020 at 23:01
  • 1
    This 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.
    – blade
    Aug 29, 2022 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .