Rob Landley (landley) wrote,
Rob Landley
landley

  • Mood:

kvm and the art of unicyle maintenance.

So, if you need a debian chroot for some reason, here's whatcha do. (As root, assuming you install all these commands.)

debootstrap lenny ~/lenny
chroot lenny
passwd # set the root password

Now make an ext2 image out of it.

genext2fs -z -d ~/lenny -i 1024 \
-b $((1024*(($(du -m -s ~/lenny | awk '{print $1}')*12)/10))) lenny.ext2
resize2fs lenny.ext2 2048M
tune2fs -c 0 -i 0 -j lenny.ext2

(I have no idea why genext2fs won't calculate the number of blocks it needs, that -b blob calculates is the amount of space it's using plus 20% for various administrative overhead like inode tables and such. It then fluffs it up to 2 gigabytes as a separate step; you could just tell genext2fs to make a big image but for some reason its behavior is nonlinear so that takes over 10 minutes to do that while the two steps separately are a few seconds each. Oh, and genext2fs creates an 11 megabyte _empty_ lost+found directory, you might want to delete that.)

Now you can chown lenny.ext2 back to a non-root user and switch over to there, build a kernel, and boot it up under kvm:

kvm -m 1024 -kernel arch/x86/boot/bzImage -no-reboot -hda ~/lenny.ext2 \
-append "root=/dev/hda rw panic=1" -net nic,model=e1000 -net user

When it boots up, you'll need a bit more configuration (starting with "dhclient eth0", maybe "aptitude update", and lots of aptitude install packages), but that's another post.
Tags: dullboy
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 0 comments