1. 程式人生 > 其它 >sd卡重新分割槽以及格式化

sd卡重新分割槽以及格式化

參考

掛載

檢視SD卡掛掛載點:

df -T
# (-h可以檢視單位為M的大小)

在這裡插入圖片描述解除安裝SD卡:

sudo umount /dev/sdb1 /dev/sdb2

使用fdisk工具刪除分割槽、新增分割槽:

sudo fdisk /dev/sdb

輸入m 幫助:

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)

輸入p檢視當前sd卡的分割槽(partition)資訊:

Command (m for help): p
 
Disk /dev/sdb: 7948 MB, 7948206080 bytes
245 heads, 62 sectors/track, 1021 cylinders, total 15523840 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 Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sdb1 * 2048 1048576 523264+ c W95 FAT32 (LBA) /dev/sdb2 1048577 15523839 7237631+ 83 Linux

刪除分割槽

輸入d刪除(delete)所有sd卡分割槽。因為有2個分割槽,需要刪除2次

Command (m for help): d
Partition number (1-4): 1
 
Command (m for help): d
Selected partition 2

建立分割槽

輸入n新建(new)一個分割槽

輸入p選擇新建一個主分割槽

輸入1建立分割槽1

輸入分割槽1的‘First sector’和‘Last sector’

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-15523839, default 2048): 2048
Last sector, +sectors or +size{K,M,G} (2048-15523839, default 15523839): 
Using default value 15523839

輸入w將建立完成對分割槽表寫入sd卡,並退出

Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
 
WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

格式化分割槽

格式化 fat 分割槽(windows下可見):

sudo mkfs.vfat -F 32 -n boot /dev/sdb1

格式化 ext3 分割槽:

sudo mkfs.ext3 -L rootfs /dev/sdb2

fat分割槽存放核心、裝置樹等。ext3分割槽存放根檔案系統。