分类: LINUX
2009-12-06 15:21:32
kvm-img create -f qcow2 /vm/sid1.img 8G |
kvm-nbd /vm/sid1.img |
modprobe nbd nbd-client localhost 1024 /dev/nbd0 |
sfdisk /dev/nbd0 -uM << EOF ,1024,82 ; EOF |
mkswap /dev/nbd0p1 mkfs.ext4 /dev/nbd0p2 |
mount /dev/nbd0p2 /mnt/root/ mkdir -p /mnt/root/var/cache/apt/archives/ mkdir -p /mnt/root/var/lib/apt/lists/ mount -o bind /var/cache/apt/archives/ /mnt/root/var/cache/apt/archives/ mount -o bind /var/lib/apt/lists/ /mnt/root/var/lib/apt/lists/ |
/usr/sbin/debootstrap --arch amd64 sid /mnt/root |
LANG=C chroot /mnt/root /bin/bash |
mount -t proc proc /proc apt-get -y install linux-image-2.6-amd64 apt-get -y install grub-pc |
cat >>/etc/fstab < sysfs /sys sysfs defaults 0 0 /dev/vda1 none swap sw 0 0 /dev/vda2 / ext4 defaults 0 1 EOF cat >>/etc/network/interfaces< iface lo inet loopback auto eth0 iface eth0 inet static address 10.10.1.11 netmask 255.255.255.0 auto eth1 iface eth1 inet static address 10.10.2.11 netmask 255.255.255.0 EOF echo "sid1" > /etc/hostname cat >>/etc/hosts < EOF |
passwd root |
exit umount /mnt/root/var/cache/apt/archives/ umount /mnt/root/var/lib/apt/lists/ umount /mnt/root/proc umount /mnt/root nbd-client -d /dev/nbd0 |
grub-mkfloppy grub.img |
kvm -m 1G -fda /root/grub.img -drive file=/vm/sid1.img,if=virtio,index=0,media=disk,boot=on -boot a |
root (hd0,2) linux /vmlinuz root=/dev/vda2 initrd /initrd.img boot |
grub-install --force /dev/vda update-grub shutdown -h now |
kvm -m 1G -drive file=/vm/sid1.img,if=virtio,index=0,media=disk,boot=on |