poweroff usbdisk by CLI

最後更新: 2017-05-10

目錄

  • Manually Poweroff usb-disk
  • Smart table
  • udisks2

 


Manually Poweroff usb-disk

 

Find the device

lsusb

Bus 003 Device 015: ID 2537:1066

lsusb -t

/:  Bus 03.Port 1: Dev 1, Class=root_hub, Driver=xhci_hcd/2p, 5000M
    |__ Port 2: Dev 15, If 0, Class=Mass Storage, Driver=usb-storage, 5000M

相當於

/sys/bus/usb/devices/Bus-Port

Device info

/sys/bus/usb/devices/Bus-Port/manufacturer

ASMedia

/sys/bus/usb/devices/Bus-Port/power/level

on

/sys/bus/usb/devices/Bus-Port/power/connected_duration

588372                  # ms

Disconnect Device

# /dev/sdX 會不見了

echo 1 > /sys/bus/usb/devices/Bus-Port/remove

Checking

lsusb 及 lsblk 都不見了它

 


Smart table

 

Power_Cycle_Count                   # count of full hard disk power on/off cycles.
Start_Stop_Count                      # count of hard disk spindle start/stop cycles
Power-Off_Retract_Count:         # counts the times heads are loaded off the media.
Load_Cycle_Count:                    # counts the times heads are loaded onto the media

Power_Cycle_Count = Start_Stop_Count = Power-Off_Retract_Count + 1

Load_Cycle_Count 唔關其它 3 個事

More info.

Load Cycle Count is the number of times the head has been moved to the "parked" position.

That typically happens when the drive is shut down or, in a laptop, it is powered down to save the battery.

 


udisks2

 

yum install udisks2

apt-get install udisks2

  • Size
  • Symlinks

udisksctl status

MODEL                     REVISION  SERIAL               DEVICE
--------------------------------------------------------------------------
WDC WD10EAVS-00D7B1       01.01A01  WD-WCAU4A544735      sda
Samsung SSD 850 EVO 250GB EMT01B6Q  S21PNXBG619259X      sdb
WDC WD10EZEX-08RKKA0      80.00A80  WD-WMC1S4211414      sdc

udisksctl info -b /dev/sdd | less

/org/freedesktop/UDisks2/block_devices/sde:
  org.freedesktop.UDisks2.Block:
    Configuration:              []
    CryptoBackingDevice:        '/'
    Device:                     /dev/sde
    DeviceNumber:               2112
    Drive:                      '/org/freedesktop/UDisks2/drives/WD_Elements_25A2_57584C31413837364E414537'
    HintAuto:                   true
    HintIconName:
    HintIgnore:                 false
    HintName:
    HintPartitionable:          true
    HintSymbolicIconName:
    HintSystem:                 false
    Id:                         by-id-usb-WD_Elements_25A2_57584C31413837364E414537-0:0
...

udisksctl power-off -b /dev/sdd

 


Script 版的 udisks2

 

#!/bin/bash

mydisk= /dev/sda

echo "Sync and Flush cache"
hdparm -f $mydisk
sleep 2
echo ""
echo "Now Drive to Stand-by"
hdparm -y $mydisk

 

Creative Commons license icon Creative Commons license icon