[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 13:19:56 +0200 |
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
Re: How to add files to an existing img partition.,
Frantisek Rysanek <=
Re: How to add files to an existing img partition., Narcis Garcia, 2020/06/28