qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] installing a boot loader into the disk images
@ 2004-09-11 11:56 Diego Iastrubni
  2004-09-11 13:18 ` Mark A. Williamson
  2004-09-11 14:25 ` Tim
  0 siblings, 2 replies; 8+ messages in thread
From: Diego Iastrubni @ 2004-09-11 11:56 UTC (permalink / raw)
  To: qemu-devel

Hi all

I am sorry if this if offtopic here, if it is, please point me to the correct 
location. (did not find a qemu-users list or something).

I am writing a new installation for linux distro, and I would like to test it 
on qemu before I do it on real HW. 

I found some nice utilities to make a HD image from a a dir, and another one 
for mounting the image on the host, however they are not enough. I need a way 
to partition the HD image, and decide which partition will be (ext3 or swap 
for example), and most importat: I need to install from the host a boot 
loader on the HD image.

The last one is really tricky since last time I tried, lilo did not want to 
use a file, but it insisted on a real device. I did not try grub yet.

As anyone tried such things? how can I do this?

-- 

diego, kde-il translation team

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
Free MS-Office replacement for most platforms
http://www.openoffice.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] installing a boot loader into the disk images
  2004-09-11 11:56 [Qemu-devel] installing a boot loader into the disk images Diego Iastrubni
@ 2004-09-11 13:18 ` Mark A. Williamson
  2004-09-11 14:44   ` Diego Iastrubni
  2004-09-11 19:55   ` Marcello 'R.D.O.' Magnifico
  2004-09-11 14:25 ` Tim
  1 sibling, 2 replies; 8+ messages in thread
From: Mark A. Williamson @ 2004-09-11 13:18 UTC (permalink / raw)
  To: qemu-devel

> I am sorry if this if offtopic here, if it is, please point me to the
> correct location. (did not find a qemu-users list or something).

I think the consensus is that the users list has some problems at the moment.

> I found some nice utilities to make a HD image from a a dir, and another
> one for mounting the image on the host, however they are not enough. I need
> a way to partition the HD image, and decide which partition will be (ext3
> or swap for example), and most importat: I need to install from the host a
> boot loader on the HD image.
>
> The last one is really tricky since last time I tried, lilo did not want to
> use a file, but it insisted on a real device. I did not try grub yet.

I assume you're on a linux host: if it's just a raw HD image, use the losetup 
command to bind the image file to a loop block device (e.g. /dev/loop0), then 
install grub / lilo on that.

The loop block device is handy becuase it allows you to make a file appear as 
a block device to the rest of the OS.  Unfortunately, it does not support 
partitions within the "file" device.  There are patches available on the 
internet which if applied to your host kernel may enable this...

An alternative approach would be to get a working Linux install in QEmu, with 
two virtual hard drives - one containing the stock Linux distro, one 
containing your own.  Then use the stock distro in QEmu to prepare the other 
disk...

HTH,
Mark

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] installing a boot loader into the disk images
  2004-09-11 11:56 [Qemu-devel] installing a boot loader into the disk images Diego Iastrubni
  2004-09-11 13:18 ` Mark A. Williamson
@ 2004-09-11 14:25 ` Tim
  2004-09-12  6:56   ` [Qemu-devel] " Alexander E. Patrakov
  1 sibling, 1 reply; 8+ messages in thread
From: Tim @ 2004-09-11 14:25 UTC (permalink / raw)
  To: qemu-devel

> I found some nice utilities to make a HD image from a a dir, and another one 
> for mounting the image on the host, however they are not enough. I need a way 
> to partition the HD image, and decide which partition will be (ext3 or swap 
> for example), and most importat: I need to install from the host a boot 
> loader on the HD image.
> 
> The last one is really tricky since last time I tried, lilo did not want to 
> use a file, but it insisted on a real device. I did not try grub yet.

Well, you can always boot the blank image in conjunction with a boot
floppy/cd and just do a normal install.

On the other hand, if you are really really wanting to do it from the
host OS, I have found this link handy:

http://rescuecd.sourceforge.net/288.html#grub

hth,
tim

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] installing a boot loader into the disk images
  2004-09-11 13:18 ` Mark A. Williamson
