orangePi3 TLS tf卡分区、格式化、手动挂载和开机自动挂载

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:普通分区

image-20230505111743817

验证是否开机自动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

image-20230505105918107

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

心之雅

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值