본문 바로가기

삽질

라즈베리파이4 ssd 인식문제

라즈베리파이를 NAS용도로 구매해서 SSD를 연결하고 삼바설정까지 다했는데
생각보다 파일복사가 느리고 계속 연결이 끊어지거나 파일을 복사가 실패하는 경우가 많아서
처음에는 전원문제인가 찾다가 라즈베리파이4에 ssd 하나정도는 외장전원 없이 충분하다는 글을 보고 다른원인인가 찾아보았다.

증상

처음엔 연결이 잘되었는데 디스크 I/O가 발생하면 어느순간 디바이스 연결이 끊긴다.

오류 메시지 확인

dmesg -T -w

USB 연결

usb 2-1: new SuperSpeed Gen 1 USB device number 2 using xhci_hcd
usb 2-1: New USB device found, idVendor=152d, idProduct=0578, bcdDevice= 5.08
usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 2-1: Product: USB to ATA/ATAPI Bridge
usb 2-1: Manufacturer: JMicron
usb 2-1: SerialNumber: 0123456789ABCDEF

연결된 SSD를 사용할때 아래와 같은 메시지가 나오면서 I/O가 멈춘다.

scsi host0: uas_eh_device_reset_handler start
usb 2-1: reset SuperSpeed Gen 1 USB device number 2 using xhci_hcd
scsi host0: uas_eh_device_reset_handler success
sd 0:0:0:0: [sda] tag#27 uas_eh_abort_handler 0 uas-tag 4 inflight: CMD IN
sd 0:0:0:0: [sda] tag#27 CDB: opcode=0x28 28 00 1d 1c 59 68 00 00 08 00
scsi host0: uas_eh_device_reset_handler start
sd 0:0:0:0: [sda] tag#26 uas_zap_pending 0 uas-tag 3 inflight: CMD
sd 0:0:0:0: [sda] tag#26 CDB: opcode=0x28 28 00 00 31 4b 00 00 01 00 00
usb 2-1: reset SuperSpeed Gen 1 USB device number 2 using xhci_hcd
scsi host0: uas_eh_device_reset_handler success

어느순간 usb disconnect가 나오면서 실패해버린다.
디바이스 연결이 끊겨서 I/O 에러가 발생한다.

sd 0:0:0:0: [sda] tag#18 uas_eh_abort_handler 0 uas-tag 2 inflight: CMD IN
sd 0:0:0:0: [sda] tag#18 CDB: opcode=0x28 28 00 00 e7 e1 c8 00 01 00 00
sd 0:0:0:0: [sda] tag#17 uas_eh_abort_handler 0 uas-tag 1 inflight: CMD IN
sd 0:0:0:0: [sda] tag#17 CDB: opcode=0x28 28 00 00 e7 e2 c8 00 01 00 00
sd 0:0:0:0: [sda] tag#13 uas_eh_abort_handler 0 uas-tag 4 inflight: CMD OUT
sd 0:0:0:0: [sda] tag#13 CDB: opcode=0x2a 2a 00 00 99 89 00 00 00 08 00
xhci_hcd 0000:01:00.0: WARNING: Host System Error
xhci_hcd 0000:01:00.0: xHCI host not responding to stop endpoint command.
xhci_hcd 0000:01:00.0: xHCI host controller not responding, assume dead
xhci_hcd 0000:01:00.0: HC died; cleaning up
sd 0:0:0:0: [sda] tag#12 uas_eh_abort_handler 0 uas-tag 3 inflight: CMD
sd 0:0:0:0: [sda] tag#12 CDB: opcode=0x2a 2a 00 00 5d a4 00 00 00 08 00
usb 2-1: USB disconnect, device number 2
sd 0:0:0:0: Device offlined - not ready after error recovery
sd 0:0:0:0: Device offlined - not ready after error recovery
sd 0:0:0:0: Device offlined - not ready after error recovery
sd 0:0:0:0: Device offlined - not ready after error recovery
print_req_error: I/O error, dev sda, sector 15196616
print_req_error: I/O error, dev sda, sector 15196872
print_req_error: I/O error, dev sda, sector 10062080
Buffer I/O error on dev sda2, logical block 1206304, lost async page write
print_req_error: I/O error, dev sda, sector 6136832
Buffer I/O error on dev sda2, logical block 715648, lost async page write
print_req_error: I/O error, dev sda, sector 15196616
Buffer I/O error on dev sda2, logical block 1848121, async page read

SATA TO USB3 확인

pi@raspberrypi:~ $ lsusb
Bus 002 Device 002: ID 152d:0578 JMicron Technology Corp. / JMicron USA Technology Corp. JMS567 SATA 6Gb/s bridge
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

원인

SATA TO USB 아답터의 칩셋 때문인것으로 보인다.

해결 방법

boot 파티션의 cmdline.txt의 제일 앞에 아래처럼 추가한다.

usb-storage.quirks=$idVender:$idProduct:u

위의 usb연결 msg를 참고해서 작성한다.

usb 2-1: New USB device found, idVendor=152d, idProduct=0578, bcdDevice= 5.08

cmdline.txt

usb-storage.quirks=152d:0578:u console=serial0,115200 console=tty1 root=PARTUUID=738a4d67-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait

재부팅 후 연결이 계속 잘 유지된다.

참고

https://www.raspberrypi.org/forums/viewtopic.php?t=245931

https://github.com/raspberrypi/linux/issues/3070

https://www.raspberrypi.org/forums/viewtopic.php?f=28&t=245931&start=50