summaryrefslogtreecommitdiff
path: root/buildgnuonqemu.mdwn
blob: 97ce3b83cecd661f12bafeb8af4a43fd294b4bc9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
[[meta copyright="Copyright © 2007 Free Software Foundation, Inc."]]
[[meta license="Permission is granted to copy, distribute and/or modify this
document under the terms of the GNU Free Documentation License, Version 1.2 or
any later version published by the Free Software Foundation; with no Invariant
Sections, no Front-Cover Texts, and no Back-Cover Texts.  A copy of the license
is included in the section entitled
[[GNU_Free_Documentation_License|/fdl]]."]]

Creating a bootable qemu image from a root filesystem and bootloader

1. Create a hard disk image

<pre>qemu-img create -f qcow <imagename.img> <size>G</pre>

2. Use a live CD (better to have a lighter OS like system rescue CD to make the process faster) and the image created to boot.

<pre>qemu -cdrom /dev/cdrom -hda <imagename.img> -boot d</pre>

3. Once system is booted use a partition editing tool (like fdisk, cfdisk, parted, gparted, qtparted ...) to partition the image.

<pre>cfdisk</pre>

create the necessary partitions (root and swap partitions boot, home ... if required)

4. Create a file syatem for the root partiotion

<pre>mke2fs /dev/hda1</pre>

5. Mount the partition 

<pre>mkdir disk
mount /dev/hda1 disk</pre>

6. Copy the file system from the host machine to the mounted directory (use a compressed file system to make the copying faster)

Grab the GNU spapshot from ams' site <http://www.update.uu.se/~ams/home/slask/GNU/>

<pre>scp <user>@<host>:<path to the compressed file system> disk</pre>

7. Uncompress the files

<pre>cd disk
tar -jxvf <compressed filesystem></pre>

8. Unmount the mounted partition

<pre>cd .. 
umount disk</pre>

9. power off the guest OS.

<pre>poweroff</pre>

10. To make the file syatem bootable download a grub floppy image ([[http://hurd.in/pub/Hurd/HurdOnVMware/grub.img][grub.img]])

11. Run qemu to boot into your brand new system 

<pre>qemu -hda <hard disk image.img> -fda grub.img -boot a</pre>

Happy Hacking !!


Make your new system boot from the hard disk

1. Mount your grub image

<pre>mkdir floppy
mount -t ext2 -o loop grub.img floppy</pre>

2. Use previous steps 2 and 5 to boot from a liveCD and mount the partition

<pre>cd disk/boot
scp -r <user>@<host>:<path to mounted floppy image directory>/boot/grub .</pre>

3. Poweroff the guest

<pre>poweroff</pre>

4. Boot new system using floppy image previous step 11

use install to hard disk option if you used the above grub image

or go to grub command line and type

<pre>root (hd0,0)
setup (hd0) </pre>

Now you have a bootable system image. Enjoy Maadi !!

-- PraveenA - 21 Jun 2006