User Tools

Site Tools


kvm

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
kvm [2014/11/24 01:14]
0.0.0.0 created
kvm [2014/11/24 02:11]
ben
Line 6: Line 6:
  
 ===== Building a Host Kernel ===== ===== Building a Host Kernel =====
-{{Root|<source lang="bash">+{{Root|<code bash>
 genkernel \ genkernel \
   --no-clean \   --no-clean \
Line 20: Line 20:
   --initramfs-overlay=/net/universe/mnt/pool/kvm/kernels/build/initramfs-overlay/ \   --initramfs-overlay=/net/universe/mnt/pool/kvm/kernels/build/initramfs-overlay/ \
   all   all
-</source>}}+</code>}}
  
 ===== Building a Guest Kernel ===== ===== Building a Guest Kernel =====
-The initrd doesn't have a udev implementation, so won't create the device nodes for the vda block devices automatically. We have to manually create these, and arrange for them to be available in /dev inside the initrd. <tt>/net/universe/mnt/pool/kvm/kernels/build/initramfs-overlay</tt> contains a /dev directory, and device nodes copied from an live cd.+The initrd doesn't have a udev implementation, so won't create the device nodes for the vda block devices automatically. We have to manually create these, and arrange for them to be available in /dev inside the initrd. ''/net/universe/mnt/pool/kvm/kernels/build/initramfs-overlay'' contains a /dev directory, and device nodes copied from an live cd.
  
 The kvm kernel configs also build the virtio device drivers as modules, so these need to be loaded into the initramfs before the main system can boot. Genkernel does not currently include these modules by default, so the default initramfs scripts need to be updated to add support. The kvm kernel configs also build the virtio device drivers as modules, so these need to be loaded into the initramfs before the main system can boot. Genkernel does not currently include these modules by default, so the default initramfs scripts need to be updated to add support.
  
-Edit <tt>module_load</tt> to have the modules included in the initramfs: +Edit ''module_load'' to have the modules included in the initramfs: 
-{{File|/usr/share/genkernel/arch/x86_64/module_load|<source lang="bash">+{{File|/usr/share/genkernel/arch/x86_64/module_load|<code bash>
   - Virtual hardware drivers   - Virtual hardware drivers
 MODULES_VIRTIO="virtio virtio_balloon virtio_console virtio_net virtio_blk virtio_pci virtio_ring" MODULES_VIRTIO="virtio virtio_balloon virtio_console virtio_net virtio_blk virtio_pci virtio_ring"
-</source>}}+</code>}}
  
-Then edit <tt>initrd.default</tt> to recognise the new VIRTIO module group and have the modules modprobe'd during the <tt>/linuxrc</tt>+Then edit ''initrd.default'' to recognise the new VIRTIO module group and have the modules modprobe'd during the ''/linuxrc''
-{{File|/usr/share/genkernel/default/initrd.default|<source lang="bash">+{{File|/usr/share/genkernel/default/initrd.default|<code bash>
 HWOPTS='keymap cache modules pata sata scsi usb firewire waitscan slowusb evms lvm dmraid mdadm fs net virtio' HWOPTS='keymap cache modules pata sata scsi usb firewire waitscan slowusb evms lvm dmraid mdadm fs net virtio'
 MY_HWOPTS='modules pata sata scsi usb firewire waitscan dmraid mdadm fs net iscsi virtio' MY_HWOPTS='modules pata sata scsi usb firewire waitscan dmraid mdadm fs net iscsi virtio'
-</source>}}+</code>}}
  
 {{Warning|These files are not protected and will be replaced each time {{Package|direct=yes|sys-kernel/genkernel}} is updated.}} {{Warning|These files are not protected and will be replaced each time {{Package|direct=yes|sys-kernel/genkernel}} is updated.}}
  
 Now build the kernel, initrd, and modules packages with the following command line: Now build the kernel, initrd, and modules packages with the following command line:
-{{Root|<source lang="bash">+{{Root|<code bash>
 genkernel \ genkernel \
   --no-clean \   --no-clean \
Line 62: Line 62:
   --no-install \   --no-install \
   all   all
-</source>}}+</code>}}
  
