|
|
|
|
||||||
| linux.debian.user debian-user@lists.debian.org. |
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
What's the best way to create a raw disk image using debootstrap that
can be booted with qemu? I think I've almost figured it out, but I'm not savvy with the low-level file commands. Can you point me in the right direction? I'm hacking together a few sources -- most notably http://www.debian.org/releases/stabl...apds03.html.en -- but I'm missing a couple steps. This is what I think I've got so far: #-------------- 1. Create the raw image ------------ # Create 1GB raw image dd if=/dev/zero of=image.raw bs=1024 count=1048576 # Format it with ext3 file system ??? how to do this ??? ??? can I do it all with a single partition ??? # Mount it mkdir -p image.mount sudo mount -o loop,offset=32256 image.raw image.mount #-------------- 2. Configure a chroot -------------- # Debootstrap it /usr/sbin/debootstrap --arch i386 etch image.mount \ http://ftp.us.debian.org/debian # Create /etc/fstab as follows: ??? what goes in here ??? # Mount the file system inside the chroot sudo chroot image.mount mount -a # ---------- 3. Enable networking ---------------- # Though it'll ultimately be a qemu image, we need # to temporarily use the host's network interface # in order to get apt working. sudo cp /etc/resolv.conf image.mount/etc sudo cp /etc/hosts image.mount/etc #----------- 4. Make it bootable ----------------- # First install the kernel sudo chroot image.mount apt-get update sudo chroot image.mount apt-get install \ linux-image-2.6.24-17-generic # Then install grub sudo chroot image.mount apt-get install grub sudo chroot image.mount apt-get grub-install /dev/???? sudo chroot image.mount apt-get update-grub # ----------- 5. Done, boot it up! ------------ sudo qemu -kernel-kqemu image.raw Granted, at this point its networking will be screwed up, but that's a task for another day. I'm just trying to get it to boot. With this in mind, can you fill in any of the blanks in the above script? Thanks! -david -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sun, Jul 06, 2008 at 09:00:38PM -0700, David Barrett wrote:
> David Barrett wrote: > >What's the best way to create a raw disk image using debootstrap that > >can be booted with qemu? > > Following up on my previous post: I've figured out some of the steps, > but I'm stuck on installing Grub. Do you know how to install grub on a > raw device file? Forgive a silly question, but why do you want to install grub on the image? Are you planning to dd it onto a physical disk? -- Carl Fink nitpicking@nitpicking.com Read my blog at blog.nitpicking.com. Reviews! Observations! Stupid mistakes you can correct! -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#3 |
|
Messages: n/a
Hébergeur: |
Carl Fink wrote:
> On Sun, Jul 06, 2008 at 09:00:38PM -0700, David Barrett wrote: >> David Barrett wrote: >>> What's the best way to create a raw disk image using debootstrap that >>> can be booted with qemu? >> Following up on my previous post: I've figured out some of the steps, >> but I'm stuck on installing Grub. Do you know how to install grub on a >> raw device file? > > Forgive a silly question, but why do you want to install grub on the image? > Are you planning to dd it onto a physical disk? No, I'm just going to use it as a QEMU image. It'll stay virtual, but it'll need to boot all the same. Unless there's some way to get it to boot without grub? -david -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#4 |
|
Messages: n/a
Hébergeur: |
On Sun, Jul 06, 2008 at 11:34:52PM -0700, David Barrett wrote:
> Carl Fink wrote: >> On Sun, Jul 06, 2008 at 09:00:38PM -0700, David Barrett wrote: >>> David Barrett wrote: >>>> What's the best way to create a raw disk image using debootstrap that >>>> can be booted with qemu? >>> Following up on my previous post: I've figured out some of the steps, but >>> I'm stuck on installing Grub. Do you know how to install grub on a raw >>> device file? >> >> Forgive a silly question, but why do you want to install grub on the >> image? Are you planning to dd it onto a physical disk? > > No, I'm just going to use it as a QEMU image. It'll stay virtual, but > it'll need to boot all the same. Unless there's some way to get it to boot > without grub? If I recall correctly, qemu can boot a linux kernel directly so you *probably* don't need grub. Regards, Andrei -- If you can't explain it simply, you don't understand it well enough. (Albert Einstein) -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkhxyKoACgkQqJyztHCFm9m09ACggBwy7gyjvi lsnVAwKvCQ3sA+ qEsAoK3DsSPvF3/zrmmYJtg8DZVyBdxo =WxfZ -----END PGP SIGNATURE----- |
|
|
|
#5 |
|
Messages: n/a
Hébergeur: |
Andrei Popescu wrote:
> On Sun, Jul 06, 2008 at 11:34:52PM -0700, David Barrett wrote: >> Carl Fink wrote: >>> On Sun, Jul 06, 2008 at 09:00:38PM -0700, David Barrett wrote: >>>> David Barrett wrote: >>>>> What's the best way to create a raw disk image using debootstrap that >>>>> can be booted with qemu? >>>> Following up on my previous post: I've figured out some of the steps, but >>>> I'm stuck on installing Grub. Do you know how to install grub on a raw >>>> device file? >>> Forgive a silly question, but why do you want to install grub on the >>> image? Are you planning to dd it onto a physical disk? >> No, I'm just going to use it as a QEMU image. It'll stay virtual, but >> it'll need to boot all the same. Unless there's some way to get it to boot >> without grub? > > If I recall correctly, qemu can boot a linux kernel directly so you > *probably* don't need grub. Aha! I completely forgot about those options. This works great: sudo qemu -kernel-kqemu -kernel newtest.mount/boot/vmlinuz-2.6.18-6-486 -append "root=/dev/hda1 ro" -initrd newtest.mount/boot/initrd.img-2.6.18-6-486 newtest.raw It makes the command line a bit awkward, but does the trick. This is great workaround, thanks! That said, if possible, I'd still like to get grub installed to make it self-contained and boot up like normal (else I need to update all the startup scripts to be aware of the exact kernel version). One way would be to boot the VM with the above trick and then install grub from the inside... but there's *got* to be a way to install it from the outside, straight into the raw image. Joey's idea of grub-mkdevicemap sounds good; I'll need to look into that more. Thanks everyone for all the ! -david -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#6 |
|
Messages: n/a
Hébergeur: |
On Mon, Jul 07, 2008 at 10:41:30AM +0300, Andrei Popescu wrote:
> On Sun, Jul 06, 2008 at 11:34:52PM -0700, David Barrett wrote: > > Carl Fink wrote: > >> On Sun, Jul 06, 2008 at 09:00:38PM -0700, David Barrett wrote: > >>> David Barrett wrote: > >>>> What's the best way to create a raw disk image using debootstrap that > >>>> can be booted with qemu? > >>> Following up on my previous post: I've figured out some of the steps, but > >>> I'm stuck on installing Grub. Do you know how to install grub on a raw > >>> device file? > >> > >> Forgive a silly question, but why do you want to install grub on the > >> image? Are you planning to dd it onto a physical disk? > > > > No, I'm just going to use it as a QEMU image. It'll stay virtual, but > > it'll need to boot all the same. Unless there's some way to get it to boot > > without grub? > > If I recall correctly, qemu can boot a linux kernel directly so you > *probably* don't need grub. That's where I was leading. I don't know qemu, but I do recall, for instance, loadlin, and made a mental analogy. -- Carl Fink nitpicking@nitpicking.com Read my blog at blog.nitpicking.com. Reviews! Observations! Stupid mistakes you can correct! -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
|
|
#7 |
|
Messages: n/a
Hébergeur: |
On Mon, Jul 07, 2008 at 01:18:22AM -0700, David Barrett wrote:
> Andrei Popescu wrote: >> On Sun, Jul 06, 2008 at 11:34:52PM -0700, David Barrett wrote: >>> Carl Fink wrote: >>>> On Sun, Jul 06, 2008 at 09:00:38PM -0700, David Barrett wrote: >>>>> David Barrett wrote: >>>>>> What's the best way to create a raw disk image using >>>>>> debootstrap that can be booted with qemu? >>>>> Following up on my previous post: I've figured out some of the >>>>> steps, but I'm stuck on installing Grub. Do you know how to >>>>> install grub on a raw device file? >>>> Forgive a silly question, but why do you want to install grub on >>>> the image? Are you planning to dd it onto a physical disk? >>> No, I'm just going to use it as a QEMU image. It'll stay virtual, >>> but it'll need to boot all the same. Unless there's some way to get >>> it to boot without grub? >> >> If I recall correctly, qemu can boot a linux kernel directly so you >> *probably* don't need grub. > > Aha! I completely forgot about those options. This works great: > > sudo qemu -kernel-kqemu -kernel newtest.mount/boot/vmlinuz-2.6.18-6-486 > -append "root=/dev/hda1 ro" -initrd > newtest.mount/boot/initrd.img-2.6.18-6-486 newtest.raw > > It makes the command line a bit awkward, but does the trick. This is > great workaround, thanks! > > That said, if possible, I'd still like to get grub installed to make it > self-contained and boot up like normal (else I need to update all the > startup scripts to be aware of the exact kernel version). can you not use the grub floppy disk image and just cat it into the boot sector? Another idea: write a script to install grub from a chroot, copy that script into the image, and then chroot in and run that script from your other script. or: make a barebones image with grub installed by some other non-automated method and then use that bare image as the starting point for your script, eliminating the dd step. just .02 A -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFIcnTLaIeIEqwil4YRAvERAKCfZymDSLMcbXL/j5H+dg9vU8bOyQCdG2RE xjl7caOnhmF6JZPDqoeJWs8= =fSc2 -----END PGP SIGNATURE----- |
|
|
|
#8 |
|
Messages: n/a
Hébergeur: |
Hi,
Andrew Sackville-West wrote: > On Mon, Jul 07, 2008 at 01:18:22AM -0700, David Barrett wrote: >> Andrei Popescu wrote: >>> On Sun, Jul 06, 2008 at 11:34:52PM -0700, David Barrett wrote: >>>> Carl Fink wrote: >>>>> On Sun, Jul 06, 2008 at 09:00:38PM -0700, David Barrett wrote: >>>>>> David Barrett wrote: >>>>>>> What's the best way to create a raw disk image using >>>>>>> debootstrap that can be booted with qemu? >>>>>> Following up on my previous post: I've figured out some of the >>>>>> steps, but I'm stuck on installing Grub. Do you know how to >>>>>> install grub on a raw device file? >>>>> Forgive a silly question, but why do you want to install grub on >>>>> the image? Are you planning to dd it onto a physical disk? >>>> No, I'm just going to use it as a QEMU image. It'll stay virtual, >>>> but it'll need to boot all the same. Unless there's some way to get >>>> it to boot without grub? >>> If I recall correctly, qemu can boot a linux kernel directly so you >>> *probably* don't need grub. >> Aha! I completely forgot about those options. This works great: >> >> sudo qemu -kernel-kqemu -kernel newtest.mount/boot/vmlinuz-2.6.18-6-486 >> -append "root=/dev/hda1 ro" -initrd >> newtest.mount/boot/initrd.img-2.6.18-6-486 newtest.raw >> >> It makes the command line a bit awkward, but does the trick. This is >> great workaround, thanks! >> >> That said, if possible, I'd still like to get grub installed to make it >> self-contained and boot up like normal (else I need to update all the >> startup scripts to be aware of the exact kernel version). > > can you not use the grub floppy disk image and just cat it into the > boot sector? > > Another idea: write a script to install grub from a chroot, > copy that script into the image, and then chroot in and run that > script from your other script. > > or: make a barebones image with grub installed by some other > non-automated method and then use that bare image as the starting > point for your script, eliminating the dd step. > > just .02 > > > A Previously, I had the same problem but I did not know how to deal with the partions (btw. I still have too figure out how did you got those numbers to be able to create smaller disks). The `parted' stuff you posted before was a missing piece of information. Here is a complete sequence of commands that - creates a harddisk image - install multiboot specification compliant kernel to it - install grub to the harddisk image -------------------------------------------------- sudo dd if=/dev/zero of=disk.img bs=1024 count=1048576 sudo parted disk.img mklabel msdos sudo parted disk.img mkpart primary ext2 0 954 sudo parted disk.img mkpart extended 954 1069 sudo parted disk.img mkpart logical linux-swap 954 1069 sudo parted disk.img set 1 boot on sudo parted disk.img mkfs 1 ext2 sudo mount -o loop,offset=16384 -t ext2 disk.img mnt sudo mkdir mnt/grub sudo cp /boot/grub/stage1 mnt/grub sudo cp /boot/grub/stage2 mnt/grub sudo cp /boot/grub/e2fs_stage1_5 mnt/grub # The contents of the `menu.lst' file should be: # # timeout 0 # default 0 # title minimal-kernel # kernel (hd0,0)/minimal-kernel # sudo cp menu.lst mnt/grub # The contents of the `grub.input' file should be: # # device (hd0) disk.img # root (hd0,0) # setup (hd0) # quit # sudo grub --device-map=/dev/null < grub.input # We finally copy a multiboot specification compliant kernel # to our disk image. You can get the one I have tried here: # # http://altair.sk/uploads/minimal-kernel # # Its homepage ![]() # # http://altair.sk/mediawiki/index.php/Minimal_Kernel # sudo cp minimal-kernel mnt sudo umount mnt # And you can boot it ... qemu -m 100 -hda disk.img -boot c -no-kqemu -------------------------------------------------- Somehow this way. -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
|
![]() |
| Outils de la discussion | |
|
|