USBフラッシュドライブを非回転ドライブとして設定

USBフラッシュドライブを非回転ドライブとして設定

IOスケジューラを最適化し、回転するドライブと回転しないドライブ(相違)に適したスケジューラを使用しようとしています。私が実行したとき:

cat /sys/block/sd*/queue/rotational

私は得る:

1    <-- for sda
1    <-- for sdb

sdbはUSBフラッシュドライブですが、回転しないでください。

$ udevadm info -a -n /dev/sda | grep queue
ATTRS{queue_depth}=="31"
ATTRS{queue_ramp_up_period}=="120000"
ATTRS{queue_type}=="simple"

$ udevadm info -a -n /dev/sdb | grep queue
ATTRS{queue_depth}=="1"
ATTRS{queue_type}=="none"

したがって、そのような属性はありません。

ATTR{queue/rotational}=="0" or ...=="1"

ベストアンサー1

はい、これは混乱した質問です。ここに対応があります。カーネルエラー90761(2015年報告書)および2019年これを調査したブログ投稿。おそらく、これは伝統的なIOスケジューラがすべてそうだったので、外観上の問題です。MQ締め切り.. しかし、かなりの悩みの末に効果のあるルールを調べて、ここに投稿するのが良いと思いました。

/etc/udev/rules.d/usb-flash-drive-non-rotational.rules:

# Try to catch USB flash drives and set them as non-rotational. Probably no impact whatsoever : /
# c.f. https://mpdesouza.com/blog/kernel-adventures-are-usb-sticks-rotational-devices/

# Device is already marked as non-rotational, skip over it
ATTR{queue/rotational}=="0", GOTO="skip"

# Device has some sort of queue support, likely to be an HDD actually
ATTRS{queue_type}!="none", GOTO="skip"

# Flip the rotational bit on this removable device and give audible signs of having caught a match
ATTR{removable}=="1", SUBSYSTEM=="block", SUBSYSTEMS=="usb", ACTION=="add", ATTR{queue/rotational}="0"
ATTR{removable}=="1", SUBSYSTEM=="block", SUBSYSTEMS=="usb", ACTION=="add", RUN+="/bin/beep -f 70 -r 2"

LABEL="skip"

おすすめ記事