Nethence Newdoc Olddoc Lab Your IP BBDock  

XEN guest // Ubuntu Server

The debootstrap guest flavor (preferred)

You need to do that on an ubuntu host, you will then be able to migrate the shit to some other xen dom0.

Assuming you got the freaking domU kernel ready — NO RAMDISK NEEDED.

mkdir -p /data/guests/ubuntu/
cd /data/guests/ubuntu/

dd if=/dev/zero of=ubuntu.img bs=1024k count=0 seek=10240
#mkfs.xfs ubuntu.img
mkfs.ext4 ubuntu.img
#dd if=/dev/zero of=ubuntu.swap bs=1024k count=0 seek=1024
#mkswap ubuntu.swap 
mkdir /tmp/xenloop
mount -o loop ubuntu.img /tmp/xenloop

apt install debootstrap

debootstrap $dist /tmp/xenloop
du -sh /tmp/xenloop # artful 302M, 307M
unset dist

chroot /tmp/xenloop /usr/bin/passwd
vi /tmp/xenloop/etc/fstab

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
/dev/xvda1       /               xfs    defaults        0       1
#/dev/xvda2       none            swap    sw             0       0

umount /tmp/xenloop

vi ubuntu

kernel = "/data/kernels/vmlinuz.4.4.88.domu"
root = "/dev/xvda1 ro"
memory = 512
name = "ubuntu"
vcpus = 2
disk = ['tap:aio:/data/guests/ubuntu/ubuntu.img,xvda1,w']
vif = [ 'bridge=xenbr0, vifname=ubuntu.0' ]

xl create ubuntu -c

dhclient eth0
apt install ifupdown net-tools openssh-server openssh-client language-pack-en

For further maintenance,

#xl des ubuntu
#xfs_repair ubuntu.img 
fsck ubuntu.img
mount -o loop ubuntu.img /tmp/xenloop
umount /tmp/xenloop


TRASH (no modules needed anymore),

mkdir /tmp/xenloop/lib/modules
rm -rf /tmp/xenloop/lib/modules/4.4.14.domu
cp -R ../vmlinuz.4.4.14.domu.modules/ /tmp/xenloop/lib/modules/4.4.14.domu
ls -lhF /tmp/xenloop/lib/modules

The classical full disk guest flavor

Fetch the latest Ubuntu Server XEN guest installer,

mkdir -p /data/guests/ubuntufull/
cd /data/guests/ubuntufull/


dd if=/dev/zero of=ubuntufull.disk bs=1024k count=0 seek=10240

cat > ubuntufull <<-EOF
kernel = "/data/guests/ubuntufull/vmlinuz"
ramdisk = "/data/guests/ubuntufull/initrd.gz"
#kernel = "/usr/local/bin/pygrub"
memory = 1024
name = "ubuntufull"
vcpus = 4
disk = [ 'tap:aio:/data/guests/ubuntufull/ubuntufull.disk,xvda,w' ]
vif = [ 'bridge=xenbr0, vifname=ubuntufull.0' ]

xl create ubuntufull -c

Provide the right repo on your network as described in the PXEing Ubuntu guide, and use it as a proxy right after defining your nearest official mirror,

proxy URL: http://x.x.x.x:3142

server mode install options e.g.,

install security updates auto
basic ubuntu server

back to the guest setup (once rebooted after successful installation),

xl destroy ubuntufull
cd /data/guests/ubuntufull/
vi ubuntufull

#kernel = "/data/guests/ubuntu/vmlinuz"
#ramdisk = "/data/guests/ubuntu/initrd.gz"
kernel = "/usr/local/bin/pygrub"

xl create ubuntufull -c

This does not work as expected, I get this error,

xc: error: panic: xc_dom_core.c:702: xc_dom_find_loader: no loader found: Invalid kernel

So my workaround in the meantile was to load the kernel and initramfs directly. For that, I first launched the guest with a rescue system,

kernel = "/data/guests/vmlinuz.4.4.14.domu"
ramdisk = "/data/guests/slackware.initrd.img"

and then sent the kernel and initramfs to the xen host through SSH, to finally be able to boot the Ubuntu guest,

kernel = "vmlinuz-4.13.0-21-generic"
root = "/dev/xvda1 ro console=hvc0"
ramdisk = "initrd.img-4.13.0-21-generic"


Home | GitHub | Docker Hub | Donate | Contact