@ 2004-09-11 14:44   ` Diego Iastrubni
  2004-09-11 15:11     ` Mark A. Williamson
  2004-09-11 19:55   ` Marcello 'R.D.O.' Magnifico
  1 sibling, 1 reply; 8+ messages in thread
From: Diego Iastrubni @ 2004-09-11 14:44 UTC (permalink / raw)
  To: qemu-devel

בשבת, 11 בספטמבר 2004, 16:18, נכתב על ידי Mark A. Williamson:
> I assume you're on a linux host: if it's just a raw HD image, use the
> losetup command to bind the image file to a loop block device (e.g.
> /dev/loop0), then install grub / lilo on that.
>
> The loop block device is handy becuase it allows you to make a file appear
> as a block device to the rest of the OS.  Unfortunately, it does not
> support partitions within the "file" device.  There are patches available
> on the internet which if applied to your host kernel may enable this...
Lets take this approach.

Now my problem is:
I use a disk with one partition. I put the kernel on thr proper location and 
install lilo/grub on it. Will this work? I think the boot loader will be 
looking for a normal setup, not this hack.

Another option is still is making a boot floppy, that will mount /dev/hda (the 
raw disk image) as /.  (Thanks Tim).
http://rescuecd.sourceforge.net/288.html#grub

Anyway, you been more then helpfull. Thanks!

-- 

diego, kde-il translation team

Please avoid sending me Word or PowerPoint attachments.
See http://www.fsf.org/philosophy/no-word-attachments.html
Free MS-Office replacement for most platforms
http://www.openoffice.org/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] installing a boot loader into the disk images
  2004-09-11 14:44   ` Diego Iastrubni
@ 2004-09-11 15:11     ` Mark A. Williamson
  2004-09-11 18:06       ` Magnus Damm
  0 siblings, 1 reply; 8+ messages in thread
From: Mark A. Williamson @ 2004-09-11 15:11 UTC (permalink / raw)
  To: qemu-devel

> > The loop block device is handy becuase it allows you to make a file
> > appear as a block device to the rest of the OS.  Unfortunately, it does
> > not support partitions within the "file" device.  There are patches
> > available on the internet which if applied to your host kernel may enable
> > this...
>
> Lets take this approach.
>
> Now my problem is:
> I use a disk with one partition. I put the kernel on thr proper location
> and install lilo/grub on it. Will this work? I think the boot loader will
> be looking for a normal setup, not this hack.

I skirted round this issue a bit ;-)

The loop device would make the file appear like a disk, so you could install a 
bootloader.  You've still, unfortunately, got to get partitions onto it 
somehow.

A brief test suggests that fdisk will manipulate disk files directly, so you 
could probably partition your image using that.  You will be able to losetup 
it then but the kernel won't see the partitions since loop block devices 
don't support partitions.

Depending on whether Lilo / Grub actually use the Linux partition support this 
may still be enough to allow an install to the loop device.

You'll have to figure out a way of getting files onto this disk image at some 
stage :-)  Some possibilities:
* Use a distro running in QEmu to copy the files across (which it could in 
turn get from NFS, SAMBA, etc.)
* Patch your host kernel so that it understands partitions in loop devices
* Use losetup to individually map the partitions to loop devices, using the -o 
(offset) switch, then mount those.  (I saw a script for doing this on a 
mailing list somewhere - Google knows)

Remember while doing all this to avoid having two "views" of the disk at once 
(e.g. avoid setups where the same part of the file appears at multiple 
mountpoints / devices simultaneously, since this may corrupt the image).

Cheers,
Mark

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] installing a boot loader into the disk images
  2004-09-11 15:11     ` Mark A. Williamson
@ 2004-09-11 18:06       ` Magnus Damm
  0 siblings, 0 replies; 8+ messages in thread
From: Magnus Damm @ 2004-09-11 18:06 UTC (permalink / raw)
  To: mark.williamson, qemu-devel

Hello,

> You'll have to figure out a way of getting files onto this disk image at some 
> stage :-)  Some possibilities:
> * Use a distro running in QEmu to copy the files across (which it could in 
> turn get from NFS, SAMBA, etc.)
> * Patch your host kernel so that it understands partitions in loop devices
> * Use losetup to individually map the partitions to loop devices, using the -o 
> (offset) switch, then mount those.  (I saw a script for doing this on a 
> mailing list somewhere - Google knows)

