Ubuntu – How to turn off hard drive when booting from USB

hard driveusb

I want to install Ubuntu on a USB drive and found these instructions here.

I want to do this, because I want to use my laptop when I am in a car or when I walk. So, I want to turn off my hard drive when booting from USB to prevent it to cause bad sectors, etc.

Now my question is: how to manually turn off the hard drive when booting from USB? Or, does it turn off when isn't in use or being mounted?

Best Answer

Here are the steps to take your hard disk to enter standby mode (or to sleep mode). This gets HDD to spin down and park the heads to landing zones so that the chances of a head crash is nullified.

  1. Boot the Ubuntu liveCD/DVD/USB.

  2. If the HDD that you're trying to take to standby mode has a swap-partition (likely if you have Ubuntu installed in your HDD as well), turn it off.

    sudo swapoff -a (This turns off all devices marked as swap)

  3. Now to make your HDD enter low power consumption standby mode:

    sudo hdparm -y /dev/sdX where sdX is the target HDD, and X in sdX should be replaced appropriately (with a, b, c, ..., z); assuming it to be sda, the command would look like this: sudo hdparm -y /dev/sda

    Or you could make your HDD enter the lowest power consumption sleep mode, causing it to shut down completely with:

    sudo hdparm -Y /dev/sdX (sdX should be the target device)

That's it! You can then continue using your live Ubuntu session.

(Note: Modern laptops use "self-park" for better & safe portability.)

PS. This method of putting a HDD to standby mode can prove helpful also when you want to be a little economical on power consumption. Especially in desktop computers, if you have more that one internal HDDs, you can power down those which you use very less than often.