Annotation of wikisrc/tutorials/how_to_set_up_a_guest_os_using_xen3.mdwn, revision 1.5
1.2 schmonz 1: **Contents**
2:
3: [[!toc levels=3]]
4:
1.4 gdt 5: # Meta
6:
7: Note that there is also a [Xen HOWTO](../../ports/xen/howto/).
8: Arguably this content could be folded in there.
9:
1.2 schmonz 10: # Requirements
11:
12: Xen3 is supported from NetBSD-4.0 onward. If you plan on using NetBSD-CURRENT,
13: please read the article [[How to build NetBSD-current]] to do so. Guest
14: operating systems can run from their own partitions, or from image files in
15: the main (DOM0) install.
16:
17: This tutorial describes how to:
18:
19: * Install and configure NetBSD as a DOM0
20: * Install and run a NetBSD as a DOMU
21: * Install and run a Windows XP system as as DOMU
22: * Install and run a Debian system as a DOMU
23:
24: # Installing Xen tools and kernels
25:
26: ## Xen tools
27:
28: To run and administer xen domains, we need the xentools3 or xentools33
29: packages which are available in pkgsrc.
30:
31: Xen 3.1 packages are under [sysutils/xentools3](http://pkgsrc.se/sysutils/xentools3) for traditional xentools,
32: and [sysutils/xentools3-hvm](http://pkgsrc.se/sysutils/xentools3-hvm) for the additional **HVM** support to run un-
33: modified OSes such as Windows XP.
34:
35: Xen 3.3 packages are under [sysutils/xentools33](http://pkgsrc.se/sysutils/xentools33). Unlike Xen 3.1, no extra
36: package is required for **HVM** support. Note, it is not possible to install
37: Xen 3.1 and Xen 3.3 packages at the same time. They conflict with each other.
38:
39: **HVM** stands for **Hardware Virtualization Managed**. The benefit of hardware virtualization is that you can run OSes that don't know they are being virutalized like Windows XP, for example. However, you must have a CPU which supports this. Intel CPUs must have the 'VT' instruction. AMD CPUs will have the 'SVM' instruction. You can find out if your CPU supports HVM by taking a look at this page:
40:
41: <http://wiki.xensource.com/xenwiki/HVM_Compatible_Processors>
42:
43: In NetBSD 5.0 there's a new cpuctl command. This is an example output of an
44: AMD CPU:
45:
46:
47: # cpuctl identify 0
48: cpu0: AMD Unknown K8 (Athlon) (686-class), 2210.22 MHz, id 0x60f82
49: cpu0: features 0x178bfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR>
50: cpu0: features 0x178bfbff<PGE,MCA,CMOV,PAT,PSE36,CFLUSH,MMX>
51: cpu0: features 0x178bfbff<FXSR,SSE,SSE2,HTT>
52: cpu0: features2 0x2001<SSE3,CX16>
53: cpu0: features3 0xebd3fbff<SCALL/RET,NOX,MXX,FFXSR,RDTSCP,LONG,3DNOW2,3DNOW>
54: cpu0: features4 0x11f<LAHF,CMPLEGACY,SVM,EAPIC,ALTMOVCR0,3DNOWPREFETCH>
55: cpu0: "AMD Turion(tm) 64 X2 Mobile Technology TL-64"
56: cpu0: I-cache 64KB 64B/line 2-way, D-cache 64KB 64B/line 2-waycpu0: L2 cache 1MB 64B/line 16-way
57: cpu0: ITLB 32 4KB entries fully associative, 8 4MB entries fully associative
58: cpu0: DTLB 32 4KB entries fully associative, 8 4MB entries fully associativecpu0: Initial APIC ID 0
59: cpu0: AMD Power Management features: 0x7f<TS,FID,VID,TTP,HTC,STC,100>
60: cpu0: family 0f model 08 extfamily 00 extmodel 06
61:
62:
63: Note the **SVM** feature flag in the **features4** line indicating that
64: **HVM** support is present on this CPU. However, this feature may be disabled
65: in the BIOS. In this case since NetBSD 5.0 there will show up this dmesg line
66: on AMD CPUs only:
67:
68:
69: cpu0: SVM disabled by the BIOS
70:
71:
72:
73: Xen 3.1 (the xentools3-hvm package will automatically bring in the base
74: xentools3):
75:
76:
77: # cd /usr/pkgsrc/sysutils/xentools3-hvm
78: # make install
79:
80:
81: Xen 3.3:
82:
83:
84: # cd /usr/pkgsrc/sysutils/xentools33
85: # make install
86:
87:
88: ## Xen kernel
89:
90: Next, we will get the xen hypervisor kernel itself. For NetBSD 4.x and 5.x the
91: i386 port does not support 'PAE' kernels and must run the Xen 3.1 package.
92: This restriction has been removed in -current and is not relevant for the
93: amd64 port.
94:
95: For Xen 3.1, in pkgsrc this is [sysutils/xenkernel3](http://pkgsrc.se/sysutils/xenkernel3), for Xen 3.3, this is
96: [sysutils/xenkernel33](http://pkgsrc.se/sysutils/xenkernel33):
97:
98:
99: # cd /usr/pkgsrc/sysutils/xenkernel3
100: # make install
101:
102:
103: And copy it into / directory, like this:
104:
105:
106: # cp /usr/pkg/xen3-kernel/xen.gz /
107:
108:
109: ## Xen DOM0 kernel
110:
111: Lastly, we need a XEN-enabled kernel for our DOM0 domain. There are two
112: possibilities: downloading the binary version, or building it from source.
113:
114: ## Downloading the binary version
115:
116: From NetBSD-4.0 onward, NetBSD supports Xen, and provides some XEN-enabled
117: kernel directly from [[1]][36], in each `binary/kernel` directory associated
118: with a particular release.
119:
120: For example, with NetBSD-4.0, You can grab one from
121: (<ftp.NetBSD.org/pub/NetBSD/NetBSD-4.0/i386/binary/kernel>/netbsd-XEN3_DOM0.gz):
122:
123:
124: # ftp -a ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-4.0/i386/binary/kernel/netbsd-XEN3_DOM0.gz
125:
126:
127: The `netbsd-XEN3_DOM0.gz` file contains a gzipped version of the kernel. Just
128: copy and move it into the root directory like this:
129:
130:
131: # cp netbsd-XEN3_DOM0.gz /
132:
133:
134: ## Building it from source
135:
136: Building a kernel from source is out of the scope of this section. Please
137: consult [How to build a kernel](http://www.netbsd.org/docs/kernel/#how_to_build_a_kernel) from NetBSD's FAQ for more details.
138:
139: Once building is done, you can find them in
140: `/usr/src/obj/_releasedir_/i386/binary/kernel/`. Identically to binary
141: version, copy or move netbsd-XEN3_DOM0 in the root directory `/`.
142:
143: # Selecting a bootloader
144:
1.3 asau 145: In NetBSD 5.0 the native boot loader, /boot, can load Xen directly.
146: The NetBSD 5.0 bootloader can be easily dropped into a NetBSD 4.x system by coping them into
1.2 schmonz 147: /boot and running installboot(8) properly.
148:
149: ## Updating /boot
150:
151: For full details refer to installboot(8), but for a standard configuration
152: with VGA console and an IDE or SATA drive with an FFSv1 root file system use
153: the following:
154:
155:
156: # cp /usr/mdec/boot /boot
157: # installboot -v -o timeout=5 /dev/rwd0a /usr/mdec/bootxx_ffsv1
158:
159:
160: ## Updating /boot.cfg
161:
162: NetBSD 5.0 or later will already have a /boot.cfg file with a basic
163: configuration. Enabling Xen support only requires one additional line in this
164: case. If you're upgrading from an earlier version or do not have an existing
165: /boot.cfg use the following example:
166:
167:
168:
169: banner=Welcome to NetBSD
170: banner==================
171: banner=
172: banner=Please choose an option from the following menu:
173: menu=Boot normally:boot netbsd
174: menu=Boot single-user:boot netbsd -s
175: menu=Boot backup kernel:boot onetbsd
176: menu=Drop to boot prompt:prompt
177: menu=Boot Xen with 256MB for dom0:load /netbsd-XEN3_DOM0 console=pc;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M
178: menu=Boot Xen with 256MB for dom0 (serial):load /netbsd-XEN3_DOM0 console=com0;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M console=com1 com1=115200,8n1
179: menu=Boot Xen with dom0 in single-user mode:load /netbsd-XEN3_DOM0 -s;multiboot /usr/pkg/xen3-kernel/xen.gz dom0_mem=256M
180: timeout=5
181: default=1
182:
183:
184: Make sure you update the "load /netbsd-XEN3_DOM0" and the "dom0_mem=256M"
185: arguments to match your setup. On next boot select the 'Boot Xen with 256MB
186: for dom0' option and make sure you see Xen kernel messages and the normal
187: NetBSD kernel messages. Once you're satisfied it is working you can change the
188: "default=1" line to "default=5" to automatically boot Xen on reboot.
189:
190: # Setting up DOM0
191:
192: ## Creating xen devices
193:
194: To create all xen devices, change to /dev and run ./MAKEDEV xen
195:
196:
197: cd /dev
198: ./MAKEDEV xen
199:
200:
201: This should create the devices **xencons**, **xenevt** and **xsd_kva**. If any
202: of these are missing you may not have updated to _CURRENT_ using the latest
203: sources and you will have to create the missing device files.
204:
205: ## Configuring the bridge interface
206:
1.5 ! kim 207: The [bridge(4)](//man.NetBSD.org/bridge.4) interface is used to provide network access to DOMUs.
1.2 schmonz 208:
209: To use one, edit (or create) the file `/etc/ifconfig.bridge0` and insert
210: following lines to:
211:
212:
213: create
214: !brconfig $int add bge0 stp bge0 up
215:
216:
217: Where 'bge0' should be changed to the name of the interface you want to use
1.5 ! kim 218: with your guest operating systems. use [ifconfig(8)](//man.NetBSD.org/ifconfig.8) to get more details
1.2 schmonz 219: about your actual interfaces.
220:
221: ## Rebooting into DOM0
222:
223: Time to reboot:
224:
225:
226: # shutdown -r now
227:
228:
229: If all has gone well, you should have booted into the XEN3_DOM0 kernel. Check
1.5 ! kim 230: this with [uname(1)](//man.NetBSD.org/uname.1):
1.2 schmonz 231:
232:
233: # uname -v
234: NetBSD 4.0 (XEN3_DOM0) #0: Sun Dec 16 01:20:31 PST 2007
235: builds@wb34:/home/builds/ab/netbsd-4-0-RELEASE/i386/200712160005Z-obj/home/builds/ab/netbsd-4-0-RELEASE/src/sys/arch/i386/compile/XEN3_DOM0
236:
237:
238: You should have **XEN3 DOM0** mentioned somewhere.
239:
240: ## Configuring rc scripts
241:
242: Copy or symlink xend, xenbackendd and xendomains from
243: `/usr/pkg/share/examples/rc.d` to `/etc/rc.d`.
244:
245:
246: # cp /usr/pkg/share/examples/rc.d/xend /etc/rc.d/
247: # cp /usr/pkg/share/examples/rc.d/xenbackendd /etc/rc.d/
248: # cp /usr/pkg/share/examples/rc.d/xendomains /etc/rc.d/
249:
250:
251: Edit `/etc/rc.conf` and add the following lines:
252:
253:
254: xend=YES
255: xenbackendd=YES
256: xendomains="dom1"
257:
258:
259: Later on, when you have created a configuration file for 'dom1', the
260: xendomains variable specified above will trigger 'dom1' to be started when the
261: system is booted. At this point no configuration exists for dom1, therefore it
262: does nothing at this point. If you choose to name your configuration file
263: something else, adapt the name accordingly.
264:
265: To avoid rebooting a second, start all three services:
266:
267:
268: # /etc/rc.d/xend start
269: # /etc/rc.d/xenbackendd start
270: # /etc/rc.d/xendomains start
271:
272:
273: Run `ifconfig -a` to ensure the bridge interface is present and issue a `ps ax
274: | grep xen` to ensure you have a similar output.
275:
276:
277:
278: 12 ? DK 0:00.00 [xenwatch]
279: 13 ? DK 0:00.00 [xenbus]
280: 411 ? I 0:00.24 xenstored --pid-file=/var/run/xenstore.pid
281: 594 ? IWa 0:00.26 xenconsoled
282: 629 ? IW 0:00.00 /usr/pkg/bin/python2.3 /usr/pkg/sbin/xend start
283: 631 ? IWsa 0:00.02 /usr/pkg/sbin/xenbackendd
284: 639 ? IWa 0:00.52 /usr/pkg/bin/python2.3 /usr/pkg/sbin/xend start
285:
286:
287: The DOM0 configuration is now done. We will proceed to configuring DOMU
288: domains.
289:
290: # Configuring DOMU
291:
292: ## Configuring and installing a NetBSD DOMU
293:
294: Create (or modify) `/usr/pkg/etc/xen/dom1` and include this:
295:
296:
297:
298: kernel = "/usr/src/obj/releasedir/i386/binary/kernel/netbsd-INSTALL_XEN3_DOMU.gz"
299: #kernel = "/netbsd-XEN3_DOMU"
300: memory = 64
301: name = "dom1"
302: #vcpus = 1
303: disk = [ 'phy:/dev/wd0g,0x03,w','file:/usr/src/obj/releasedir/i386/installation/cdrom/netbsd-i386.iso,0x04,r' ]
304: vif = [ 'bridge=bridge0' ]
305: root = "/dev/wd0d"
306:
307:
308: This configuration boots into the NetBSD sysinst program and allows you to
309: install a NetBSD DOMU using the normal sysinst method. This configuration uses
310: a DOMU_INSTALL kernel and an ISO image provided by a successful 'build
311: release' and 'build iso-image'. You may be able to locate a valid Xen3
312: DOMU_INSTALL kernel from <ftp://ftp.netbsd.org/pub/NetBSD-daily/> but if
313: not, building a release is your best bet.
314:
315: In this configuration file, `/dev/wd0g` is the reserved partition for the
316: guest operating system. This should be changed to the partition you reserved
317: prior to following the instructions within this document.
318:
319: If you would like to use a physical CDROM instead of an ISO image, change the
320: disk line to:
321:
322:
323: disk = [ 'phy:/dev/wd0g,0x03,w','phy:/dev/cd0a,0x04,r' ]
324:
325:
326: Now boot into sysinst using the command:
327:
328:
329: xm create dom1 -c
330:
331:
332: The reserved partition will appear as `/dev/xbd0`. Proceed as you would with a
333: normal NetBSD installation using xbd0 as the target drive and xbd1 as the
334: CDROM.
335:
336: When you have finished, run `shutdown -hp now` to dom1.
337:
338: Now edit `/usr/pkg/etc/xen/dom1`. Comment the INSTALL kernel and uncomment the
339: DOMU kernel.
340:
341: You should now have a working NetBSD DOMU (dom1). Boot into dom1 again with
342: the command:
343:
344:
345: xm create dom1 -c
346:
347:
348: and ensure the file, `/etc/ttys` contains only this line or has all other
349: lines commented:
350:
351:
352: console "/usr/libexec/getty Pc" vt100 on secure
353:
354:
355: and the file `/etc/wscons.conf` is completely empty or has all lines commented
356: out. These last two steps ensure no errors should be present on boot. Setting
357: wscons=NO in `/etc/rc.conf` may effectively do the same thing.
358:
359: From here, configure `/etc/rc.conf` and all runtime configuration files as you
360: would normally. The network interface name should be _**xennet0**_. Use this
361: name when configuring an IP address.
362:
363: More information can be obtained by referencing the [Xen user guide](http://www.cl.cam.ac.uk/Research/SRG/netos/xen/readmes/user/) and
364: [the official NetBSD Xen Howto](http://www.netbsd.org/Ports/xen/howto.html). Questions can be addressed to the port-
365: xen@NetBSD.org mailling list.
366:
367: ## Configuring and installing a Windows XP DOMU
368:
369: This requires an HVM capable processor and xentools (see sections above).
370:
371: This assumes you have a copy of the Windows install CD in /home/xen/winxp.iso,
372: and wish to create a file /home/xen/winxp.img to hold the install. First
373: create a blank file to hold the install. This assumes a size of 4GB (4096M).
374: If you want a different size adjust the numbers to match:
375:
376:
377: # dd if=/dev/zero of=/home/xen/winxp.img bs=1m count=4096
378:
379:
380: Create `/usr/pkg/etc/xen/win01`:
381:
382:
383:
384: kernel = '/usr/pkg/lib/xen/boot/hvmloader'
385: builder = 'hvm'
386: memory = '400'
387: device_model='/usr/pkg/libexec/qemu-dm'
388:
389: disk = [ 'file:/home/xen/winxp.img,ioemu:hda,w',
390: 'file:/home/xen/winxp.iso,ioemu:hdb:cdrom,r', ]
391:
392: # Hostname
393: name = "win01"
394:
395: vif = [ 'type=ioemu, bridge=bridge0' ]
396:
397: boot= 'd'
398: vnc = 1
399: usbdevice = 'tablet' # Helps with mouse pointer positioning
400:
401:
402: You may want to modify the amount of memory and pathnames.
403:
404: Ensure you have a vncviewer installed, such as [net/tightvncviewer](http://pkgsrc.se/net/tightvncviewer) or
405: [net/vncviewer](http://pkgsrc.se/net/vncviewer) from pkgsrc.
406:
407: Then start the XENU and connect to it via VNC.
408:
409:
410: # xm create /usr/pkg/etc/xen/win01
411: # vncviewer :0
412:
413:
414: This will boot the Windows ISO image and let you install Windows as normal. As
415: Windows reboots during install you may need to restart vncviewer.
416:
417: After install change the **boot d** to **boot c** to have the system boot
418: directly from the disk image.
419:
420: ## Configuring and installing a GNU/Linux DOMU
421:
422: We will do this in two steps:
423:
424: * install a GNU/Linux system, from a livecd or any installation media
425: * configure the DOM0 so that it can create and start the Linux DOMU.
426:
427: ### Installing a Linux distribution (soon-to-be DOMU)
428:
429: Before proceeding with DOMU configuration, we will install our favorite
430: GNU/Linux distribution on the computer.
431:
432: In order to do it, we need at least two partitions (only one, if you do not
433: consider the swap). These partitions must reside outside of the NetBSD slice,
434: and may be either of primary or extended type. Of course, you can use more
435: than two, but adapt your labels and partitions accordingly.
436:
1.5 ! kim 437: We do not cover the partition/slices manipulations through [fdisk(8)](//man.NetBSD.org/fdisk.8) and
! 438: [disklabel(8)](//man.NetBSD.org/disklabel.8), as it depends strongly on how you manage your hard drive's
1.2 schmonz 439: space.
440:
441: For this tutorial, we will use this partitioning:
442:
443:
444:
445: # fdisk /dev/wd0d
446: fdisk: removing corrupt bootsel information
447: fdisk: Cannot determine the number of heads
448: Disk: /dev/wd0d
449: NetBSD disklabel disk geometry:
450: cylinders: 486344, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
451: total sectors: 490234752
452:
453: BIOS disk geometry:
454: cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
455: total sectors: 490234752
456:
457: Partition table:
458: 0: Linux native (sysid 131)
459: start 63, size 20482812 (10001 MB, Cyls 0-1274)
460: PBR is not bootable: All bytes are identical (0x00)
461: 1: Linux swap or Prime or Solaris (sysid 130)
462: start 20482875, size 1959930 (957 MB, Cyls 1275-1396)
463: PBR is not bootable: All bytes are identical (0x00)
464: 2: NetBSD (sysid 169)
465: start 61464690, size 428770062 (209360 MB, Cyls 3826-30515/178/63), Active
466: 3: <UNUSED>
467: Drive serial number: -286527765 (0xeeebeeeb)
468:
469:
470: Here, you notice that we decide to use two primary partitions for our future
471: Linux DOMU:
472:
473: * partition 0 (for the **root directory /**)
474: * partition 1 (for the **swap**)
475:
476: Labels:
477:
478:
479:
480: 16 partitions:
481: # size offset fstype [fsize bsize cpg/sgs]
482: a: 30720816 61464690 4.2BSD 2048 16384 0 # (Cyl. 60976*- 91453*)
483: b: 1049328 92185506 swap # (Cyl. 91453*- 92494*)
484: c: 428770062 61464690 unused 0 0 # (Cyl. 60976*- 486343)
485: d: 490234752 0 unused 0 0 # (Cyl. 0 - 486343)
486: e: 20480000 93234834 4.2BSD 0 0 0 # (Cyl. 92494*- 112812*)
487: f: 20480000 113714834 4.2BSD 0 0 0 # (Cyl. 112812*- 133129*)
488: g: 20480000 134194834 4.2BSD 0 0 0 # (Cyl. 133129*- 153447*)
489: h: 335559918 154674834 4.2BSD 0 0 0 # (Cyl. 153447*- 486343)
490: i: 20482812 63 Linux Ext2 0 0 # (Cyl. 0*- 20320*)
491: j: 1959930 20482875 swap # (Cyl. 20320*- 22264*)
492:
493:
494: Bear in mind that we added two labels here, namely **i** and **j**, which maps
495: respectively to partition 0 and partition 1 of the disk. We will use these
496: labels later for DOMU configuration.
497:
498: Now that we have partitioned the disk, proceed with installing your Linux
499: distribution. We will not cover that part in this tutorial. You can either
500: install it from an installation media (a cdrom from example), or copy files
501: from an already installed distribution on your computer.
502:
503: Tip: to manipulate ext2/3 filesystems (the traditional fs under Linux) from
504: NetBSD, you can use [sysutils/e2fsprogs](http://pkgsrc.se/sysutils/e2fsprogs) from pkgsrc:
505:
506:
507: # cd /usr/pkgsrc/sysutils/e2fsprogs
508: # make install
509:
510:
1.5 ! kim 511: And then use e2fsck, mke2fs and [mount_ext2fs(8)](//man.NetBSD.org/mount_ext2fs.8) directly from NetBSD.
1.2 schmonz 512:
513: ### Getting XEN aware Linux kernels
514:
515: Once installation is done, reboot your computer and return to our Xen-NetBSD
516: system.
517:
518: To boot our Linux DOMU, we will need a Linux kernel supporting the XENU
519: virtualisation. Depending on your Linux distribution, you can grab one from
520: its repository (it is up to you to find it through aptitude, yum or whatever
521: package manager you use), or get one from the Xen binary distribution.
522:
523: To get a XENU Linux kernel from Xen binary distribution, get it directly from
524: [Xen website download page](http://www.xen.org/download/dl_31tarballs.html). Download the tarball and extract the
525: **vmlinuz-*-xen** from it. In our case, with a 2.6.18 Linux kernel:
526:
527:
528: # ftp -a http://bits.xensource.com/oss-xen/release/3.1.0/bin.tgz/xen-3.1.0-install-x86_32.tgz
529: # cd /tmp
530: # tar -xzf xen-3.1.0-install-x86_32.tgz dist/install/boot/vmlinuz-2.6.18-xen
531:
532:
533: **vmlinuz-2.6.18-xen** is the kernel that Xen will use to start the DOMU. Move it to any directory you like (just remember it when configuring the _kernel_ entry in the DOMU configuration file):
534:
535: # mv dist/install/boot/vmlinuz-2.6.18-xen /vmlinuz-XEN3-DOMU
536:
537:
538: ### Configuring DOMU
539:
540: Configuring the Linux DOMU is a bit different than a NetBSD one; some options
541: tend to differ.
542:
543: Edit (or create) the configuration file **domu-linux**, in
544: `/usr/pkg/etc/xen/`:
545:
546:
547: # vi /usr/pkg/etc/xen/domu-linux
548:
549:
550: Here's a typical config file for a Linux DOMU:
551:
552:
553:
554: #----------------------------------------------------------------------------
555: # Kernel image file. This kernel will be loaded in the new domain.
556: kernel = "/vmlinuz-XEN3-DOMU"
557:
558: # Memory allocation (in megabytes) for the new domain.
559: memory = 256
560:
561: # A handy name for your new domain. This will appear in 'xm list',
562: # and you can use this as parameters for xm in place of the domain
563: # number. All domains must have different names.
564: #
565: name = "domu-linux"
566:
567: # Which CPU to start domain on (only relevant for SMP hardware). CPUs
568: # numbered starting from ``0''.
569: #
570: cpu = "^1" # leave to Xen to pick
571:
572: #----------------------------------------------------------------------------
573: # Define network interfaces for the new domain.
574:
575: # Number of network interfaces (must be at least 1). Default is 1.
576: vif = [ '' ]
577:
578: # Define MAC and/or bridge for the network interfaces.
579: #
580: # The MAC address specified in ``mac'' is the one used for the interface
581: # in the new domain. The interface in domain0 will use this address XOR'd
582: # with 00:00:00:01:00:00 (i.e. aa:00:00:51:02:f0 in our example). Random
583: # MACs are assigned if not given.
584: #
585: # ``bridge'' is a required parameter, which will be passed to the
586: # vif-script called by xend(8) when a new domain is created to configure
587: # the new xvif interface in domain0.
588: #
589: # In this example, the xvif is added to bridge0, which should have been
590: # set up prior to the new domain being created -- either in the
591: # ``network'' script or using a /etc/ifconfig.bridge0 file.
592: #
593: vif = [ 'mac=aa:00:00:50:02:f0, bridge=bridge0' ]
594:
595: #----------------------------------------------------------------------------
596: # Define the disk devices you want the domain to have access to, and
597: # what you want them accessible as.
598: #
599: # Each disk entry is of the form:
600: #
601: # phy:DEV,VDEV,MODE
602: #
603: # where DEV is the device, VDEV is the device name the domain will see,
604: # and MODE is r for read-only, w for read-write. You can also create
605: # file-backed domains using disk entries of the form:
606: #
607: # file:PATH,VDEV,MODE
608: #
609: # where PATH is the path to the file used as the virtual disk, and VDEV
610: # and MODE have the same meaning as for ``phy'' devices.
611: #
612: # /dev/wd0i will be seen as "hda1" under DOMU (the root partition)
613: # /dev/wd0j will be seen as "hda2" under DOMU (the swap)
614: #
615: disk = [ 'phy:/dev/wd0i,hda1,w','phy:/dev/wd0j,hda2,w' ]
616:
617: #----------------------------------------------------------------------------
618: # Set the kernel command line for the new domain.
619:
620: # Set root device.
621: root = "/dev/hda1"
622:
623:
624: Now, you should be able to start your first Linux DOMU!
625:
626:
627: # xm create -c /usr/pkg/etc/xen/domu-linux
628:
629:
630: # Possible caveats
631:
632: If you intend to have more than one box configured with the above
633: configuration on the same network, you will most likely have to specify a
634: unique MAC address per guest OS, otherwise it is likely you will have a
635: conflict. I'm not sure if the MAC assignment is random, incremental or if Xen
636: is able to check for the existence of the proposed MAC address, so specifying
637: the MAC address is recommended.
638:
639: Here is a method to assign a MAC address to a newly created Xen Domu. First as
640: described before, use the following vif parameter in your config file :
641:
642:
643:
644: vif = [ 'bridge=bridge0' ]
645:
646:
647: Then, run the Xen DomU and, once logged run the following command :
648:
649:
650:
651: # ifconfig xennet0
652:
653: Output Sample :
654:
655: xennet0: flags=8863<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST> mtu 1500
656: capabilities=2800<TCP4CSUM_Tx,UDP4CSUM_Tx>
657: enabled=0
658: address: 00:16:3e:2e:32:5f
659: inet 192.168.4.81 netmask 0xffffff00 broadcast 192.168.4.255
660: inet6 fe80::216:3eff:fe2e:325f%xennet0 prefixlen 64 scopeid 0x2
661:
662:
663:
664: A MAC address is automaticaly generated, use it in your config file with the
665: following syntax :
666:
667:
668:
669: vif = [ 'mac=00:16:3e:2e:32:5f, bridge=bridge0' ]
670:
671:
672: And now you can restart the Xen DomU.
673:
674: Please, note that the MAC Address MUST start with "00:16:3e".
675:
676:
677:
678: # See also
679:
680: * [The official NetBSD Xen Howto](http://www.netbsd.org/Ports/xen/howto.html)
681: * [The official Xen Wiki](http://wiki.xensource.com/xenwiki/)
682:
CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb