我有一个img
包含 3 个分区的文件,如下所示
$ fdisk -l ./disk.img
Disk ./disk.img: 4 GiB, 4294967296 bytes, 8388608 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: 0x90909090
Device Boot Start End Sectors Size Id Type
./disk.img 1 131072 131072 64M ef EFI (FAT-12/16/32)
./disk.img * 131073 1761232 1630160 796M a5 FreeBSD
./disk.img 1761233 8388607 6627375 3.2G b W95 FAT32
我尝试使用以下命令进行挂载,但是没有作用。
sudo mount -o loop,rw,sync,offset=$((1761233*512)) ./disk.img /mnt/usb
下面是挂载后的输出。它显示分区的大小为 63MB,而我预计它接近 3.2G。
$ df -h scratch/usb/
Filesystem Size Used Avail Use% Mounted on
/dev/loop6 63M 16K 63M 1% /mnt/usb
的输出losetup -la
如下
$ sudo losetup -la
NAME SIZELIMIT OFFSET AUTOCLEAR RO BACK-FILE DIO LOG-SEC
/dev/loop1 0 0 1 1 /var/lib/snapd/snaps/core18_2714.snap 0 512
/dev/loop6 0 901751296 1 0 /home/naidu/disk.img 0 512
/dev/loop4 0 0 1 1 /var/lib/snapd/snaps/snapd_17950.snap 0 512
/dev/loop2 0 0 1 1 /var/lib/snapd/snaps/docker_2343.snap 0 512
/dev/loop0 0 0 1 1 /var/lib/snapd/snaps/core18_2708.snap 0 512
/dev/loop5 0 0 1 1 /var/lib/snapd/snaps/snapd_18357.snap 0 512
/dev/loop3 0 0 1 1 /var/lib/snapd/snaps/docker_2746.snap 0 512
命令的输出parted
如下
$ sudo parted ./disk.img print
Model: (file)
Disk /home/naidu/disk.img: 4295MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 512B 67.1MB 67.1MB primary fat16 esp
2 67.1MB 902MB 835MB primary boot
3 902MB 4295MB 3393MB primary fat32
失去dd if=/home/naidu/disk.img bs=512 skip=1761233 count=2 2>/dev/null | gzip -c -9 | base64
控制
H4sIAAAAAAACA3sdMcEp2MVEz0RBgYGJEYgZgOADA4M9gwADBDAxfGCGsRgYGCEqEIBRU0ymZn+A
W7CrX7CrAhC4OYYYGwHpX4YH+i7sYaj53XfjBQNDXPMxyd3sDH/WtBwoYdvCd1bg9VeDJ2fFzkry
cvnl5+kWVxaXpOYqpGQWZ/NyBRSlFhcrJOZVKmSnViqU5CsUpSbl55fwcjGMAuqC0FVBQYmOo+Ew
vEFRkWPi/e+MDLZY4h8At2s1TgAEAAA=
如果这能提供更多线索和解决方法,我也有以下输出
$ gdisk -l ./disk.img
GPT fdisk (gdisk) version 1.0.8
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory.
***************************************************************
Warning! Main partition table overlaps the first partition by 33 blocks!
You will need to delete this partition or resize it in another utility.
Warning! Secondary partition table overlaps the last partition by
33 blocks!
You will need to delete this partition or resize it in another utility.
Disk ./disk.img: 8388608 sectors, 4.0 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 36F01765-7E55-4F88-B946-DD584C8034AC
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 8388574
Partitions will be aligned on 1-sector boundaries
Total free space is 0 sectors (0 bytes)
Number Start (sector) End (sector) Size Code Name
1 1 131072 64.0 MiB EF00 EFI system partition
2 131073 1761232 796.0 MiB A500 FreeBSD disklabel
3 1761233 8388607 3.2 GiB 0700 Microsoft basic data
我在这里遗漏了什么?
答案1
您发布了分区前两个扇区的 base64 编码 gzip 压缩内容。让我们解码、gunzip 并查看内容file
:
<<EOF base64 -d | gzip -cd | file -
H4sIAAAAAAACA3sdMcEp2MVEz0RBgYGJEYgZgOADA4M9gwADBDAxfGCGsRgYGCEqEIBRU0ymZn+A
W7CrX7CrAhC4OYYYGwHpX4YH+i7sYaj53XfjBQNDXPMxyd3sDH/WtBwoYdvCd1bg9VeDJ2fFzkry
cvnl5+kWVxaXpOYqpGQWZ/NyBRSlFhcrJOZVKmSnViqU5CsUpSbl55fwcjGMAuqC0FVBQYmOo+Ew
vEFRkWPi/e+MDLZY4h8At2s1TgAEAAA=
EOF
这是输出:
/dev/stdin: DOS/MBR boot sector, code offset 0x58+2, OEM-ID "BSD4.4 ", sectors/track 63, heads 16, sectors 131072 (volumes > 32 MB), FAT (32 bit), sectors/FAT 1008, reserved 0x1, serial number 0xbf7c1c16, label: "PFSENSE "
sectors 131072
表示文件系统占用 131072x512 字节;这正好是 64 MiB。文件系统中有元数据和结构,因此63M
您从中获得的df -h
数据大小似乎非常正确。
结论:你所安装的是这文件系统。文件系统比分区小得多。