前言
环境介绍:
1.编译环境
Ubuntu 18.04.5 LTS
2.SDK
rk356x_linux
3.单板
迅为itop-3568开发板 + 自制底板
一、查看硬盘
插上硬盘上电,进入系统后通过命令lspci查看nvme硬盘识别情况
[root@RK356X:/]# lspci -k
21:00.0 Class 0108: 1e4b:1202 nvme
20:00.0 Class 0604: 1d87:3566 pcieport
[root@RK356X:/]#
可以看到能正常识别到nvme设备
21:00.0 Class 0108: 1e4b:1202 nvme
二、查看分区
在/dev下面查看硬盘分区情况
[root@RK356X:/]# ls /dev/nvme0
nvme0 nvme0n1
可以看到nvme硬盘已经分好一个区了nvme0n1
要是还想分区可以通过fdisk进行分区。
[root@RK356X:/]# fdisk /dev/nvme0n1
Device contains neither a valid DOS partition table, nor Sun, SGI, OSF or GPT disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that the previous content
won't be recoverable.
The number of cylinders for this disk is set to 488386.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
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
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)
这里制作测试,一个区够用,不再进行分区。
分好区后可以通过fdisk -l查看分区情况
[root@RK356X:/]# fdisk -l
Found valid GPT with protective MBR; using GPT
Disk /dev/mmcblk0: 30547968 sectors, 2628M
Logical sector size: 512
Disk identifier (GUID): f4420000-0000-426c-8000-368900004ad5
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 30547934
Number Start (sector) End (sector) Size Name
1 16384 24575 4096K uboot
2 24576 32767 4096K misc
3 32768 163839 64.0M boot
4 163840 294911 64.0M recovery
5 294912 360447 32.0M backup
6 360448 25526271 12.0G rootfs
7 25526272 25919487 192M oem
8 25919488 30547903 2259M userdata
Disk /dev/nvme0n1: 477 GB, 512110190592 bytes, 1000215216 sectors
488386 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes
Disk /dev/nvme0n1 doesn't contain a valid partition table
[root@RK356X:/]#
这是识别到的nvme盘信息,就一个分区。
Disk /dev/nvme0n1: 477 GB, 512110190592 bytes, 1000215216 sectors
488386 cylinders, 64 heads, 32 sectors/track
Units: sectors of 1 * 512 = 512 bytes
三、格式化
硬盘分好区后,要格式化才能正常挂载
系统自带了格式化工具mkfs.ext4,可以直接使用。
[root@RK356X:/]# mkfs.ext4 /dev/nvme0n1
mke2fs 1.46.5 (30-Dec-2021)
/dev/nvme0n1 contains a ext4 file system
last mounted on Thu Jan 1 08:15:21 1970
Proceed anyway? (y,N) y
Discarding device blocks: done
Creating filesystem with 125026902 4k blocks and 31260672 inodes
Filesystem UUID: 19d88471-cbb2-4cc6-a39f-f5d0c776607e
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000
Allocating group tables: done
Writing inode tables: done
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done
[root@RK356X:/]#
四、 挂载
直接mount就行
[root@RK356X:/]# mount /dev/nvme0n1 /mnt
[ 4152.556192] EXT4-fs (nvme0n1): mounted filesystem with ordered data mode. Opts[root@RK356X:/]# : (null)
[root@RK356X:/]# ls /mnt/
lost+found
[root@RK356X:/]#
查看系统挂载情况
[root@RK356X:/]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/root ext4 13G 844M 12G 7% /
devtmpfs devtmpfs 1.1G 0 1.1G 0% /dev
tmpfs tmpfs 1.1G 0 1.1G 0% /dev/shm
tmpfs tmpfs 1.1G 263k 1.1G 1% /tmp
tmpfs tmpfs 1.1G 300k 1.1G 1% /run
/dev/mmcblk0p7 ext2 193M 13M 170M 7% /oem
/dev/mmcblk0p8 ext2 2.4G 26k 2.4G 1% /userdata
/dev/nvme0n1 ext4 503G 29k 478G 1% /mnt
[root@RK356X:/]#