New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
How to restore .img file with partition on it?
Hello, I need this as fast way to reinstall/restore OS I create/test on virtual environments.
I convert this image .qcow2
to raw .img file using command
qemu-img convert -f qcow2 -O raw my-os.qcow2 my-os.img
When I checked img file using fdisk I got this
fdisk -lu my-os.img
Disk my-os.img: 8 GiB, 8589934592 bytes, 16777216 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: 0x2c54c34d
Device Boot Start End Sectors Size Id Type
my-os.img1 * 2048 206847 204800 100M 7 HPFS/NTFS/exFAT
my-os.img2 206848 16775167 16568320 7.9G 7 HPFS/NTFS/exFAT
I was planning to restore it on the other virtual machine (using Live Linux CD) using dd
command.
dd if=my-os.img of=/dev/vda1
But obviously this won't work, since the img
file had two partitions.
So should I restore each both .img1 .img2
file to separated partition (e.g. sda1 and sda2) ?
Comments
I am not sure, but this probably works.
But perhaps instead of all that, just write the my-os.img to /dev/vda (not a partition number)
dd if=my-os.img of=/dev/vda
Entire disk structure would be copied to the block device, including any partitions it may have inside.
Thanks for reply, I reach similar idea to use
losetup
orkpartx
, unfortunately my other VPS runs on OpenVZ ( which I kept the backup of .img file ) ,I'll try to run it on my laptop (Arch Linux) and do the test again.