fdisk /dev/loop0
m 显示fdisk的命令帮助
x 进入高级菜单
p 列出分区表,查看uuid等信息
r 返回基本菜单
or
p 列出分区表,看看分区Type,大小
i
2 显示分区2的信息UUID会用到
2.删除新建分区
//删除新建
fdisk /dev/loop0
d
2 删除分区2
n
2 创建分区2
Start扇区要和原来保持一致,结束扇区只要比之前大就可以
是否要清楚分区签名 no
//修改分区类型(新版本默认不用修改)
t
2 修改分区2的类型
op23的官方版,类型为20 (Linux filesystem), 默认就是
//修改新建分区uuid
x 进入高级菜单
u 修改分区2的UUID和原来保持一致
r 返回基本菜单
w 保存
4.格式转换
dnf install -y qemu-img
qemu-img convert -f raw -O vdi disk.img disk.vdi
qemu-img convert -f raw -O qcow2 test.img test.qcow2
or
VBoxManage convertdd disk.img disk.vdi
5.挂载磁盘启动
pass
losetup help
[root@vgt-rocky9-60 ~]# losetup --help
Usage:
losetup [options] [<loopdev>]
losetup [options] -f | <loopdev> <file>
Set up and control loop devices.
Options:
-a, --all list all used devices
-d, --detach <loopdev>... detach one or more devices ### 移除设备
-D, --detach-all detach all used devices ### 移除所有未使用设备
-f, --find find first unused device ### 自动挂载未使用第一个loop设备 loop0..loopn
-c, --set-capacity <loopdev> resize the device
-j, --associated <file> list all devices associated with <file>
-L, --nooverlap avoid possible conflict between devices
-o, --offset <num> start at offset <num> into file
--sizelimit <num> device is limited to <num> bytes of the file
-b, --sector-size <num> set the logical sector size to <num>
-P, --partscan create a partitioned loop device ### 分区设备盘
-r, --read-only set up a read-only loop device
--direct-io[=<on|off>] open backing file with O_DIRECT
--show print device name after setup (with -f)
-v, --verbose verbose mode
-J, --json use JSON --list output format
-l, --list list info about all or specified (default)
-n, --noheadings don't print headings for --list output
-O, --output <cols> specify columns to output for --list
--output-all output all columns
--raw use raw --list output format
-h, --help display this help
-V, --version display version
Welcome to fdisk (util-linux 2.37.4). 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 openwrt-x86-64-generic-ext4-combined-efi.img: 1.43 GiB, 1535409664 bytes, 2998847 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: gpt Disk identifier: 38948C92-761D-992A-2027-0CEE23BA4000
Device Start End Sectors Size Type openwrt-x86-64-generic-ext4-combined-efi.img1 512 33279 32768 16M Linux filesystem openwrt-x86-64-generic-ext4-combined-efi.img2 33280 2998813 2965534 1.4G Linux filesystem openwrt-x86-64-generic-ext4-combined-efi.img128 34 511 478 239K BIOS boot
Partition table entries are not in disk order.
Command (m for help): m
Help:
GPT M enter protective/hybrid MBR
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 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
Command (m for help):
Command (m for help): i Partition number (1,2,128, default 128): 2
GPT i change disk GUID n change partition name u change partition UUID ### 更新分区表uuid l change table length M enter protective/hybrid MBR
A toggle the legacy BIOS bootable flag B toggle the no block IO protocol flag R toggle the required partition flag S toggle the GUID specific bits
Generic p print the partition table v verify the partition table d print the raw data of the first sector from the device D print the raw data of the disklabel from the device f fix partitions order m print this menu
Save & Exit q quit without saving changes r return to main menu ### 退回正常菜单