嵌入式爱好者

8mm将flash虚拟成U盘

2023-3-27 14:28| 发布者: Q_Y_X| 查看: 393| 评论: 0

类目: i.MX8MM系列产品  >  Linux     文档编号: 952

首先在烧写前需要将自动扩展分区的服务关掉。
OK8MM-linux-fs/OK8MM-linux-fs/lib/systemd/system/resize-helper.service
烧写后先确认想虚拟成U盘的分区大小,这里我将mmcblk2分区拿出2G虚拟成U盘
root@okmx8mm:~# fdisk -l
Disk /dev/mmcblk2: 7.3 GiB, 7818182656 bytes, 15269888 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: 0xb7f57906
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 16384 147455 131072 64M c W95 FAT32 (LBA)
/dev/mmcblk2p2 147456 6438911 6291456 3G 83 Linux
Disk /dev/mmcblk2rpmb: 4 MiB, 4194304 bytes, 8192 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
Disk /dev/mmcblk2boot1: 4 MiB, 4194304 bytes, 8192 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
Disk /dev/mmcblk2boot0: 4 MiB, 4194304 bytes, 8192 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: 0x8cc5ac8c
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2boot0p1 16384 147455 131072 64M c W95 FAT32 (LBA)
/dev/mmcblk2boot0p2 147456 6438911 6291456 3G 83 Linux
root@okmx8mm:~# fdisk /dev/mmcblk2
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/mmcblk2: 7.3 GiB, 7818182656 bytes, 15269888 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: 0xb7f57906
Device Boot Start End Sectors Size Id Type
/dev/mmcblk2p1 16384 147455 131072 64M c W95 FAT32 (LBA)
/dev/mmcblk2p2 147456 6438911 6291456 3G 83 Linux
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (2048-15269887, default 2048): 6500000
Last sector, +sectors or +size{K,M,G,T,P} (6500000-15269887, default 15269887): +2G
Created a new partition 3 of type 'Linux' and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
root@okmx8mm:~# ls /dev/mmcblk2*
/dev/mmcblk2 /dev/mmcblk2boot1 /dev/mmcblk2p2 /dev/mmcblk2rpmb
/dev/mmcblk2boot0 /dev/mmcblk2p1 /dev/mmcblk2p3
resize2fs: New size smaller than minimum (1117578)
root@okmx8mm:~# mkdosfs -F 32 /dev/mmcblk2p3
mkfs.fat 4.1 (2017-01-24)
root@okmx8mm:~# insmod
/lib/modules/4.14.78/kernel/drivers/usb/gadget/legacy/g_mass_storage.ko
removable=1 file=/dev/mmcblk2p3
[ 793.029709] Mass Storage Function, version: 2009/09/11
[ 793.034942] LUN: removable file: (no medium)
[ 793.039425] LUN: removable file: /dev/mmcblk2p3
[ 793.044029] Number of LUNs=1
[ 793.047096] g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
[ 793.054104] g_mass_storage gadget: userspace failed to provide iSerialNumber
[ 793.061195] g_mass_storage gadget: g_mass_storage ready
root@okmx8mm:~# [ 798.512590] g_mass_storage gadget: high-speed config #1: Linux
File-Backed Storage
root@okmx8mm:~# mkdir /run/media/mmcblk2p3
root@okmx8mm:~# mount /dev/mmcblk2p3 /run/media/mmcblk2p3

已解决

未解决

只是看看

最新评论

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2024-4-26 01:16

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

返回顶部