qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to add files to an existing img partition.


From: Frantisek Rysanek
Subject: Re: How to add files to an existing img partition.
Date: Sun, 28 Jun 2020 16:18:53 +0200

Dear Dan,

I do not have an answer on "how to do all this in Windows".
Not an easy one anyway.
*Are we* talking Windows btw?

Some of the things that you're asking for, might be worked around by 
booting Windows (or DOS!) and Ghost or Partition Magic in a VM, 
providing the disk images to the VM, and arranging network-based 
remote access into or out of the VM, to copy your data.
The question is, what hypervisor to use. E.g. VirtualBox apparently 
does not support raw images. It does support VHD images = the "VHD 
footer" that you're talking about probably means some metadata 
section, for VirtualBox and others to understand the image as a VHD 
image (even if the contents are raw and complete, i.e. not sparse, 
not compressed, not capable of Copy On Write or whatever).

As for Partition Magic in a VM, there's a catch:
Partition Magic can resize a partition.
But, you need to resize the "disk" too :-)
Maybe resize the partition inside and then truncate the image file?
And yes, it would require some manual maths, and some tool
to crop the file after a given number of bytes (in Linux I'd use 
"dd").

My favourite platform for various partitioning and disk cloning is 
Linux. I have a PXE-bootable environment in my lab, where I can boot 
Linux on pretty much any PC hardware and use Linux-based tools to 
inspect the partitioning, I can start DOS or Windows in a VM and pass 
any physical disks to them etc. Raw disk image files are very similar 
to physical disks. Yes the learning curve of Linux is a little steep 
(especially for diskless booting with some custom improvements) but 
once you get the hang of the basics, Windows look like a pile of 
hurdles.

To resize any misc DOS/NTFS disk image (until XP), I'd probably 
create an empty raw image of the desired destination size (all 
zeroes, like a factory clean HDD) and start the DOS-based Ghost 
11.5.1 or some such in a VM, probably using QEMU. I'd pass the 
original "too big" image and the desired destination image as two raw 
drives to the VM. Then, I'd tell Ghost to clone from one raw disk 
image to the other. It is admittedly difficult to arrange scripting 
the GHOST guest from the Linux host to run fully unattended :-(
You'd need to do this over the network, or pass a small disk with a 
script to the guest on VM startup (where the small disk can easily be 
loop-mounted in Linux ahead of VM startup, primed, and unmounted).

You cannot mount a disk twice in parallel, e.g. by the guest VM and 
by the host - although technically this might be possible, you'd end 
up with corrupted data...

Apologies if my response is a mess :-)

BTW, this disk image resizing requirement...
sounds like something that gets handled inherently by the more modern 
image file formats, that are "sparse" or "internally compressed" or 
some such. You just need a hypervisor that supports some of those...
The modern image files make your disk look bigger on the inside, than 
the image actually is on the outside. The image takes just as much 
actual space on the host as it absolutely needs to.
And Yes I do understand that it may be difficult to get all that in 
Android, or in a heterogeneous deployment environment.
I'm not a fan of Android :-)

Frank




reply via email to

[Prev in Thread] Current Thread [Next in Thread]