# XEN, PCI passthrough, boot FreeBSD



## private0330 (Dec 23, 2012)

Hi, on my desktop I install virtualization based on Xen Cloud Platform (XCP). My motherboard has two SATA controllers. I made PCI passthrough of one SATA controller and 3 disks connected to that controller. I created VM, boot from FreeBSD-9.0-RELEASE-amd64-dvd1.iso and successfully installed FreeBSD on ZFS in raidz configuration (ada0, ada1, ada2). After that I realized that I canâ€™t boot my VM because XCP know nothing about my 3 disks and VM donâ€™t have normal BIOS. The only choice is boot from network, iso or boot from hdd. HDD=vhd in my case. I created 100MB disk and attached to my VM. The disk becomes ada0 and my disks are ada1, ada2, ada3. I tried different variants to boot VM but all time I received the message:
gptzfsboot:no ZFS zpools located, canâ€™t boot   

I reinstall all system via script:
mydisk0=/dev/ada0
mydisk1=/dev/ada1
mydisk2=/dev/ada2
mydisk3=/dev/ada3
poolname=raidpool
gpart create -s gpt $mydisk0
gpart create -s gpt $mydisk1
gpart create -s gpt $mydisk2
gpart create -s gpt $mydisk3

gpart add -b 40 -s 128k -t freebsd-boot -l boot0 $mydisk0
gpart add -b 40 -s 128k -t freebsd-boot -l boot1 $mydisk1
gpart add -b 40 -s 128k -t freebsd-boot -l boot2 $mydisk2
gpart add -b 40 -s 128k -t freebsd-boot -l boot3 $mydisk3 
gpart add -t freebsd-zfs -l disk1 -b 2048 -a 4k $mydisk1
gpart add -t freebsd-zfs -l disk2 -b 2048 -a 4k $mydisk2
gpart add -t freebsd-zfs -l disk3 -b 2048 -a 4k $mydisk3
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $mydisk0
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $mydisk1
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $mydisk2
gpart bootcode -b /boot/pmbr -p /boot/gptzfsboot -i 1 $mydisk3

#This is for 4k sectors disks
gnop create -S 4096 /dev/gpt/disk1
gnop create -S 4096 /dev/gpt/disk2
gnop create -S 4096 /dev/gpt/disk3
zpool create -f -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache $poolname raidz /dev/gpt/disk1.nop /dev/gpt/disk2.nop /dev/gpt/disk3.nop
zpool export $poolname
gnop destroy /dev/gpt/disk1.nop
gnop destroy /dev/gpt/disk2.nop
gnop destroy /dev/gpt/disk3.nop
zpool import -o altroot=/mnt -o cachefile=/var/tmp/zpool.cache $poolname
zpool set bootfs=$poolname $poolname
zfs set checksum=fletcher4 $poolname 
zfs create $poolname/usr
===â€¦ creating other partitions, install swap, unpack system â€¦===
cp /var/tmp/zpool.cache /mnt/boot/zfs/zpool.cache
and restart but still no success. 
Please help.


----------

