【TINY4412】LINUX移植笔记:(14)SD卡分区、格式化

环境

宿主机 : 虚拟机 Ubuntu 16.04 LTS / X64
目标板[底板]: Tiny4412SDK - 1506
目标板[核心板]: Tiny4412 - 1412
LINUX内核: 4.12.0
交叉编译器: arm-none-linux-gnueabi-gcc(gcc version 4.8.3 20140320)
日期: 2017-9-9 20:30:09
作者: SY

简介

SD容量:16GB

首先在Windows下格式化完成,再将SD卡插入Ubuntu

分区

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
root@ubuntu:/opt/u-boot-2017.03/sd_fuse/tiny4412# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x0f0ec6f5
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 39847934 41940991 2093058 1022M 5 Extended
/dev/sda5 39847936 41940991 2093056 1022M 82 Linux swap / Solaris
Disk /dev/sdd: 14.5 GiB, 15544090624 bytes, 30359552 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: 0x500a0dff
Device Boot Start End Sectors Size Id Type
/dev/sdd1 1948285285 3650263507 1701978223 811.6G 6e unknown
/dev/sdd2 0 0 0 0B 74 unknown
/dev/sdd4 28049408 28049848 441 220.5K 0 Empty
Partition table entries are not in disk order.

可以发现我的SD卡被识别为sdd,但是显示的扇区信息全部错的。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
root@ubuntu:/opt/u-boot-2017.03/sd_fuse/tiny4412# fdisk /dev/sdd
Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): m
Help:
DOS (MBR)
a toggle a bootable flag
b edit nested BSD disklabel
c toggle the dos compatibility flag
Generic
d delete a partition
F list free unpartitioned space
l list known partition types
n add a new partition
p print the partition table
t change a partition type
v verify the partition table
i print information about a partition
Misc
m print this menu
u change display/entry units
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table

查看fdisk支持的命令,其中d为删除分区:

1
2
3
4
5
6
7
8
9
10
11
12
13
Command (m for help): d
Partition number (1,2,4, default 4):
Partition 4 has been deleted.
Command (m for help): d
Partition number (1,2, default 2):
Partition 2 has been deleted.
Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

先将分区全部删除,默认回车就行

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Command (m for help): n
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-30359551, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-30359551, default 30359551): +1G
Created a new partition 1 of type 'Linux' and of size 1 GiB.
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2):
First sector (2099200-30359551, default 2099200):
Last sector, +sectors or +size{K,M,G,T,P} (2099200-30359551, default 30359551):
Created a new partition 2 of type 'Linux' and of size 13.5 GiB.

创建1个分区,大小为1G,创建第2个分区,大小为剩余空间大小

1
2
3
4
5
6
7
8
9
10
11
Command (m for help): p
Disk /dev/sdd: 14.5 GiB, 15544090624 bytes, 30359552 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: 0x500a0dff
Device Boot Start End Sectors Size Id Type
/dev/sdd1 2048 2099199 2097152 1G 83 Linux
/dev/sdd2 2099200 30359551 28260352 13.5G 83 Linux

可以看到2个分区,分区类型全部为LINUX

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
Command (m for help): t
Partition number (1,2, default 2): 1
Partition type (type L to list all types): L
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
Partition type (type L to list all types): b
Changed type of partition 'Linux' to 'W95 FAT32'.
Command (m for help): t
Partition number (1,2, default 2): 2
Partition type (type L to list all types): 83
Changed type of partition 'Linux' to 'Linux'.

修改分区类型:1设置为FAT322设置为LINUX

1
2
3
4
5
6
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@ubuntu:/opt/u-boot-2017.03/sd_fuse/tiny4412#

保存退出。

格式化

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
root@ubuntu:/opt/u-boot-2017.03/sd_fuse/tiny4412# fdisk -l
Disk /dev/sda: 20 GiB, 21474836480 bytes, 41943040 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: 0x0f0ec6f5
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 39845887 39843840 19G 83 Linux
/dev/sda2 39847934 41940991 2093058 1022M 5 Extended
/dev/sda5 39847936 41940991 2093056 1022M 82 Linux swap / Solaris
Disk /dev/sdd: 14.5 GiB, 15544090624 bytes, 30359552 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: 0x500a0dff
Device Boot Start End Sectors Size Id Type
/dev/sdd1 2048 2099199 2097152 1G b W95 FAT32
/dev/sdd2 2099200 30359551 28260352 13.5G 83 Linux
root@ubuntu:/opt/u-boot-2017.03/sd_fuse/tiny4412# mkfs.msdos -n FAT32 -F 32 /dev/sdd1
mkfs.fat 3.0.28 (2015-05-16)

格式化sdd1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@ubuntu:/opt/u-boot-2017.03/sd_fuse/tiny4412# mkfs.ext4 -L EXT4 /dev/sdd2
mke2fs 1.42.13 (17-May-2015)
/dev/sdd2 contains a vfat file system labelled 'SD'
Proceed anyway? (y,n) y
Creating filesystem with 3532544 4k blocks and 884736 inodes
Filesystem UUID: 9320d520-907d-42b4-a9b5-8ab19b5a2d6a
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks):
done
Writing superblocks and filesystem accounting information:
done

格式化sdd2

这样,SD卡已经分区、格式化完毕。注意:EXT4分区在Windows中不能被识别!

SY wechat
扫一扫,用手机访问本站