Create a loop device corresponding to the entire disk image:
1
losetup /dev/loop0 /vieuxpc/vieuxpc.hda.img
Partition the image:
1
fdisk /dev/loop0
List the created partitions:
1
2
3
4
5
6
7
8
fdisk -ul /dev/loop0
Disk /dev/loop0: 20.9 GB, 20971520000 bytes
255 heads, 63 sectors/track, 2549 cylinders, total 40960000 sectors
Units= sectors of 1 * 512=512 bytes
Device Boot Start End Blocks Id System
/dev/loop0p1 6317591174879555683 Linux
/dev/loop0p2 1759117519567169 987997+ 82 Linux swap / Solaris
Install GRUB on the disk using a GRUB rescue floppy:
1
cat /usr/lib/grub/stage[12] > floppy.img
Note: Debian users can install grub-disk, a bootable GRUB image preconfigured to boot many operating systems.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
qemu -fda floppy.img -hda /vieuxpc/vieuxpc.hda.img -boot a
GNU GRUB version 0.95 (639K lower / 31744K upper memory)[ Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists the possible
completions of a device/filename. ]grub> root (hd0,0)Filesystem type is ext2fs, partition type 0x83
grub> setup (hd0)Checking if"/boot/grub/stage1" exists... yes
Checking if"/boot/grub/stage2" exists... yes
Checking if"/boot/grub/e2fs_stage1_5" exists... no
Running "install /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/menu.lst "... succeeded
Done.
grub>
On first boot, reconfigure the network interface, since the physical interface obviously no longer exists. Instead, you have an emulated ne2000 network card.