我有一个mSATA的SSD磁盘的个人电脑的图像。磁盘包含操作系统,容量为512 of。
我没有那个免费的存储空间,所以我把磁盘克隆到一个用dd压缩它的映像中,然后根据这个职位的答案,我复制了稀疏的内容,所以它占用了很少的空间。
这是正确的工作,导致512 5GB的映像占用不到5GB的磁盘。
作为对所做工作的总结:
# dd bs=64K if=/dev/sdd conv=sync,noerror status=progress | gzip -c > /image.img.gz
# gunzip -c /image.img.gz | cp --sparse=always /dev/stdin mini.img
# ls -lhs
4,8G -rw------- 1 balon users 477G ene 13 10:54 mini.img
2,3G -rw-r--r-- 1 balon users 2,3G ene 11 08:32 minimal-industrial-pc.img.gz到目前为止,一切都是正确的。当我打算挂载映像时,问题就出现了(因为我想把自己关在里面,并对文件系统做一些修改)。
我尝试了以下几点:
fdisk# fdisk -l mini.img
The size mismatch of the primary master boot record (GPT PMBR) (1000215215!= 1000215295) will be corrected by writing.
The backup GPT table is not at the end of the device.
Disk mini.img: 476,94 GiB, 512110231552 bytes, 1000215296 sectors
Units: sectores de 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disc label type: gpt
Disk identifier: 74BC899D-E8BA-4C70-B82D-6F4E8F6343A3
Device Start End Sectors Size Type
mini.img1 2048 2203647 2201600 1G EFI System
mini.img2 2203648 6397951 4194304 2G Linux file system
mini.img3 6397952 1000212479 993814528 473.9G Linux file systemkpartx# kpartx -a -v mini.img
GPT:Primary header thinks Alt. header is not at the end of the disk.
GPT:Alternate GPT header not at the end of the disk.
GPT: Use GNU Parted to correct GPT errors.
add map loop1p1 (254:4): 0 2201600 linear 7:1 2048
add map loop1p2 (254:5): 0 4194304 linear 7:1 2203648
add map loop1p3 (254:6): 0 993814528 linear 7:1 6397952在这种情况下,安装loop1p1和loop1p2似乎没有任何问题,但是使用“环1p3”(我理解它对应于Ubuntu根系统),就没有办法了。
gdisk# gdisk -l mini.img
GPT fdisk (gdisk) version 1.0.9.1
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Disk mini.img: 1000215296 sectors, 476.9 GiB
Sector size (logical): 512 bytes
Disk identifier (GUID): 74BC899D-E8BA-4C70-B82D-6F4E8F6343A3
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 1000215182
Partitions will be aligned on 2048-sector boundaries
Total free space is 4717 sectors (2.3 MiB)
Number Start (sector) End (sector) Size Code Name
1 2048 2203647 1.0 GiB EF00
2 2203648 6397951 2.0 GiB 8300
3 6397952 1000212479 473.9 GiB 8300我做错了什么?
发布于 2023-01-13 10:21:31
您的图像可能由于您在dd上使用的标志而损坏。如果您可以重复这个过程,就不要使用dd。相反,
gzip /.../sdd.img.gz
zcat /.../sdd.img.gz | cp --sparse=always /dev/stdin mini.img如果您实际上不需要压缩映像,只需直接从磁盘复制一个稀疏的副本即可:
cp --sparse=always /dev/sdd mini.img如果磁盘/dev/sdd正在被复制时正在使用,那么副本可能会失败--最糟糕的情况是您看不到它们。
https://unix.stackexchange.com/questions/731592
复制相似问题