UGREEN UASP USB SATA 어댑터/인클로저에서 SSD TRIM 수정
8032 단어 linuxraspberrypi
우리는 다음을 수행해야 합니다.
/sys/block/sda/device/scsi_disk/0:0:0:0/provisioning_mode
(표준 수정)/sys/block/sda/queue/discard_max_bytes
에 '2147450880' 설정두 번째 수정 사항
fstrim
이 없으면 작은 파티션에서만 작동합니다.UDEV 규칙을 통한 영구 수정
다음 udev 규칙을
/etc/udev/rules.d/99-ugreen-sata-adapter-trim-enable.rules
에 추가합니다.# UGREEN SATA USB adapter cable - ASMedia Technology Inc. Ugreen Storage Device
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="225c", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="225c", SUBSYSTEM=="block", ATTR{queue/discard_max_bytes}="2147450880"
# UGREEN SATA Enclosure - ASMedia Technology Inc. ASM1153 SATA 3Gb/s bridge
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="1153", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"
ACTION=="add|change", ATTRS{idVendor}=="174c", ATTRS{idProduct}=="1153", SUBSYSTEM=="block", ATTR{queue/discard_max_bytes}="2147450880"
💡:
idProduct
를 자신의 것으로 변경해야 할 수도 있습니다 - 확인 lsusb
.예를 들어 여기 내 것이 있습니다.
# `lsusb` output:
...
Bus 002 Device 034: ID 174c:225c ASMedia Technology Inc. Ugreen Storage Device
...
Bus 002 Device 041: ID 174c:1153 ASMedia Technology Inc. ASM1153 SATA 3Gb/s bridge
2147450880은 어디에서 왔습니까?
기본
fstrim
값이 너무 큰(4294966784) 경우 큰 파티션에서 여전히 실패할 수 있는 것 같습니다discard_max_bytes
. 어댑터가 처리할 수 있는 최대값으로 설정해야 합니다.2147450880은 어댑터의 2가지 속성에서 계산된 제 경우의 최대값입니다.
Maximum unmap LBA count
(에서 sg_vpd
) Logical block length
(에서 sg_readcap
) 다음은 귀하의 정보를 보여주는 작은 스니펫입니다.
sudo su -
apt install sg3-utils
# Device to check
device=sdh
# e.g. lba_count=4194240
lba_count=$(sg_vpd --all /dev/$device|grep 'Maximum unmap LBA count'|grep -Po '(?<=: )(.*)(?=$)')
# e.g. block_length=512
block_length=$(sg_readcap --long /dev/$device|grep 'Logical block length'|grep -Po '(?<=\=)(.*)(?= bytes)')
# e.g. 2147450880
echo $(( $lba_count * $block_length ))
수정으로 해결되는 증상
이 수정 사항은 다음 오류가 발생하는 경우 관련이 있습니다.
# fstrim -v /
fstrim: /: the discard operation is not supported
fstrim: /: FITRIM ioctl failed: Operation not permitted
그리고
/var/log/syslog
/journalctl
에서:Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#12 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#12 Sense Key : Illegal Request [current]
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#12 Add. Sense: Invalid field in cdb
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#12 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
Sep 22 20:16:19 LINUX kernel: print_req_error: 6703 callbacks suppressed
Sep 22 20:16:19 LINUX kernel: blk_update_request: critical target error, dev sdg, sector 39667712 op 0x3:(DISCARD) flags 0x4000 phys_seg 1 prio class 0
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#13 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#13 Sense Key : Illegal Request [current]
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#13 Add. Sense: Invalid field in cdb
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#13 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
Sep 22 20:16:19 LINUX kernel: blk_update_request: critical target error, dev sdg, sector 48056312 op 0x3:(DISCARD) flags 0x4000 phys_seg 1 prio class 0
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#14 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#14 Sense Key : Illegal Request [current]
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#14 Add. Sense: Invalid field in cdb
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#14 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
Sep 22 20:16:19 LINUX kernel: blk_update_request: critical target error, dev sdg, sector 56444912 op 0x3:(DISCARD) flags 0x4000 phys_seg 1 prio class 0
Sep 22 20:16:19 LINUX kernel: blk_update_request: critical target error, dev sdg, sector 89999312 op 0x3:(DISCARD) flags 0x0 phys_seg 1 prio class 0
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#15 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#15 Sense Key : Illegal Request [current]
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#15 Add. Sense: Invalid field in cdb
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#15 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
Sep 22 20:16:19 LINUX kernel: blk_update_request: critical target error, dev sdg, sector 64833512 op 0x3:(DISCARD) flags 0x4000 phys_seg 1 prio class 0
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#16 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#16 Sense Key : Illegal Request [current]
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#16 Add. Sense: Invalid field in cdb
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#16 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
Sep 22 20:16:19 LINUX kernel: blk_update_request: critical target error, dev sdg, sector 73222112 op 0x3:(DISCARD) flags 0x4000 phys_seg 1 prio class 0
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#17 FAILED Result: hostbyte=DID_OK driverbyte=DRIVER_OK cmd_age=0s
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#17 Sense Key : Illegal Request [current]
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#17 Add. Sense: Invalid field in cdb
Sep 22 20:16:19 LINUX kernel: sd 7:0:0:0: [sdg] tag#17 CDB: Unmap/Read sub-channel 42 00 00 00 00 00 00 00 18 00
Sep 22 20:16:19 LINUX kernel: blk_update_request: critical target error, dev sdg, sector 81610712 op 0x3:(DISCARD) flags 0x4000 phys_seg 1 prio class 0
Sep 22 20:16:19 LINUX kernel: BTRFS warning (device sdg3): failed to trim 1 device(s), last error -95
신용 거래
이것은 Jeff Geerling의 this post 덕분에 가능합니다(그는 대단합니다 👍).
Reference
이 문제에 관하여(UGREEN UASP USB SATA 어댑터/인클로저에서 SSD TRIM 수정), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/klo2k/fix-ssd-trim-on-ugreen-uasp-usb-sata-adapterenclosure-5ge6텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)