スパースディスクイメージをマウントする方法

スパースディスクイメージをマウントする方法

私のPCのmSATA SSDディスクイメージがあります。このディスクにはオペレーティングシステムが含まれており、容量は512 GBです。

空き容量がないため、ディスクをイメージに複製し、次のようにdd圧縮しました。gzこの投稿、スペースを少なくするようにリーンな内容をコピーしました。

これは正しく機能し、512 GBのイメージがディスク上の5 GB未満を占めます。

完了したタスクを要約すると、次のようになります。

# 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

これまではすべてが正しいです。イメージをマウントしようとすると問題が発生します(自分自身をイメージに含めてファイルシステムをいくつか変更したいからです)。

私は以下を試しました:

  1. 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 system
  1. kpartx
# 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知っているとは、Ubuntuのルートシステムに対応する `loop1p3 'には方法がありません。

  1. 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

私は何が間違っていましたか?

ベストアンサー1

で使用したロゴは画像を損傷する可能性がありますdd。プロセスを繰り返すことができる場合は、代わりに使用しないでくださいdd

gzip </dev/sdd >/.../sdd.img.gz
zcat /.../sdd.img.gz | cp --sparse=always /dev/stdin mini.img

これをさらに改善するには、実際にイメージを圧縮する必要がない場合は、ディスクから直接レアコピーを作成してください。

cp --sparse=always /dev/sdd mini.img

ディスク/dev/sddのコピー中に使用していると、コピーの整合性チェックが失敗する可能性があります。最悪のシナリオは、ディスクが表示されないことです。

おすすめ記事