Kugutsumen
2007-Oct-19 09:37 UTC
[zfs-discuss] Installing a zvol-based gentoo domU from an existing linux partition
# I booted the gentoo partition
emerge xen-sources
cd /usr/src/linux-2.6.20-xen-r6
mount /boot
make && make install && make modules install
tar Ccp / linux-2.6.20-xen-r6-x64.tar.gz /boot/*2.6.20-xen-r6* /lib/
modules/*2.6.20-xen-r6*
# I transfered my xen domU kernel to a safe place.
# Now we can reboot in Solaris dom0
# Let''s create a 10 gig zvol
zfs create -V 10G tank/gentoo-disk
# The gentoo partition was on partition 4 of the c2t0d0p0 (your
mileage may vary.)
# We create a xen config file that will drop us in a bash shell
cat >gentoo.py <<EOF
name = "gentoo"
vcpus = 1
memory = 512
kernel = "/tank/xen/gentoo/boot/vmlinux-syms-2.6.20-xen-r6-domU"
extra = "init=/bin/bash"
disk = [ ''phy:/dev/dsk/c2t0d0p0,hdb,w'',
''phy:/dev/zvol/dsk/tank/
gentoo-disk,xvda1,w'' ]
root="/dev/hdb4 ro"
vif = ['''']
on_shutdown = "destroy"
on_reboot = "restart"
on_crash = "destroy"
EOF
# let''s start the domU
xm create gentoo.py -c
# now we need to remount the root partition rw and create xvda device
and create an ext3 filesystem (they can resize nicely and are better
supported then reiserfs [author is jail] and xfs [SGI bankrupt])
mount -o rw,remount /
mknod /dev/xvda1 b 202 1
mke2fs -j /dev/xvda1
mount /dev/xvda1 /mnt
# Now let''s copy the content of our original filesystem to the zvol
ext3
tar Ccp / --one-file-system . | tar Cxp /mnt
# We need to fix fstab
cat >/mnt/etc/fstab <<EOF
/dev/xvda1 / ext3 noatime 1 1
#/dev/sda3 /boot ext2 noauto,noatime 1 2
proc /proc proc defaults 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
/dev/cdroms/cdrom0 /mnt/cdrom iso9660 noauto,ro 0 0
EOF
# We need to disable hardware checksuming for eth0
cat >>/mnt/etc/conf.d/net <<EOF
postup() {
if [[ "${IFACE}" == "eth0" ]] ; then
/usr/sbin/ethtool -K ${IFACE} tx off
}
EOF
vi /mnt/etc/inittab # comment all all the c2:c5 getty entries and
keep the first one (c1)
umount /mnt
mount -o ro,remount /
halt
# Now this is our final gentoo.py
cat >gentoo.py <<EOF
name = "gentoo"
vcpus = 1
memory = 512
kernel = "/tank/xen/gentoo/boot/vmlinux-syms-2.6.20-xen-r6-domU"
extra = ""
disk = [ ''phy:/dev/zvol/dsk/tank/gentoo-disk,xvda1,w'' ]
root="/dev/xvda1 ro"
vif = ['''']
on_shutdown = "destroy"
on_reboot = "restart"
on_crash = "destroy"
on_xen_start = "start"
EOF
xm new gentoo.py
xm start gentoo.py
voila :D