Friday, February 27, 2015

raspberry pi에 USB Flash Memory(FAT32) 읽기 쓰기가 가능하도록 마운트 (Mount FAT32 usb stick read,write permission)

USB Flash memory를 FAT32로 포맷하고 이것을 마운트 하려면 다음과 같이 한다.

굵은 글씨는 명령어.

pi@rpi ~ $ lsusb
Bus 001 Device 002: ID 0424:9514 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 005: ID 0781:5580 SanDisk Corp.
Bus 001 Device 004: ID 0d8c:0105 C-Media Electronics, Inc. CM108 Audio Controller


USB Flash memory가 lsusb에 나타났다.

pi@rpi ~ $ tail -f /var/log/messagesFeb 28 05:09:34 rpi kernel: [58069.795528] usb-storage 1-1.2:1.0: USB Mass Storage device detected
Feb 28 05:09:34 rpi kernel: [58069.796076] scsi host0: usb-storage 1-1.2:1.0
Feb 28 05:09:34 rpi kernel: [58069.820379] usbcore: registered new interface driver uas
Feb 28 05:09:35 rpi kernel: [58070.793472] scsi 0:0:0:0: Direct-Access     SanDisk  Extreme          0001 PQ: 0 ANSI: 6
Feb 28 05:09:35 rpi kernel: [58070.796241] sd 0:0:0:0: [sda] 31277232 512-byte logical blocks: (16.0 GB/14.9 GiB)
Feb 28 05:09:35 rpi kernel: [58070.797056] sd 0:0:0:0: [sda] Write Protect is off
Feb 28 05:09:35 rpi kernel: [58070.797777] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Feb 28 05:09:35 rpi kernel: [58070.802944]  sda: sda4Feb 28 05:09:35 rpi kernel: [58070.806540] sd 0:0:0:0: [sda] Attached SCSI disk
Feb 28 05:09:35 rpi kernel: [58070.825946] sd 0:0:0:0: Attached scsi generic sg0 type 0

꼽았을때 sda4로 잡혔음을 알 수 있다.

그렇다면 sda4를 마운트 하면됨.
pi@rpi ~ $ sudo mount -t vfat /dev/sda4 /media/usbstick -o rw,umask=111,dmask=000
pi@rpi ~ $ ls /media/usbstick/ -l

total 8
drwxrwxrwx 3 root root 8192 Feb 28 05:28 log


이제 usb flash memory의 내용이 잘 보임. 마운트가 잘되었음.

pi@rpi /media/usbstick/log/201502 $ ls -l
total 8
-rw-rw-rw- 1 root root 15 Feb 28 05:29 20150228142900.txt


중요한것은 umask와 dmask에 따라서 디렉토리와 파일의 권한이 달라진다는점.


No comments:

Post a Comment