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: DC
Subject: Re: How to add files to an existing img partition.
Date: Sun, 28 Jun 2020 09:22:05 -0400
User-agent: Mozilla/5.0 (Windows NT 6.3; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0

Thanks for all the suggestions, Frantisek.  The two things I'm trying to accomplish are


1) Generate a Win98 bootable partition that can be opened with Bochs on Android.


2) Same with an XP partition.


I've generated both, and tested them, and they work fine.  The problem is two fold


1) For Win98, I don't know how to resize it.  I used the BxImage tool to resize the file (not the partition), and it becomes unreadable.  I have a backup, no problem.


2) For WinXP, I can't edit the one the image generated by Qemu.


If there's a better tool for loading a Windows partition in Android, then absolutely I'm open to suggestions.  I'm not married to Bochs ; that's the only tool that I've been able to use.  I tried others, but during the setup process there's always something that goes wrong.


Here's some more specific detail, maybe too much:



"Hi Dan...

I've just taken a look at Qemu Manager...
...what format is the .IMG file?"

The image file is created by Bochs Bximage.  It's then used as the target of the install process (Win98 and WinXP, in this case) inside Qemm. So eventually it becomes the repository for the hard drive for that operating system.

The source of the Install is an Iso.

"BTW, what makes you believe that PowerISO is able to mount
FAT/FAT32/NTFS volumes, and further, do that from raw HDD images that
can possibly contain an MBR?"

If you look at the attached Win98_PowerIso.jpg, this is the Bochs image containing the Win98 partition that was generated inside the Qemu environment.


"https://www.hackingarticles.in/multiple-ways-to-mount-raw-images-windows/";

This might actually be the answer to my question.  I just need a tool that can open an image enclosing a partition, and be able to resize and add files.

If there's also a tool that performs the entire Install process without having to combine Bochs & Qemu, that would be ideal.


One of the problems with the tools I've seen so far, is that they require you to understand something about the structure of the images, and be able to do calculations. The old partition magic, was just a matter of changing the size of the partition with the tool, and it performs all of the calculations internally.

The utility at http://www.fysnet.net/ultimate/index.htm seems to do the resizing (of a Win98 image), but then requires you to add a Append a VHD footer afterwards. I don't even know what a VHD footer is, and am hoping to be spared that learning process.

See Win98_UltimateImager.jpg for an example.

Note that the Delete & Insert buttons are enabled, in Win98_UltimateImager.jpg.


In contrast, in the XP image shown in WinXP_UltimateImager.jpg, Insert is disabled.  I don't know why it's not editable.


It's taken more than a month, with frustration breaks in between, to finally put together a bootable XP that can be opened in Android, using Bochs and Qemu.

I can't even reproduce the steps taken to build the Windows 98 image.  Almost none of the advice on the web works completely ; there's always some kind of glitch.  So it's been primarily a process of trial & error.


So I think https://www.hackingarticles.in/multiple-ways-to-mount-raw-images-windows will help the most.


If you know of any commercial software that does the entire process of generating a Windows partition in an image that can be loaded by iBochs or Bochs, that would do the trick.

I have the iso files for both 98 and XP, and I've loaded both on a Galaxy Tab S6. But I can't resize the 98 image, and cannot add to the XP image. (That's a summary of the problem)



Regards,


DC


On 6/28/2020 7:19 AM, Frantisek Rysanek wrote:
On 27 Jun 2020 at 23:04, Dan Campbell wrote:
Hi,

I'm using a virtual disc created in Qemu Manager.  It contains a
Windows XP partition.

I'm not able to add files or change anything with PowerISO.  If I
open the c.img file with PowerISO and try to add a few files,
PowerISO returns an error that it has to truncate dozens of folder
names including C:\Windows.

Is there another tool I should be using to make changes to the
partition like add files or install programs?

Hi Dan...

I've just taken a look at Qemu Manager - seems like the software is
getting a little stale :-) But that alone should not be a problem.
I don't know Qemu Manager and have no clue what it does.
Perhaps the key question is: what format is the .IMG file?
Per QEMU docs, "IMG" is not listed as some particular image file
format. It could be a "raw" image in QEMU parlance. Which would mean
that any tool that's able to loop-mount an XP-level NTFS partition
(or is it FAT?) from an image should work fine.

BTW, what makes you believe that PowerISO is able to mount
FAT/FAT32/NTFS volumes, and further, do that from raw HDD images that
can possibly contain an MBR? Doesn't seem to be the right tool for
the job... Take a look here:
https://www.hackingarticles.in/multiple-ways-to-mount-raw-images-windo
ws/
I believe these tools are all commercial software.

In Linux, I'd suggest to loop-mount the image:
mount -o loop /my_raw.img /where
But if the image is not a single partition (or a floppy in the old
days), i.e. zector 0 in the image is not a filesystem bootsector,
i.e. sector 0 contains a partition table, you will need to refer to
the particular partition. In Linux I'd start using one of the
following, to learn about the partition layout within the image:
   fdisk my_raw.img
   sfdisk -l  my_raw.img
   sfdisk -d my_raw.img
...and figure out the offset of the boot sector of your partition of
choice. You need to multiply the starting sector number (zero-based)
by the number of bytes in a sector (typically 512). E.g., suppose the
partition starts at sector 63. In that case, I'd use
mount -o loop,offset=32256 /my_raw.img /where

>From there, it's a matter of having the right filesystem drivers in your kernel for NTFS/FAT/FAT32/EXFAT/whatever, and maybe having the
right flavour of the user-space mount tool in your Linux OS.

If you're interesting to learn more about HDD partitioning, try this
howto:
https://www.tldp.org/HOWTO/Partition/index.html
It is nowadays a little dated (with UEFI, GPT, 4k sector size and
binary alignment) but should be valid for XP-level partitioning
= for the legacy BIOS master boot record and its partition table.

The above should be valid for raw images = bitwise identical copies
of a harddisk. Note that QEMU can use more advanced image files that
are not raw, such as the qcow2 and others. Other hypervisors have
their proprietary image formats in various versions... I can see that
mounting qcow2 images should be possible in Linux:
https://www.google.com/search?q=how+to+loop-mount+a+qcow2+image

This is just a quick idea off the top of my head.

Frank Rysanek


Attachment: Win98_PowerIso.jpg
Description: JPEG image

Attachment: Win98_UltimateImager.jpg
Description: JPEG image

Attachment: WinXP_UltimateImager.jpg
Description: JPEG image


reply via email to

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