如何在Ubuntu中关闭硬盘驱动器?


20

我正在从外部硬盘驱动器运行Kubuntu。我的内置硬盘上装有Windows。我不想在Ubuntu上使用它,而是想关闭它以产生更少的热量并消耗更少的电池。我认为旋转硬盘驱动器不是我的选择。因为,它磨损了硬盘驱动器,因此我不打算在HDD上花费:)


已经问过(并回答过)类似的问题:askubuntu.com/questions/39760/…–
Guilhem

1
man hdparm sudo hdparm -Y /dev/sdX
EarthmeLon 2015年

@GuilhemSoulas我的问题不是关于旋转硬盘。我的是如何关闭硬盘的。
AhmedBilal 2015年

Answers:


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

到底是什么hard or soft reset,即如何找回驱动器?
Asalle

该命令确实关闭了硬盘驱动器,但是运行sudo hdparm -C /dev/sdX查询状态将再次打开驱动器,然后进入待机状态(我猜是软复位)。这样做是为了省电,而不是为了模拟没有硬盘驱动器的安装。
clearkimura

5

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

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

+1可以正常工作,以防止安装程序检测到硬盘驱动器。必须以root用户(不是sudo)身份运行命令。
clearkimura

1
我想使用相同的是可行的sudosudo bash -c 'echo 1 > /sys/block/sdc/device/delete'
东方

3

您可能已经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.
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.