XEN4LiveCD: Unterschied zwischen den Versionen
| Zeile 6: | Zeile 6: | ||
Benötigt wird "irgendein" Linux-System, bevorzugt Debian oder Ubuntu, um die vorhandenen Repositories zu verwenden: | Benötigt wird "irgendein" Linux-System, bevorzugt Debian oder Ubuntu, um die vorhandenen Repositories zu verwenden: | ||
<pre>root# apt-get install live-build live-boot live-config | <pre>root# | ||
apt-get install live-build live-boot live-config | |||
mkdir livexen | mkdir livexen | ||
| Zeile 15: | Zeile 16: | ||
</pre> | </pre> | ||
'''auto/config''' | '''Zusammenstellung der LiveCD''' | ||
Als Basis wird ein Wheezy 64-Bit LXDE Desktop mit deutschem Layout definiert. | |||
'''''auto/config''''' | |||
<pre>lb config noauto \ | <pre>lb config noauto \ | ||
--linux-flavours amd64 \ | --linux-flavours amd64 \ | ||
| Zeile 27: | Zeile 32: | ||
"${@}" | "${@}" | ||
</pre> | </pre> | ||
Die optionalen Programme und XEN Anpassungen werden in den folgenden Konfig-files eingetragen. | |||
''config/package-lists/my.list.chroot'' | |||
<pre>echo "ssh less pciutils lsbutils network-manager iceweasel gparted" > config/package-lists/my.list.chroot | |||
echo "xen-utils-4.1 xen-tools syslinux virt-manager virt-what virt-viewer" >> config/package-lists/my.list.chroot</pre> | |||
''config/hooks/'''xend.chroot''''' und ''config/hooks/'''xen-syslinux.binary''''' | |||
<pre>echo > config/hooks/xend.chroot <<EOF | |||
#!/bin/sh | |||
echo "I: hooks/xend.chroot" | |||
# modify xend-config.sxp (use NAT because WLAN don't likes bridges) | |||
# enable virt-manager access | |||
FILE=/etc/xen/xend-config.sxp | |||
if test -e $FILE; then | |||
sed -i \ | |||
-e "s;(vif-script vif-bridge);#(vif-script vif-bridge);g" \ | |||
-e "s;#(vif-script vif-nat);(vif-script vif-nat);g" \ | |||
-e "s;#(network-script network-nat);(network-script vif-nat);g" \ | |||
-e "s;#(xend-http-server no);(xend-http-server yes);g" \ | |||
-e "s;#(xend-unix-server no);(xend-unix-server yes);g" \ | |||
-e "s;#(vnc-listen '127.0.0.1');(vnc-listen '0.0.0.0');g" \ | |||
$FILE | |||
fi | |||
# modify /etc/default/xendomains | |||
# disable VM save/restore | |||
FILE=/etc/default/xendomains | |||
if test -e $FILE; then | |||
sed -i \ | |||
-e "s;XENDOMAINS_SAVE=/var/lib/xen/save;XENDOMAINS_SAVE=;g" \ | |||
-e "s;XENDOMAINS_RESTORE=true;XENDOMAINS_RESTORE=false;g" \ | |||
$FILE | |||
fi | |||
# set XEN toolstack to xm | |||
FILE=/etc/default/xen | |||
if test -e $FILE; then | |||
sed -i \ | |||
-e "s;TOOLSTACK=;TOOLSTACK=xm;g" \ | |||
$FILE | |||
fi | |||
# XEN optimisation | |||
# wait 10 seconds, check xend | |||
# raise Dom0 prio | |||
FILE=/etc/rc.local | |||
cat << EOF >> $FILE | |||
# XEN: Dom0 specific settings | |||
sleep 10; | |||
xend status >/dev/null 2>&1 && /etc/init.d/xen restart | |||
if [ ! \`xend status\` ]; then | |||
# give Dom0 preference over DomUs by Faktor x (weight 256 = DomU default) | |||
xen sched-credit -d Domain-0 -w 1024 | |||
# PowerSave | |||
xenpm set-scaling-governor ondemand | |||
fi | |||
EOF | |||
# wheezy bugfix: | |||
# virt-manager fails because of missing links | |||
if [ ! -d /usr/lib64 ]; then | |||
mkdir /usr/lib64 | |||
ln -s /usr/lib/xen-4.1 /usr/lib64/xen | |||
fi | |||
[ -d /usr/lib/xen-default ] || ln -s /usr/lib/xen-4.1 /usr/lib/xen-default | |||
EOF</pre> | |||
<pre>echo > config/hooks/xen-syslinux.binary <<EOF | |||
#!/bin/sh | |||
echo "I: hooks/xen-syslinux.binary" | |||
# insert XEN entries in syslinux bootmenu | |||
# bootdir is syslinux (hdd images) or isolinux (iso images) | |||
BOOTDIR="binary/isolinux/" | |||
[ ! -d "${BOOTDIR}" ] && BOOTDIR="binary/syslinux" | |||
# xen needs multiboot loader mboot.c32 to start | |||
[ -e chroot/usr/lib/syslinux/mboot.c32 ] || (echo "Error: missing mboot.c32 (syslinux)"; exit 1) | |||
# copy multiboot loader to syslinux dir | |||
cp chroot/usr/lib/syslinux/mboot.c32 ${BOOTDIR} | |||
# bugfix live-build: sometime rename boot to live is needed | |||
if [ -d binary/boot ]; then | |||
echo "W: rename /boot to /live" | |||
mv binary/boot binary/live | |||
fi | |||
# copy xen.gz hypervisor to syslinux | |||
if [ -e chroot/boot/xen.gz ]; then | |||
cp chroot/boot/xen.gz binary/live/xen.gz | |||
else | |||
for f in chroot/boot/xen?*.gz; do | |||
cp $f binary/live/xen.gz | |||
done | |||
fi | |||
# copy kernel/initrd for booting | |||
if [ ! -e binary/live/vmlinuz ]; then | |||
cp chroot/vmlinuz binary/live/ | |||
fi | |||
if [ ! -e binary/live/initrd.img -a -e chroot/initrd.img ]; then | |||
cp chroot/initrd.img binary/live/initrd.img | |||
elif [ ! -e binary/live/initrd.img ]; then | |||
cp chroot/boot/initrd.img* binary/live/initrd.img | |||
fi | |||
# create XEN entries für syslinux | |||
cat > ${BOOTDIR}/xen.cfg <<EOF | |||
label xen | |||
menu label Xen 4 Live | |||
kernel mboot.c32 | |||
append /live/xen.gz --- /live/vmlinuz boot=live config locales=de_DE.UTF-8 keyboard-layouts=de --- /live/initrd.img | |||
label xen-p | |||
menu label Xen 4 Live (persistent) | |||
kernel mboot.c32 | |||
append /live/xen.gz --- /live/vmlinuz boot=live config quiet locales=de_DE.UTF-8 keyboard-layouts=de persistence --- /live/initrd.img | |||
label xen-c | |||
menu label Xen Live (Console) | |||
kernel mboot.c32 | |||
append /live/xen.gz --- /live/vmlinuz boot=live config S quiet locales=de_DE.UTF-8 keyboard-layouts=de --- /live/initrd.img | |||
EOF | |||
# insert XEN entries in boot menu | |||
sed -i -e "s;include live.cfg;include xen.cfg\ninclude live.cfg;g" ${BOOTDIR}/menu.cfg | |||
# fix live_build bug: usb/hdd image uses syslinux instead of isolinux | |||
# copy syslinux.cfg to isolinux.cfg | |||
if [ "${LB_BOOTLOADER}" = "syslinux" ]; then | |||
cp ${BOOTIR}/isolinux.cfg ${BOOTDIR}/syslinux.cfg | |||
fi | |||
EOF</pre> | |||
Version vom 30. Juli 2012, 21:06 Uhr
XEN 4 Live CD mit Debian (Wheezy)
Mit dem Debian Live Projekt ist eine XEN Live CD relativ einfach zu erstellen. Die Installation kann man auch auf einen USB-Stick installieren.
Zum booten wird SYSLINUX bzw. ISOLINUX verwendet. Hierbei ist zu berücksichtigen, dass zum Start von XEN das Bootprogramm mboot.c32 benötigt wird, damit der Kernel mit der Initrd auf dem XEN Hypervisor gestartet werden können. Ansonsten sind optional zusätzliche Anpassungen zum starten vom USB-Stick mit einem beschreibbaren Filesystem (VFAT) anstatt eines Read-Only Filesystems (Iso9660) zu beachten.
Benötigt wird "irgendein" Linux-System, bevorzugt Debian oder Ubuntu, um die vorhandenen Repositories zu verwenden:
root# apt-get install live-build live-boot live-config mkdir livexen cd livexen cp -r /usr/share/live/build/examples/auto . vi auto/config
Zusammenstellung der LiveCD
Als Basis wird ein Wheezy 64-Bit LXDE Desktop mit deutschem Layout definiert.
auto/config
lb config noauto \
--linux-flavours amd64 \
--distribution wheezy \
--archive-areas "main contrib non-free" \
--hostname xen4live \
--package-lists "lxde" \
--bootappend-live "locales=de_DE.UTF-8 keyboard-layouts=de" \
--iso-publisher Neobiker \
--iso-volume "XEN Live" \
"${@}"
Die optionalen Programme und XEN Anpassungen werden in den folgenden Konfig-files eingetragen.
config/package-lists/my.list.chroot
echo "ssh less pciutils lsbutils network-manager iceweasel gparted" > config/package-lists/my.list.chroot echo "xen-utils-4.1 xen-tools syslinux virt-manager virt-what virt-viewer" >> config/package-lists/my.list.chroot
config/hooks/xend.chroot und config/hooks/xen-syslinux.binary
echo > config/hooks/xend.chroot <<EOF
#!/bin/sh
echo "I: hooks/xend.chroot"
# modify xend-config.sxp (use NAT because WLAN don't likes bridges)
# enable virt-manager access
FILE=/etc/xen/xend-config.sxp
if test -e $FILE; then
sed -i \
-e "s;(vif-script vif-bridge);#(vif-script vif-bridge);g" \
-e "s;#(vif-script vif-nat);(vif-script vif-nat);g" \
-e "s;#(network-script network-nat);(network-script vif-nat);g" \
-e "s;#(xend-http-server no);(xend-http-server yes);g" \
-e "s;#(xend-unix-server no);(xend-unix-server yes);g" \
-e "s;#(vnc-listen '127.0.0.1');(vnc-listen '0.0.0.0');g" \
$FILE
fi
# modify /etc/default/xendomains
# disable VM save/restore
FILE=/etc/default/xendomains
if test -e $FILE; then
sed -i \
-e "s;XENDOMAINS_SAVE=/var/lib/xen/save;XENDOMAINS_SAVE=;g" \
-e "s;XENDOMAINS_RESTORE=true;XENDOMAINS_RESTORE=false;g" \
$FILE
fi
# set XEN toolstack to xm
FILE=/etc/default/xen
if test -e $FILE; then
sed -i \
-e "s;TOOLSTACK=;TOOLSTACK=xm;g" \
$FILE
fi
# XEN optimisation
# wait 10 seconds, check xend
# raise Dom0 prio
FILE=/etc/rc.local
cat << EOF >> $FILE
# XEN: Dom0 specific settings
sleep 10;
xend status >/dev/null 2>&1 && /etc/init.d/xen restart
if [ ! \`xend status\` ]; then
# give Dom0 preference over DomUs by Faktor x (weight 256 = DomU default)
xen sched-credit -d Domain-0 -w 1024
# PowerSave
xenpm set-scaling-governor ondemand
fi
EOF
# wheezy bugfix:
# virt-manager fails because of missing links
if [ ! -d /usr/lib64 ]; then
mkdir /usr/lib64
ln -s /usr/lib/xen-4.1 /usr/lib64/xen
fi
[ -d /usr/lib/xen-default ] || ln -s /usr/lib/xen-4.1 /usr/lib/xen-default
EOF
echo > config/hooks/xen-syslinux.binary <<EOF
#!/bin/sh
echo "I: hooks/xen-syslinux.binary"
# insert XEN entries in syslinux bootmenu
# bootdir is syslinux (hdd images) or isolinux (iso images)
BOOTDIR="binary/isolinux/"
[ ! -d "${BOOTDIR}" ] && BOOTDIR="binary/syslinux"
# xen needs multiboot loader mboot.c32 to start
[ -e chroot/usr/lib/syslinux/mboot.c32 ] || (echo "Error: missing mboot.c32 (syslinux)"; exit 1)
# copy multiboot loader to syslinux dir
cp chroot/usr/lib/syslinux/mboot.c32 ${BOOTDIR}
# bugfix live-build: sometime rename boot to live is needed
if [ -d binary/boot ]; then
echo "W: rename /boot to /live"
mv binary/boot binary/live
fi
# copy xen.gz hypervisor to syslinux
if [ -e chroot/boot/xen.gz ]; then
cp chroot/boot/xen.gz binary/live/xen.gz
else
for f in chroot/boot/xen?*.gz; do
cp $f binary/live/xen.gz
done
fi
# copy kernel/initrd for booting
if [ ! -e binary/live/vmlinuz ]; then
cp chroot/vmlinuz binary/live/
fi
if [ ! -e binary/live/initrd.img -a -e chroot/initrd.img ]; then
cp chroot/initrd.img binary/live/initrd.img
elif [ ! -e binary/live/initrd.img ]; then
cp chroot/boot/initrd.img* binary/live/initrd.img
fi
# create XEN entries für syslinux
cat > ${BOOTDIR}/xen.cfg <<EOF
label xen
menu label Xen 4 Live
kernel mboot.c32
append /live/xen.gz --- /live/vmlinuz boot=live config locales=de_DE.UTF-8 keyboard-layouts=de --- /live/initrd.img
label xen-p
menu label Xen 4 Live (persistent)
kernel mboot.c32
append /live/xen.gz --- /live/vmlinuz boot=live config quiet locales=de_DE.UTF-8 keyboard-layouts=de persistence --- /live/initrd.img
label xen-c
menu label Xen Live (Console)
kernel mboot.c32
append /live/xen.gz --- /live/vmlinuz boot=live config S quiet locales=de_DE.UTF-8 keyboard-layouts=de --- /live/initrd.img
EOF
# insert XEN entries in boot menu
sed -i -e "s;include live.cfg;include xen.cfg\ninclude live.cfg;g" ${BOOTDIR}/menu.cfg
# fix live_build bug: usb/hdd image uses syslinux instead of isolinux
# copy syslinux.cfg to isolinux.cfg
if [ "${LB_BOOTLOADER}" = "syslinux" ]; then
cp ${BOOTIR}/isolinux.cfg ${BOOTDIR}/syslinux.cfg
fi
EOF