This shows you the differences between two versions of the page.
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=/ | --initramfs-overlay=/ | ||
all | all | ||
- | </source>}} | + | </code>}} |
===== Building a Guest Kernel ===== | ===== Building a Guest Kernel ===== | ||
- | The initrd doesn' | + | The initrd doesn' |
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</ | + | Edit '' |
- | {{File|/ | + | {{File|/ |
- Virtual hardware drivers | - Virtual hardware drivers | ||
MODULES_VIRTIO=" | MODULES_VIRTIO=" | ||
- | </source>}} | + | </code>}} |
- | Then edit <tt>initrd.default</ | + | Then edit '' |
- | {{File|/ | + | {{File|/ |
HWOPTS=' | HWOPTS=' | ||
MY_HWOPTS=' | MY_HWOPTS=' | ||
- | </source>}} | + | </code>}} |
{{Warning|These files are not protected and will be replaced each time {{Package|direct=yes|sys-kernel/ | {{Warning|These files are not protected and will be replaced each time {{Package|direct=yes|sys-kernel/ | ||
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 | + | 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 |
- | {{Root|<source lang="bash"> | + | {{Root|<code bash> |
cd / | cd / | ||
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, | mv config-x86_64-2.6.34-{sabayon, | ||
mv initramfs-x86_64-2.6.34-{sabayon, | mv initramfs-x86_64-2.6.34-{sabayon, | ||
- | </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:// | --connect qemu+ssh:// | ||
Line 96: | Line 96: | ||
--noreboot \ | --noreboot \ | ||
--autostart | --autostart | ||
- | </source>}} | + | </code>}} |
- | <tt>$ARCH</ | + | '' |
===== 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:// | --connect qemu+ssh:// | ||
Line 107: | Line 107: | ||
--name=$NAME \ | --name=$NAME \ | ||
--file=/ | --file=/ | ||
- | </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:// | Credit for this tip to [[http:// |