-This will build a bzip'd tarball of the kernel files, and another package containing all the modules. Extract the kernel files from the archive and put them in the right place. The generated files wont have the correct <tt>kernname</tt> either, so fix that at the same time. +This will build a bzip'd tarball of the kernel files, and another package containing all the modules. Extract the kernel files from the archive and put them in the right place. The generated files wont have the correct ''kernname'' either, so fix that at the same time. 
-{{Root|<source lang="bash">+{{Root|<code bash>
 cd /net/universe/mnt/pool/kvm/kernels/ cd /net/universe/mnt/pool/kvm/kernels/
 tar -xjf kernel-x86_6x-2.6.35-kvm-sabayon-r6.tar.bz2 tar -xjf kernel-x86_6x-2.6.35-kvm-sabayon-r6.tar.bz2
Line 71: Line 71:
 mv config-x86_64-2.6.34-{sabayon,kvm-sabayon}-r6 mv config-x86_64-2.6.34-{sabayon,kvm-sabayon}-r6
 mv initramfs-x86_64-2.6.34-{sabayon,kvm-sabayon}-r6 mv initramfs-x86_64-2.6.34-{sabayon,kvm-sabayon}-r6
-</source>}}+</code>}}
  
 The modules package needs to be copied into the guest, and extracted into the root filesystem. Finally, edit the domain config to use the new kernel and initramfs, then reboot the guest and hope for the best. The modules package needs to be copied into the guest, and extracted into the root filesystem. Finally, edit the domain config to use the new kernel and initramfs, then reboot the guest and hope for the best.
  
 ===== Provision a new VM using the command line ===== ===== Provision a new VM using the command line =====
-{{Root|<source lang="bash">+{{Root|<code bash>
 virt-install \ virt-install \
   --connect qemu+ssh://root@$VMHOST/system \   --connect qemu+ssh://root@$VMHOST/system \
Line 96: Line 96:
   --noreboot \   --noreboot \
   --autostart   --autostart
-</source>}}+</code>}}
  
-<tt>$ARCH</tt> should be one of <tt>x86_64</tt> or <tt>i686</tt><tt>$RAM</tt> is the amount of memory in MB, and <tt>$DISKSIZE</tt> is the size of the vritual disk drive in GB.+''$ARCH'' should be one of ''x86_64'' or ''i686''''$RAM'' is the amount of memory in MB, and ''$DISKSIZE'' is the size of the vritual disk drive in GB.
  
 ===== Creating a new instance of a template ===== ===== Creating a new instance of a template =====
-{{Root|<source lang="bash">+{{Root|<code bash>
 virt-clone \ virt-clone \
   --connect qemu+ssh://root@$VMHOST/system \   --connect qemu+ssh://root@$VMHOST/system \
Line 107: Line 107:
   --name=$NAME \   --name=$NAME \
   --file=/var/lib/libvirt/images/$NAME.img   --file=/var/lib/libvirt/images/$NAME.img
-</source>}}+</code>}}
  
 ===== Sending SysRq keys ===== ===== Sending SysRq keys =====
 You can use virsh to send SysRq key presses to guests; handy if things get stuck and you want to force a slighly more graceful reboot than pulling the virtual power. You can use virsh to send SysRq key presses to guests; handy if things get stuck and you want to force a slighly more graceful reboot than pulling the virtual power.
  
-{{Root|<source lang="bash">+{{Root|<code bash>
   - where $key is one of REISUB   - where $key is one of REISUB
 virsh send-key $domain KEY_LEFTALT KEY_SYSRQ KEY_${key} virsh send-key $domain KEY_LEFTALT KEY_SYSRQ KEY_${key}
-</source>}}+</code>}}
  
 Credit for this tip to [[http://dustymabe.com/2012/04/21/send-magic-sysrq-to-a-kvm-guest-using-virsh/|Dusty Mabe]] for this. Credit for this tip to [[http://dustymabe.com/2012/04/21/send-magic-sysrq-to-a-kvm-guest-using-virsh/|Dusty Mabe]] for this.
kvm.txt · Last modified: 2014/11/24 02:11 by ben