no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | netbsd_xen [2015/06/01 23:01] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== NetBSD Xen ====== | ||
+ | * [[NetBSD]] | ||
+ | * [[Xen]] | ||
+ | * [[disklabel]] | ||
+ | * [[grub]] | ||
+ | * [[vnconfig]] | ||
+ | * [[newfs]] | ||
+ | |||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * [[ftp:// | ||
+ | ==== Installing NetBSD as Dom0 ==== | ||
+ | |||
+ | In Xen, Dom0 is the main OS that handles all the Xen virtual domains (called domU). | ||
+ | |||
+ | |||
+ | As of version 4.2, Xen can be built natively on NetBSD without patches, although I haven' | ||
+ | |||
+ | === Initial Setup === | ||
+ | |||
+ | First, do a NetBSD install as normal. | ||
+ | |||
+ | === Primary Kernel === | ||
+ | |||
+ | There are two parts to the kernel for booting NetBSD with support for Xen as dom0. The first one is built by your system, and it is the kernel that NetBSD boots first. | ||
+ | |||
+ | Build and install the first Xen kernel: | ||
+ | |||
+ | < | ||
+ | cd / | ||
+ | make install | ||
+ | </ | ||
+ | |||
+ | Once it's built, there will be a '' | ||
+ | |||
+ | Copy the '' | ||
+ | |||
+ | The NetBSD Xen guide keeps the kernel as a gzipped file, but when using GRUB as a bootloader, it wouldn' | ||
+ | |||
+ | < | ||
+ | cp / | ||
+ | gunzip /xen.gz | ||
+ | </ | ||
+ | |||
+ | === Secondary Kernel === | ||
+ | |||
+ | Next, download the Xen DOM0 kernel from NetBSD' | ||
+ | |||
+ | < | ||
+ | ftp ftp:// | ||
+ | </ | ||
+ | |||
+ | Move it to the root filesystem and unpack it as well: | ||
+ | |||
+ | < | ||
+ | mv netbsd-XEN3_DOM0.gz / | ||
+ | gunzip / | ||
+ | </ | ||
+ | |||
+ | === Xen Tools === | ||
+ | |||
+ | As a master domain, you'll need some Xen tools installed to maintain installations. | ||
+ | |||
+ | < | ||
+ | cd / | ||
+ | make install | ||
+ | </ | ||
+ | |||
+ | === Setup GRUB Bootloader === | ||
+ | |||
+ | There are two ways to boot into the NetBSD Xen kernel: using the original bootloader, or installing GRUB. I prefer using GRUB because I'm familiar with the syntax, and it can chainload into the NetBSD bootloader as well. | ||
+ | |||
+ | Install GRUB on the system: | ||
+ | |||
+ | < | ||
+ | cd / | ||
+ | make install | ||
+ | </ | ||
+ | |||
+ | Create a configuration file for GRUB at ''/ | ||
+ | |||
+ | < | ||
+ | default 0 | ||
+ | timeout 10 | ||
+ | |||
+ | # Load NetBSD Xen through GRUB | ||
+ | title NetBSD Xen | ||
+ | root (hd0,0,a) | ||
+ | kernel /xen dom0_mem=512M | ||
+ | module / | ||
+ | |||
+ | # Jump to NetBSD bootloader | ||
+ | title NetBSD Bootloader | ||
+ | root (hd0,0,a) | ||
+ | chainloader +1 | ||
+ | </ | ||
+ | |||
+ | Install GRUB as your bootloader: | ||
+ | |||
+ | < | ||
+ | grub-install ' | ||
+ | </ | ||
+ | |||
+ | You can pass the device name directly as well, if you know it: | ||
+ | |||
+ | < | ||
+ | grub-install /dev/wd0d | ||
+ | </ | ||
+ | |||
+ | An alternative way to install: | ||
+ | |||
+ | < | ||
+ | grub --no-curses | ||
+ | root (hd0,0,a) | ||
+ | setup (hd0) | ||
+ | </ | ||
+ | |||
+ | === Setup NetBSD Bootloader === | ||
+ | |||
+ | You can alternatively use the default NetBSD bootloader, although I haven' | ||
+ | |||
+ | Add this menu entry to ''/ | ||
+ | |||
+ | < | ||
+ | menu=NetBSD Xen:load / | ||
+ | </ | ||
+ | |||
+ | === Copying Files === | ||
+ | |||
+ | There are some example files installed with the xentools package that need to be copied over to the right locations so they can be used. | ||
+ | |||
+ | == Init scripts == | ||
+ | |||
+ | < | ||
+ | cp / | ||
+ | </ | ||
+ | |||
+ | Update ''/ | ||
+ | |||
+ | < | ||
+ | xenwatchdog=YES | ||
+ | xencommons=YES | ||
+ | xend=YES | ||
+ | xendomains=YES | ||
+ | </ | ||
+ | |||
+ | == Xen Scripts == | ||
+ | |||
+ | < | ||
+ | cp / | ||
+ | </ | ||
+ | |||
+ | == Device Files == | ||
+ | |||
+ | Setup the new Xen device files: | ||
+ | |||
+ | < | ||
+ | cd /dev && sh MAKEDEV xen | ||
+ | </ | ||
+ | |||
+ | ==== Installing NetBSD as DomU ==== | ||
+ | |||
+ | Now to create a NetBSD virtual machine. | ||
+ | |||
+ | For the base directories in this guide, I'm going to use ''/ | ||
+ | |||
+ | === Create Network Adapter === | ||
+ | |||
+ | Bridge the main Ethernet device ('' | ||
+ | |||
+ | Create this file: ''/ | ||
+ | |||
+ | < | ||
+ | create | ||
+ | !brconfig $int add bnx0 up | ||
+ | </ | ||
+ | |||
+ | Reboot the '' | ||
+ | |||
+ | === Create Hard Drive === | ||
+ | |||
+ | Create a hard drive with as many GBs as you want. In this example, I'm using 4 GB (4096): | ||
+ | |||
+ | < | ||
+ | dd if=/ | ||
+ | </ | ||
+ | |||
+ | Mount the drive, and give it an MBR: | ||
+ | |||
+ | < | ||
+ | vnconfig vnd0 netbsd.img | ||
+ | fdisk -l /dev/vnd0d | ||
+ | vnconfig -u vnd0 | ||
+ | </ | ||
+ | |||
+ | === Create Xen Configuration File === | ||
+ | |||
+ | Create a new file, '' | ||
+ | |||
+ | < | ||
+ | # use this kernel to boot and install | ||
+ | kernel = "/ | ||
+ | # use this kernel once install is complete | ||
+ | # kernel = "/ | ||
+ | memory = 1024 | ||
+ | name = " | ||
+ | vcpus = 2 | ||
+ | vif = [ ' | ||
+ | disk = [ ' | ||
+ | root = " | ||
+ | </ | ||
+ | |||
+ | === Install NetBSD === | ||
+ | |||
+ | Install NetBSD as usual, using FTP to download the base install. | ||
+ | |||
+ | < | ||
+ | xm create -c netbsd-xen | ||
+ | </ | ||
+ | |||
+ | Once you're finished, shutdown the install, and close it out with '' | ||
+ | |||
+ | < | ||
+ | xm shutdown netbsd-xen | ||
+ | xm destroy netbsd-xen | ||
+ | </ | ||
+ | |||
+ | Edit the '' | ||
+ | |||
+ | < | ||
+ | xm create -c netbsd-xen | ||
+ | </ | ||
+ | |||
+ | ==== Installing Linux as DomU ==== | ||
+ | |||
+ | I haven' | ||
+ | |||
+ | * Create a disk and a swap image | ||
+ | * Format the images | ||
+ | * Install GRUB | ||
+ | |||
+ | They need GRUB installed on the root disk. Pygrub then runs from NetBSD and boots off the GRUB install of that box. | ||
+ | |||
+ | So, you need an image that is already created and formatted before doing anything. | ||
+ | |||
+ | Here is a cobbled-together '' | ||
+ | |||
+ | < | ||
+ | bootloader = '/ | ||
+ | vcpus = ' | ||
+ | memory | ||
+ | root = '/ | ||
+ | disk = [ | ||
+ | ' | ||
+ | ' | ||
+ | ] | ||
+ | name = ' | ||
+ | dhcp = ' | ||
+ | vif = [ ' | ||
+ | on_poweroff = ' | ||
+ | on_reboot | ||
+ | on_crash | ||
+ | </ | ||
+ | |||
+ | ==== Install Ubuntu as DomU ==== | ||
+ | |||
+ | * [[http:// | ||
+ | |||
+ | Download the Ubuntu Xen kernel, initrd, and Xen config files from the FTP repo. | ||
+ | |||
+ | Create a config file for Xen: | ||
+ | |||
+ | < | ||
+ | kernel = "/ | ||
+ | ramdisk = "/ | ||
+ | name = " | ||
+ | memory = " | ||
+ | disk = [ ' | ||
+ | vcpus = 4 | ||
+ | on_reboot = ' | ||
+ | on_poweroff = ' | ||
+ | on_crash = ' | ||
+ | vif = [' | ||
+ | </ | ||
+ | |||
+ | Boot the new Xen image and install Ubuntu: | ||
+ | |||
+ | < | ||
+ | xm create -c config | ||
+ | </ |