MonkeyBrains.net/~rudy/example Random examples

Xen on NetBSD

HOW TO do Xen3 on NetBSD 3.1

  • Download and install NetBSD. There are plenty of tutorials for this.
  • Come up with a partitioning scheme.
    I am going with partition backed filesystems instead of file backed (performance and ease of maintenance reasons).
    I was coming from a FreeBSD background and was confused as to how the various partitions are accessed. Say you set up two slices with fdisk... in FreeBSD, they show up as /dev/ads1 and /dev/ads2. Not so in NetBSD. Make one uber partition of type NetBSD. Then create a wd0a about 6GB big to hold the host. Here is an example partitioning scheme.
    wd0a is /
    wd0b is 2x RAM size and is my swap
    wd0e is the first Xen instance
    wd0g is a 10GB NTFS partition
    wd0h is a 10GB Ext2 partition
    
    disklabel -e wd0
    # /dev/rwd0d:
    type: unknown
    disk: WDC WD2500YD-01
    label: 
    flags:
    bytes/sector: 512
    sectors/track: 63
    tracks/cylinder: 16
    sectors/cylinder: 1008
    cylinders: 486344
    total sectors: 490234752
    rpm: 3600
    interleave: 1
    trackskew: 0
    cylinderskew: 0
    headswitch: 0           # microseconds
    track-to-track seek: 0  # microseconds
    drivedata: 0 
    
    #        size    offset     fstype [fsize bsize cpg/sgs]
     a:  12288528        63     4.2BSD   2048 16384 27560  # (Cyl.      0*-  12191*)
     b:   8192016  12288591       swap                     # (Cyl.  12191*-  20318*)
     c: 490230000        63     unused      0     0        # (Cyl.      0*- 486339*)
     d: 490234752         0     unused      0     0        # (Cyl.      0 - 486343)
     e:  20482812  20482812     4.2BSD   2048 16384 27568  # (Cyl.  20320*-  40640*)
     f:  20482812  40965624     4.2BSD   2048 16384 27568  # (Cyl.  40640*-  60960*)
     g:  20482812  61448436       NTFS                     # (Cyl.  60960*-  81280)
     h:  20482812  81931248 Linux Ext2   2048 16384        # (Cyl.  81281 - 101601*)
     i:  20482812 102414060     4.2BSD   2048 16384 27568  # (Cyl. 101601*- 121921*)
     j:  40965624 143379684     4.2BSD   2048 16384 28424  # (Cyl. 142241*- 182882*)
    
    We are going to need to know the number of heads in the disk geometry ... the number NetBSD is using.
    fdisk 
    Disk: /dev/rwd0d
    NetBSD disklabel disk geometry:
    cylinders: 486344, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
    total sectors: 490234752
    
    BIOS disk geometry:
    cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
    total sectors: 490234752
    
  • Format the partitions and mount them
    # The BSD one is easy
    newfs /dev/wd0e
    
    # The NTFS one needs data from the disklabel output AND the mkntfs program
    # install mkntfs into: /usr/pkg/sbin/
    # run fdisk to get the number of heads that NetBSD is using... not the BIOS
    cd /usr/pkgsrc/sysutils/ntfsprogs/ && make install clean 
    mkntfs --ntfs-version 3.1 --sector-size 512 --heads 16 \
     --partition-start 61448436 --sectors-per-track 63 --fast --label ShitItWorks --/dev/wd0g
    
    # Next set up another partition for Linux
    # install e2fs into: /usr/pkg/sbin/
    cd /usr/pkgsrc/sysutils/e2fsprogs/ && make install clean 
    mke2fs -j -L XenExt3 /dev/wd0h
    
    # set a special mount point for all your Xen partitions.
    mkdir /xen
    mkdir /xen/wd0e
    mkdir /xen/wd0f
    mkdir /xen/wd0g
    mkdir /xen/wd0h
    mkdir /xen/wd0i
    mkdir /xen/wd0j
    
    # add these lines to your /etc/fstab
    ### Xen partitions
    # Note: all ntfs partitions need 0 and 0 in the last two columns.
    /dev/wd0e /xen/wd0e ffs rw 2 2
    /dev/wd0f /xen/wd0f ffs rw 2 2
    /dev/wd0g /xen/wd0g ntfs rw 0 0
    /dev/wd0h /xen/wd0h ext2fs rw 2 2
    /dev/wd0i /xen/wd0i ffs rw 2 2
    /dev/wd0j /xen/wd0j ffs rw 2 2
    
    
    # now try mounting them!
    mount /xen/wd0g
    mount /xen/wd0i
    mount /xen/wd0j
    
    # run the mount command to see if they worked!
    mount
    # also run df to check the partition sizes.  I like the -m flag...
    df -m
    # Want something more Human Readable?  Try this:
    df -h
    
    
  • Install the Xen2 kernel and grub (When netBSD 4.x is stable, you can switch to Xen3)
     cd /usr/pkgsrc/sysutils/xenkernel20/  && make install clean
     cd /usr/pkgsrc/sysutils/xentools20/   && make install clean
     cd /usr/pkgsrc/sysutils/grub/         && make install clean
    Download your kernel from netbsd.org... depends on your version and ARCH:
    eg, ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-3.1/i386/binary/kernel
  • Configure Grub
    I used this HOW-TO to set up grub.
  • Reboot! It works! (hopefully)
  • Set up domN instances.