Recently, you need to divide the SD card into Several partitions when developing a set-top box gui. The following is a summary of how to partition the SD card.
I. Using the disk management tool fdisk in Linux
Sudo fdisk/dev/SDC
Use fdisk to open your SD card device name. My SD card device name is SDC
2. Go to the fdisk management tool
Go to the following page
Warning: DOS-compatible mode is deprecated. It's stronugly recommended
Switch off the mode (command 'C') and change display units
Sectors (command 'U ').
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)
Command (M for help ):
We only need to use several main Commands of fdisk.
M: Help
N: Create a partition.
D: delete a partition.
P: Print partition information
T: Modify the partition ID. By modifying the ID, we can change the partition format. For example, the FAT32 format ID in Windows is 6 and the ext3 format ID in Linux is 83.
W: Save the partition information and exit
3. Create a partition
1. Print and display existing partitions.
Input P
Command (M for help): p
Disk/dev/SDC: 1967 MB, 1967128576 bytes
57 heads, 56 sectors/track, 1203 Cylinders
Units = cylinders of 3192*512 = 1634304 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/sdc1 1 23 36680 83 Linux
/Dev/sdc2 24 34 17556 83 Linux
2. Delete existing partitions
Enter D and select the Partition Number.
Command (M for help): d
Partition Number (1-4): 1
Command (M for help): d
Selected partition 2
3. Create a partition
3.1 create a primary Partition
Input n
Command (M for help): n
Command action
E extended
P primary partition (1-4)
P
Partition Number (1-4): 1
First cylinder (1-1203, default 1): 1
Last cylinder, + cylinders or + size {K, M, g} (1-1203, default 1203): 23
Enter N and select P to create a primary partition. Select 1 as the Partition Number, 1 as the first cylinder, and 23 as the last cylinder.
3.2 Create an extended partition
Command (M for help): n
Command action
E extended
P primary partition (1-4)
E
Partition Number (1-4): 2
First cylinder (24-1203, default 24 ):
Using default value 24
Last cylinder, + cylinders or + size {K, M, g} (24-1203, default 1203 ):
Using default value 1203
Enter N, select e to create an extended partition, and select number 2. Select the default 24 ~ 1023
3.3 create a logical Partition
Command (M for help): n
Command action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (24-1203, default 24 ):
Using default value 24
Last cylinder, + cylinders or + size {K, M, g} (24-1203, default 1203): 43
Enter N, select L to create a logical partition, and select the start and end positions as 24 ~ 43
Create the second logical Partition
Command (M for help): n
Command action
L logical (5 or over)
P primary partition (1-4)
L
First cylinder (44-1203, default 44 ):
Using default value 44
Last cylinder, + cylinders or + size {K, M, g} (44-1203, default 1203 ):
Using default value 1203
Modify partition ID
Input t
Command (M for help): T
Partition Number (1-6): 1
HEX Code (type L to list codes): 6
Changed system type of partition 1 to 6 (fat16)
Select a partition numbered 1. Here I set the ID to 6 (fat16 format, ext32 format ID to 83)
Similarly, modify the ID of other partitions.
4. Save and exit
Command (M for help): p
Disk/dev/SDB: 1967 MB, 1967128576 bytes
57 heads, 56 sectors/track, 1203 Cylinders
Units = cylinders of 3192*512 = 1634304 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 1 23 36680 6 fat16
/Dev/sdb2 24 1203 1883280 5 extended
/Dev/sdb5 24 43 31892 83 Linux
/Dev/sdb6 44 1203 1851332 83 Linux
Here we can see the partition I just created
Input W
Command (M for help): W
The partition table has been altered!
Calling IOCTL () to re-read partition table.
Warning: re-reading the Partition Table failed with error 16: the device or resource is busy.
The kernel still uses the old table. The new table will be used
The next reboot or after you run partprobe (8) or kpartx (8)
Warning: If you have created or modified any DOS 6.x
Partitions, please see the fdisk manual page for additional
Information.
Syncing disks.
Save and exit. I thought it would be done at this step. Otherwise there will be the following
4. Format partitions
After step 3, you will find that your SD card has no response, because step 3 only writes the partition table information and does not complete formatting.
Fat format partition formatting command mkfs. vfat/dev/sdb1
Format partition format command mkfs. ext3/dev/sdb5
Note that if you use these two commands for formatting, a message is displayed.
Yang @ Yang-PC :~ $ Sudo mkfs. ext3/dev/sdb3
Mke2fs 1.41.12 (17-may-2010)
Unable to call/dev/sdb3 stat --- no file or directory
This is because the partition table we wrote has not yet taken effect. You can remove the SD card and insert it again. Now you can see the partition you created in/dev/SD *.
Then, use the format command to format the corresponding format partition. If your SD card has something, then format it with the-I parameter to overwrite the content.
5. Modify the partition name
After completing step 4, we can see that the partition we just created is automatically mounted to/Media. However, the names of these partitions are still ugly characters.
Therefore, you need to modify the partition name, that is, label.
Modify the label command e2label/dev/SDB labelname in ext3 format
I have not found a good method for modifying the fat format. I can only solve this problem in windows.
PS: If you have any questions, please leave a message. If any of you can find a better way to name the partition name in the fat format, I 'd like to tell you, thank you!