linux: Class10 SD 카드의 다양한 장치 및 블록 장치 크기

linux: Class10 SD 카드의 다양한 장치 및 블록 장치 크기

A는 새로운 16GB 클래스 10 SD 카드를 가지고 있는데 매우 이상한 동작을 보입니다. USB SD 카드 리더로 카드를 연결한 후 장치가 /dev/sdb로 나타납니다. into를 사용하여 2GB 원시 이미지를 복사하려고 시도했지만 dd즉시 "장치에 더 이상 공간이 남지 않았습니다"라는 메시지가 반환됩니다.

블록 장치에는 10M 공간만 있다고 표시됩니다.

ls -lah /dev/sdb
-rw-r--r-- 1 root root 10M máj   16 23:16 /dev/sdb

fdisk는 동일한 크기를 표시합니다.

fdisk -l /dev/sdb
Disk /dev/sdb: 10 MiB, 10485760 bytes, 20480 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x84f9d19f

다른 리더로 SD 카드를 사용해 보았지만 카드 리더 문제는 아닌 것 같습니다. SD 카드의 "크기"는 모든 리더에서 10M입니다.

cat /proc/partitions
major minor  #blocks  name
...
   8       16   15558144 sdb
...

흥미로운 부분은 커널이 실제로 SD 카드의 올바른 크기를 알고 있는 것처럼 보인다는 것입니다.

cat /sys/block/sdb/size
31116288  # numbers of 512 byte blocks => 15.93 GB

그리고 제대로 인식된 것 같습니다.

May 16 22:58:07 DDSI-Laptop kernel: [258762.883672] usb 1-3: New USB device found, idVendor=14cd, idProduct=125c
May 16 22:58:07 DDSI-Laptop kernel: [258762.883674] usb 1-3: New USB device strings: Mfr=1, Product=3, SerialNumber=2
May 16 22:58:07 DDSI-Laptop kernel: [258762.883675] usb 1-3: Product: Mass Storage Device
May 16 22:58:07 DDSI-Laptop kernel: [258762.883676] usb 1-3: Manufacturer: Generic
May 16 22:58:07 DDSI-Laptop kernel: [258762.883677] usb 1-3: SerialNumber: 125C20100726
May 16 22:58:07 DDSI-Laptop kernel: [258762.883972] usb-storage 1-3:1.0: USB Mass Storage device detected
May 16 22:58:07 DDSI-Laptop kernel: [258762.884114] scsi host52: usb-storage 1-3:1.0
May 16 22:58:07 DDSI-Laptop mtp-probe: checking bus 1, device 30: "/sys/devices/pci0000:00/0000:00:14.0/usb1/1-3"
May 16 22:58:07 DDSI-Laptop mtp-probe: bus: 1, device: 30 was not an MTP device
May 16 22:58:08 DDSI-Laptop kernel: [258763.881813] scsi 52:0:0:0: Direct-Access     Mass     Storage Device        PQ: 0 ANSI: 0 CCS
May 16 22:58:08 DDSI-Laptop kernel: [258763.882008] sd 52:0:0:0: Attached scsi generic sg1 type 0
May 16 22:58:08 DDSI-Laptop kernel: [258763.883073] sd 52:0:0:0: [sdb] 31116288 512-byte logical blocks: (15.9 GB/14.8 GiB)
May 16 22:58:08 DDSI-Laptop kernel: [258763.883195] sd 52:0:0:0: [sdb] Write Protect is off
May 16 22:58:08 DDSI-Laptop kernel: [258763.883198] sd 52:0:0:0: [sdb] Mode Sense: 03 00 00 00
May 16 22:58:08 DDSI-Laptop kernel: [258763.883312] sd 52:0:0:0: [sdb] No Caching mode page found
May 16 22:58:08 DDSI-Laptop kernel: [258763.883315] sd 52:0:0:0: [sdb] Assuming drive cache: write through

차이의 원인은 무엇입니까?

답변1

-… /dev/sdb

이것은 장치가 아닌 일반 파일입니다. /dev/sdb이 드라이브 문자와 연결된 장치가 없을 때 어느 시점 에 쓰기를 시도한 것 같습니다 . 조심하세요! 의도한 장치와 다른 장치를 덮어쓰지 않은 것은 행운이었습니다.

/proc커널에서 직접 제공 되는 블록 장치에 대한 정보 /sys는 장치의 커널 이름을 사용합니다. 장치 노드는 다음 /dev에 의해 관리됩니다.udev; 일반적으로 커널의 장치 이름을 따르지만(다른 이름을 기호 링크로 추가) /dev수동으로 쓰면 udev가 중단될 수 있습니다. 디렉터리 항목이 /dev/sdb이미 존재하므로 SD 카드를 연결할 때 장치 노드가 생성되지 않았습니다.

을 제거하고 /dev/sdbSD 카드를 꺼냈다가 다시 연결한 후 어떤 장치 이름이 표시되는지 확인하세요. 블록 장치가 표시됩니다.

$ ls -l /dev/sdb
rw-rw-rw- 1 루트 디스크 8, 16 … /dev/sdb    

관련 정보