1. 程式人生 > >linux掛載SD卡

linux掛載SD卡

(1)通過#fdisk -l命令確認板子上的linux系統是否識別SD卡

MP805M板子插入SD卡後顯示

SD30 slot is without WP
mmc1: new high speed SD card at address 5bc0
mmcblk0: mmc1:5bc0 SD02G 1.83 GiB 
mmcblk0: p1

[/]# fdisk -l

Disk /dev/mtdblock0: 1 MB, 1179648 bytes
255 heads, 63 sectors/track, 0 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/mtdblock0 doesn't contain a valid partition table

Disk /dev/mmcblk0: 1967 MB, 1967128576 bytes
40 heads, 56 sectors/track, 1715 cylinders
Units = cylinders of 2240 * 512 = 1146880 bytes

Device Boot Start End Blocks Id System
/dev/mmcblk0p1 * 192 1716 1707008 6 FAT16

(2)確保/mnt存在
然後cat /proc/partitions
看看到底有沒有mmc相關的分割槽

[/]# cat /proc/partitions 
major minor #blocks name

31 0 1152 mtdblock0
31 1 768 mtdblock1
31 2 768 mtdblock2
31 3 7040 mtdblock3
31 4 121344 mtdblock4
179 0 1921024 mmcblk0
179 1 1707008 mmcblk0p1

沒有這兩個分割槽,就說明SD卡驅動沒有移植成功

核心選項裡支援
device deivers-》mmc/sd card support ->Samsung s3c sd/mmc card interface support

(3)掛載SD卡

mount /dev/mmcblk0p1 /mnt/mmc

或者

mount -t vfat  /dev/mmcblk0p1/mnt/ 

(4)解除安裝SD卡

umount /mnt

注意,當前目錄不能是/mnt,否則會出現“umount can't umount /mnt device or resource busy”的錯誤提示資訊。

 (5)Linux 如何上電掛載SD卡

編輯/etc/init.d/目錄下的rcS檔案:vi /etc/init.d/rcS
在裡面加入一行:mount -t vfat /dev/mmcblk0p1 /mmc
這樣上電後開發板就會自動掛載SD卡到主目錄的mmc資料夾

 

Stay hungry, stay foolish!