23

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/… – Guilhem Soulas Sep 8 '15 at 11:01
  • 1
    man hdparm sudo hdparm -Y /dev/sdX – earthmeLon Sep 8 '15 at 21:08
  • @GuilhemSoulas My question is not about spinning down hard drive. Mine is how to turn off hard drive. – AhmedBilal Sep 9 '15 at 7:42
25
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.
| improve this answer | |
  • What exactly is hard or soft reset, i. e. how to get the drive back? – Asalle May 19 '19 at 18:18
  • 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. – clearkimura Aug 4 '19 at 17:23
6

You can use the following (here sdc is the name of corresponding block device of interest):

sync
echo 1 > /sys/block/sdc/device/delete
| improve this answer | |
  • +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). – clearkimura Aug 4 '19 at 17:15
  • 1
    I think the same is feasible using sudo: sudo bash -c 'echo 1 > /sys/block/sdc/device/delete'. – Tomilov Anatoliy Aug 5 '19 at 15:44
4

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.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.