UGREEN UASP USB SATA 어댑터/인클로저에서 SSD TRIM 수정

8032 단어 linuxraspberrypi
마침내 내 컴퓨터와 Raspberry Pi-s 모두에서 최신 UGREEN USB SATAadapterenclosure에서 SSD TRIM을 수정하는 방법을 알아냈습니다!

우리는 다음을 수행해야 합니다.
  • '매핑 해제' 설정/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 덕분에 가능합니다(그는 대단합니다 👍).

    좋은 웹페이지 즐겨찾기