XEN guest // Slackware Linux

Assuming the domU kernel has already been prepared

The dirty way (preferred)


Preparing the filesystem,

mkdir -p /data/guests/slack/
cd /data/guests/slack/

dd if=/dev/zero of=slack.ext4 bs=1024k count=0 seek=10240
mkfs.ext4 slack.ext4
#dd if=/dev/zero of=slack.swap bs=1024k count=0 seek=2048
#mkswap slack.swap
mkdir lala/
mount -o loop slack.ext4 lala/

local repo

Fetching the necessary sets. If you already got the sets, at least synchronize patches/.

mkdir -p /tftpboot/slackware142/
cd /tftpboot/slackware142/

lftp $mirror

cd slackware64/
mirror -c -e a
mirror -c -e ap
mirror -c -e d
mirror -c -e f
mirror -c -e k
mirror -c -e l
mirror -c -e n
cd ../patches/
mirror -c -e packages

install script

Warning: this will only work on a Slackware system or with installed installpkg and removepkg

cd /data/guests/slack/
wget http://pub.nethence.com/bin/slackware.install.bash.txt
cp slackware.install.bash.txt slackware.install.bash
#rm -rf lala/*
vi slackware.install.bash


diff -bu slackware.install.bash.txt slackware.install.bash
chmod +x slackware.install.bash
#./slackware.install.bash ADD
#./slackware.install.bash REC
./slackware.install.bash OPT

post-install from dom0

ls -lhFd lala/dev/pts/ # exists
ls -lhFd lala/dev/shm/ # exists
ls -lhF lala/etc/fstab # does not exist yet

cat > lala/etc/fstab <<-EOF
/dev/xvda1       /                ext4         defaults         1   1
#/dev/xvda2       swap             swap        defaults         0   0
devpts           /dev/pts         devpts      gid=5,mode=620   0   0
proc             /proc            proc        defaults         0   0
tmpfs            /dev/shm         tmpfs       defaults         0   0
cat lala/etc/fstab

ls -l lala/etc/rc.d/rc.udev # already executable

echo disabling useless shit from rc.d -- tag ADD
chmod -x lala/etc/rc.d/rc.cpufreq
chmod -x lala/etc/rc.d/rc.loop
chmod -x lala/etc/rc.d/rc.modules
chmod -x lala/etc/rc.d/rc.modules.local

echo disabling useless shit from rc.d -- tag REC
chmod -x lala/etc/rc.d/rc.bluetooth
chmod -x lala/etc/rc.d/rc.cgmanager
chmod -x lala/etc/rc.d/rc.cgproxy
chmod -x lala/etc/rc.d/rc.inetd

#chmod -x lala/etc/rc.d/rc.consolekit 
#chmod -x lala/etc/rc.d/rc.mcelog

brutal network setup,

mv -i lala/etc/rc.d/rc.inet1 lala/etc/rc.d/rc.inet1.dist
chmod -x lala/etc/rc.d/rc.inet1.dist
vi lala/etc/rc.d/rc.inet1


echo rc.inet1 PATH is $PATH

echo -n lo...
ifconfig lo up && echo done

echo -n eth0...
ifconfig eth0 x.x.x.x/xx up && echo done

echo -n default route...
route add default gw x.x.x.x && echo done

chmod +x lala/etc/rc.d/rc.inet1

to avoid keys generated for darkstar,

echo slack > lala/etc/HOSTNAME
mv lala/etc/hosts lala/etc/hosts.dist
cat > lala/etc/hosts <<-EOF   localhost
x.x.x.x     slack
x.x.x.x     gw

push your pub key over there,

mkdir lala/root/.ssh/
chmod 700 lala/root/.ssh/
vi lala/root/.ssh/authorized_keys
chmod 600 lala/root/.ssh/authorized_keys

#REC but forcibly installed with the script
ls -lhF lala/etc/rc.d/rc.sshd #already executable

cp -pi lala/etc/rc.d/rc.S lala/etc/rc.d/rc.S.dist
chmod -x lala/etc/rc.d/rc.S.dist
vi lala/etc/rc.d/rc.S

/tick #remove hwclock with it

cp -pi lala/etc/rc.d/rc.M lala/etc/rc.d/rc.M.dist
chmod -x lala/etc/rc.d/rc.M.dist
vi lala/etc/rc.d/rc.M

/powersave #remove
/icon #remove
/GTK #remove

fix the xen guest serial console,

ls -lhF lala/sbin/agetty
ls -lhF  lala/etc/termcap
cp -pi lala/etc/inittab lala/etc/inittab.dist
vi lala/etc/inittab

