多分区U盘/磁盘 插入电脑后 有不同的设备节点 如 /dev/sdc1, /dev/sdc2等。
可通过mount命令分开挂载。
多分区的镜像文件该如何挂载, 如以下sdimage.img
river@river-VirtualBox:~/image$ fdisk sdimage.img
Welcome to fdisk (util-linux 2.31.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 sdimage.img: 576 MiB, 603979776 bytes, 1179648 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: 0x09dcfcef
Device Boot Start End Sectors Size Id Type
sdimage.img1 2048 133120 131073 64M b W95 FAT32
sdimage.img2 133121 1179647 1046527 511M 83 Linux
Command (m for help):
该镜像文件有两个分区, 类型分别为b: W95 FAT32, 83: Linux (这里是ext4)
1. 利用mount -o offset选项进行挂载。即偏移地址。
Units: sectors of 1 * 512 = 512 bytes
一个扇区为512bytes。
故第一个分区偏移地址: 512 * 2048 = 1048576
第二个分区偏移地址: 512 * 133121 = 68157952
命令如下:
river@river-VirtualBox:~/image$ sudo mount -v -o offset=1048576 -t vfat sdimage.img ~/mount/boot/
mount: enabling autoclear loopdev flag
mount: going to use the loop device /dev/loop0
/home/river/image/sdimage.img on /home/river/mount/boot type vfat (rw,offset=1048576)
river@river-VirtualBox:~/image$
river@river-VirtualBox:~/image$ sudo mount -v -o offset=68157952 -t ext4 sdimage.img ~/mount/rootfs
mount: enabling autoclear loopdev flag
mount: going to use the loop device /dev/loop1
/home/river/image/sdimage.img on /home/river/mount/rootfs type ext4 (rw,offset=68157952)