我正在使用外置硬盘运行Kubuntu。我的内置硬盘上安装了Windows。在Ubuntu上,我不想使用它,并且希望关闭它以减少发热并节省电池电量。我认为关闭硬盘旋转对我来说不是一个选项,因为这会损坏硬盘,而且我也不打算花钱购买新的硬盘 :)
sudo hdparm -Y /dev/sdX
其中/dev/sdX是您想关闭的设备。您还可以运行sudo blkid
来确定设备的“指纹”(UUID),这将使您能够更可靠地控制要关闭的设备。
在这种情况下,您将运行:
sudo hdparm -Y /dev/disk/by-uuid/DEVICE-IDENT-HERE
-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.
sudo hdparm -C /dev/sdX
来查询状态会再次打开驱动器然后进入待机模式(我猜是软重置)。这个命令适用于节能,但不能模拟没有硬盘驱动器的安装。 - user37165udisks2
软件包;你可以使用它。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.
sdc
是感兴趣的相应块设备的名称):sync
echo 1 > /sys/block/sdc/device/delete
sync
echo 1 | sudo tee /sys/block/sdc/device/delete
sudo
也是可行的:sudo bash -c 'echo 1 > /sys/block/sdc/device/delete'
。 - Tomilov Anatoliy