c1:12345:respawn:/sbin/agetty --noclear 115200,38400,9600 hvc0 linux

ls -lhF lala/etc/securetty
echo hvc0 >> lala/etc/securetty

fix the timezone,

ls -lF lala/etc/localtime-copied-from
ls -lF lala/etc/localtime
rm -f lala/etc/localtime-copied-from
rm -f lala/etc/localtime
ln -s ../usr/share/zoneinfo/Europe/Moscow lala/etc/localtime
#ln -s ../usr/share/zoneinfo/Europe/Paris lala/etc/localtime

finish up,

du -sh lala # full: 6.5G
umount lala

guest configuration

Preparing the guest configuration,

vi slack

kernel = "/data/kernels/vmlinuz.domU"
root = "/dev/xvda1 ro console=hvc0 ipv6.disable=1"
#extra = "init=/bin/bash"
name = "slack"
memory = "256"
vcpus = "2"
disk = ['tap:tapdisk:aio:/data/guests/slack/slack.ext4,xvda1,w']
vif = [ 'bridge=xenbr0, vifname=slack.0' ]

ready to go

xl create slack -c

What a pleasure, a clean and minimal gnu/linux distro.

template finish-up

In case this is a template and you are finished with the setup,

ls -lhF lala/etc/ssh/ssh_host_*
rm -fv lala/etc/ssh/ssh_host_*

The classical way (full disk)

Preparing the vdisk,

mkdir -p /data/guests/slackfull/
cd /data/guests/slackfull/

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

Grabbing the installer initrd,

cd /data/kernels/
mkdir slackware64.142
cd slackware64.142
wget https://mirror.yandex.ru/slackware/slackware64-14.2/isolinux/initrd.img

Setting up the guest,

cat > slackfull <<-EOF
kernel = "/vmlinuz"
#kernel = "/data/guests/vmlinuz.4.4.14.domu"
#root = "/dev/xvda1 ro console=hvc0 init=/bin/bash"
#root = "/dev/xvda1 ro console=hvc0"
#extra = "load_ramdisk=1 prompt_ramdisk=0 rw"
ramdisk = "/data/kernels/slackware64.142/initrd.img"
name = "slackfull"
memory = "256"
vcpus = "1"
disk = ['tap:tapdisk:aio:/data/guests/slackfull/slackfull.disk,xvda,w']
vif = [ 'bridge=xenbr0, vifname=slackfull.0' ]

And if you have no choice but to run it as HVM, add/remove,

type = "hvm"
boot = "cd"
sdl = 1
disk = ...
vif = [ 'type=ioemu,model=e1000,bridge=xenbr0, vifname=slackfull.0' ]


Launching the guest and installer,

xl create slackfull -c

dhcpcd eth0
ping x.x.x.x

cfdisk /dev/xvda

Note. also see the section about setting up the xen serial console above, you might want to do that against /mnt/ on a secondary console during the installation.

troubleshooting the guest (both flavors)

vi slackfull // vi slack

root = "/dev/xvda1 ro console=hvc0 init=/bin/bash"

mount -o remount,rw /
export TERM=xterm
dmesg | grep hvc


mount -n -o remount,ro /
halt -p


mount: mount point /dev/pts does not exist
mount: mount point /dev/shm does not exist

==> enabled rc.udev

interesting shit happens when you install the l and n sets before a and ap, for the record,

installpkg --root lala slackware64/l/glibc-2.23-x86_64-1.txz...sbin/ldconfig: Warning: ignoring configuration file that cannot be opened: /etc/ld.so.conf: No such file or directory

installpkg --root lala slackware64/l/polkit-0.113-x86_64-2.txz...grep: etc/passwd: No such file or directory
grep: etc/group: No such file or directory

installpkg --root lala slackware64/n/openssh-7.2p2-x86_64-1.txz...grep: etc/shadow: No such file or directory


fix (at boot time),

setterm: linux: unknown terminal type

Ref. http://www.unixguide.net/linux/faq/09.02.shtml




==> /var/log/mcelog <==
mcelog: Cannot find SMBIOS DMI tables
mcelog: Cannot open `/dev/mcelog': No such file or directory

==> /var/log/syslog <==
Jun 23 16:02:12 slack mcelog: Cannot find SMBIOS DMI tables
Jun 23 16:02:12 slack mcelog: Cannot open `/dev/mcelog': No such file or directory 

more pkgs

slackpkg install tcpdump libcap-ng libpcap libnl3 dbus


no need for modules

#tar tvzf vmlinuz.4.4.14.domu.modules.tar.gz
#tar xzf vmlinuz.4.4.14.domu.modules.tar.gz -C lala/

Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml