일정 시간 후 외부 ext4 드라이브 마운트 해제(Raspbian)

일정 시간 후 외부 ext4 드라이브 마운트 해제(Raspbian)

저는 Raspberry Pi(Raspbian)에서 BitTorrent Sync를 사용하여 외장 하드 드라이브(ext4)의 파일을 동기화하고 있습니다. 나는 5분 동안 활동이 없으면 드라이브의 속도를 줄이는 작은 스크립트를 작성했습니다. 뭔가를 읽으면 다시 돌기 시작해서 꽤 잘 작동하는 것 같습니다.

다음은 cronjob을 통해 5분마다 실행되는 스핀다운 스크립트입니다.

# !/bin/sh

# Get new state from diskstats
NEWstate=$(cat /proc/diskstats | grep $1)
echo $NEWstate > /home/pi/bin/spindown/NEWstate.txt

# compare md5 sums
md5new=$(md5sum /home/pi/bin/spindown/NEWstate.txt | sed 's/ .*//')
md5old=$(md5sum /home/pi/bin/spindown/OLDstate.txt | sed 's/ .*//')

# if no changes, power down
if [ "$md5new" = "$md5old" ]; then
        sdparm --flexible --command=stop /dev/$1 &>/dev/null
fi

# Write current state to file
echo $NEWstate > /home/pi/bin/spindown/OLDstate.txt

그러나 몇 시간 후에 하드 드라이브가 마운트 해제되고 BT Sync가 더 이상 제대로 작동하지 않았습니다. 개인 백업 서버로 사용하고 싶기 때문에 항상 실행되어야 합니다.

/etc/fstab다음과 같은 파일을 통해 설치 됩니다 .

/dev/sda5 /media/External ext4 defaults,noatime 0 0

드라이브를 마운트 해제한 후 즉시 자동으로 다시 마운트할 수 있는 방법이 있습니까? 아니면 (더 나은 방법으로) 그렇게 하는 것을 방지할 수 있습니까?

답변1

하드 드라이브의 전원 관리 설정을 변경해 보겠습니다 hdparm.

$ hdparm -B <value> /dev/sdx

세부 사항

-B     Query/set Advanced Power Management feature, if the drive supports it. 
       Allow value means aggressive power  management  and  a high value means 
       better performance.  Possible settings range from values 1 through 127 
       (which permit spin-down), and values 128 through 254 (which do not permit
       spin-down).  The highest degree of power management is attained  with a 
       setting of 1, and the highest I/O performance with a setting of 254.  A 
       value of 255 tells hdparm to disable Advanced Power Management altogether 
       on the drive (not all drives support disabling it, but most do).

관련 정보