I've created a tool that makes it possible to create and populate
filesystems (ext2/ext3/reiserfs right now) on a disk image. Scriptable
without root permissions. 

This tool is actually a small custom linux distribution (< 3 Mbytes)
desigend to be executed in the QEMU environment. It is possible to pass
a set of commands or a script to the QEMU environment for easy
scripting. Files are transfered from the host to the guest with TFTP.
Busybox fdisk is included (if I remember correctly that is), but no
lilo/grub yet. You need a recent CVS snapshot of QEMU or 0.6.0 with a
patch to get the tftp support.

I really would like to get this project out of my closet, one big
problem right now is that the entire source code is so damn large (> 100
Mbytes) and I need a way to distribute that amount of data. I was
thinking bittorrent, does anyone know a good tracker for FOSS?

Thanks!

/ magnus

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Qemu-devel] installing a boot loader into the disk images
  2004-09-11 13:18 ` Mark A. Williamson
  2004-09-11 14:44   ` Diego Iastrubni
@ 2004-09-11 19:55   ` Marcello 'R.D.O.' Magnifico
  1 sibling, 0 replies; 8+ messages in thread
From: Marcello 'R.D.O.' Magnifico @ 2004-09-11 19:55 UTC (permalink / raw)
  To: qemu-devel

> An alternative approach would be to get a working Linux install in
> QEmu, with two virtual hard drives - one containing the stock Linux  
> distro, one containing your own.  Then use the stock distro in QEmu  
> to prepare the other disk...

Floppydistros may fit. I personally partition my disk images via a  
bootable Linux floppy containing the GNU PartEd. Never tried LILO or  
GRUB stuff, because I usually let the real distro to do the right job.
If you just need a bootloader (ANY bootloader), I use GAG  
(http://gag.sourceforge.net/) for real machines, and find it to be very  
practical. Its approach implies that there's nothing else than GAG  
itself in the MBR; so you'll have to tell your OS'es of choice to place  
their LILO/GRUB/whatever in the boot sector of their own partition, and  
nowhere else, while installing. This might seem odd, but I never  
encountered yet an OS that GAG can't start; and it's quite easy and  
quick to get back if corrupted or overwritten, say, by a Windows  
reinstallation.


	yo,
	RDO

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Qemu-devel] Re: installing a boot loader into the disk images
  2004-09-11 14:25 ` Tim
@ 2004-09-12  6:56   ` Alexander E. Patrakov
  0 siblings, 0 replies; 8+ messages in thread
From: Alexander E. Patrakov @ 2004-09-12  6:56 UTC (permalink / raw)
  To: qemu-devel

Tim wrote:
>>I found some nice utilities to make a HD image from a a dir, and another one 
>>for mounting the image on the host, however they are not enough. I need a way 
>>to partition the HD image, and decide which partition will be (ext3 or swap 
>>for example), and most importat: I need to install from the host a boot 
>>loader on the HD image.
>>
>>The last one is really tricky since last time I tried, lilo did not want to 
>>use a file, but it insisted on a real device. I did not try grub yet.
> 
> 
> Well, you can always boot the blank image in conjunction with a boot
> floppy/cd and just do a normal install.
> 
> On the other hand, if you are really really wanting to do it from the
> host OS, I have found this link handy:
> 
> http://rescuecd.sourceforge.net/288.html#grub

You can also use EVMS to partition the loop device. This is a complete 
replacement of lomount. But it's like (as Russians say) shooting 
sparrows from a big cannon.

-- 
Alexander E. Patrakov

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-09-12  7:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-11 11:56 [Qemu-devel] installing a boot loader into the disk images Diego Iastrubni
2004-09-11 13:18 ` Mark A. Williamson
2004-09-11 14:44   ` Diego Iastrubni
2004-09-11 15:11     ` Mark A. Williamson
2004-09-11 18:06       ` Magnus Damm
2004-09-11 19:55   ` Marcello 'R.D.O.' Magnifico
2004-09-11 14:25 ` Tim
2004-09-12  6:56   ` [Qemu-devel] " Alexander E. Patrakov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).