orangePi3 TLS tf卡分区、格式化、手动挂载和开机自动挂载
文章目录
适用于所有linux系统
TF卡新建分区
查看磁盘情况
fdisk -l
root@orangepi3-lts:~# fdisk -l
.......
Disk /dev/mmcblk0: 58.24 GiB, 62534975488 bytes, 122138624 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: 0xe8e42744
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 120913919 120905728 57.7G 83 Linux
建立分区
主要指令fdisk /dev/mmcblk0,然后依次输入p,n,1,w即可;具体含义可以输入m,查看。
root@orangepi3-lts:~# fdisk /dev/mmcblk0
Welcome to fdisk (util-linux 2.37.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
This disk is currently in use - repartitioning is probably a bad idea.
It's recommended to umount all file systems, and swapoff all swap
partitions on this disk.
Command (m for help): p
Disk /dev/mmcblk0: 58.24 GiB, 62534975488 bytes, 122138624 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: 0xe8e42744
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): 1
First sector (2048-122138623, default 2048):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-122138623, default 122138623):
Created a new partition 1 of type 'Linux' and of size 58.2 GiB.
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
格式化
分区建立好后,需要格式化,这里使用mkfs -t ext4 /dev/mmcblk0p1,格式化成ext4类型文件系统
root@orangepi3-lts:~# mkfs -t ext4 /dev/mmcblk0p1
mke2fs 1.46.5 (30-Dec-2021)
Discarding device blocks: done
Creating filesystem with 15267072 4k blocks and 3817472 inodes
Filesystem UUID: 77363ae0-0ea7-4604-923a-06c76be48696
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
Allocating group tables: done
Writing inode tables: done
Creating journal (65536 blocks):
done
Writing superblocks and filesystem accounting information: done
root@orangepi3-lts:~# lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
mmcblk2
│
└─mmcblk2p1
ext4 1.0 ebd7f60c-e1e6-498f-b78a-bcdcdecaa68a 5.3G 19% /var/log.hdd
手动挂载和卸载分区命
挂载分区
//新建分区挂载点目录/mnt/myemmc
root@orangepi3-lts:~# mkdir -p /mnt/myemmc
//挂载分区
root@orangepi3-lts:~# mount /dev/mmcblk0p1 /mnt/myemmc
//查看挂载情况
root@orangepi3-lts:~# mount
......
/dev/mmcblk0p1 on /mnt/myemmc type ext4 (rw,relatime)
......
root@orangepi3-lts:~#
//在挂载目录下,进行写入查看测试
root@orangepi3-lts:~# cd /mnt/myemmc/
root@orangepi3-lts:/mnt/myemmc# ls
lost+found
root@orangepi3-lts:/mnt/myemmc# echo 1 >1.txt
root@orangepi3-lts:/mnt/myemmc# ls
1.txt lost+found
卸载分区
卸载
root@orangepi3-lts:~# umount /mnt/myemmc
自动mount
查询挂载emmc 的UUID
//获取uuid,供fstab文件使用
root@orangepi3-lts:~# blkid /dev/mmcblk0p1
/dev/mmcblk0p1: UUID="77363ae0-0ea7-4604-923a-06c76be48696" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="e8e42744-01"
//打开fstab,写入挂载命令
root@orangepi3-lts:~# vim /etc/fstab
UUID=77363ae0-0ea7-4604-923a-06c76be48696 /mnt/myemmc ext4 defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 2
其中:
UUID 通blkid /dev/mmcblk0p1获取
/mnt/myemmc 挂载点<mount point>,前边已经建立的目录
ext4 <type> 格式化的文件类型,这里是ext4
defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide <options>
0 代表 0:开机不检查磁盘,1:开机检查磁盘;
2 代表 0:交换分区,1:启动分区(Linux),2:普通分区
验证是否开机自动mount成功
reboot重启后,登录系统
查看挂载情况
root@orangepi3-lts:~# mount
.......
/dev/mmcblk0p1 on /mnt/myemmc type ext4 (rw,noatime,errors=remount-ro,commit=600,x-gvfs-hide)
.......
//查看之前测试建立的文件1.txt
root@orangepi3-lts:~# cd /mnt/myemmc/
root@orangepi3-lts:/mnt/myemmc# ls
1.txt lost+found
开机出现Give root password for maintenance
原因:分区mount不对
解决方法:仔细核对/etc/fstab