如何在 Ubuntu 中关闭硬盘?

如何在 Ubuntu 中关闭硬盘?

我在外置硬盘上运行 Kubuntu。我的内置硬盘上有 Windows。我不想在使用 Ubuntu 时使用它,想关闭它以减少热量并降低电池消耗。我认为降低硬盘转速对我来说不是一个选择。因为它会磨损硬盘,我不打算在 HDD 上花钱 :)

答案1

sudo hdparm -Y /dev/sdX

在哪里/dev/sdX是您要关闭的设备。您还可以运行sudo blkid来确定设备的“指纹”(UUID),这将使您能够更可靠地控制要关闭的设备。

在这种情况下,你可以运行:

sudo hdparm -Y /dev/disk/by-uuid/DEVICE-IDENT-HERE

人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.

答案2

您可能已经udisks2安装了该软件包;你可以使用

udisksctl power-off -b /dev/sdX

/dev/sdX您想关闭的设备在哪里?

来自udisksctl手册页(版本 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.

答案3

您可以使用以下内容(这里sdc是感兴趣的相应块设备的名称):

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

或(非 root 用户):

sync
echo 1 | sudo tee /sys/block/sdc/device/delete

相关内容