The officially official Devuan Forum!

You are not logged in.

#1 2018-12-20 15:16:24

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Xen and the art of VM

It is several years since I tried running Devuan Jessie, and some other non-systemd OSs in a virtual machine (VM) under Xen, using the instructions on their web-site :-

https://wiki.xenproject.org/wiki/How_to … 0,_Xen_4.4

At the time, my machine was still running Debian and the installation of Devuan was carried out using debootstrap. This required a small fiddle to give the debootstrap command the switches to avoid systemd and to supply the Devuan mirror.

Now that I have Devuan (ASCII) as my host machine (Dom0), I thought that I should try a clean install of ASCII as a guest (DomU), before thinking about having a look at Beowulf.

I had already installed xen, xen-tools and LVM from my earlier attempts and LVM was configured and in use
and the network bridge had been set-up as described in the link to Xen.

The steps needed to install ASCII looked something like this, omitting most of the mistakes on the way :-

Edit the file /etc/xen-tools/xen-tools.conf and ensure that debootstrap is set to the the standard /usr/sbin/debootstrap and that the distribution is set to ascii.

dist	= ascii
debootstrap-cmd = /usr/sbin/debootstrap
mirror = http://deb.devuan.org/merged

You may wish to increase the sizes allowed for the disk, swap and memory as well as setting up any of your networking settings.

I told it to not copy over users from Dom0 passwd etc. as my host had gathered a lot of rubbish over the years, including users and groups with names like systemd-network! It is easier to start with the clean passwd file and add users later :-

accounts = 0

You will also need to specify the name of the lvm volume group which you have set up, in my case HDD0

lvm = HDD0

When you are happy with your settings you will need to update the Xen in /usr/share/xen-tools, which does not know about Devuan! There are a list of scripts to run during the installation, sorted numerically. There are several OSs and distributions already known and most of the scripts are links to shared ones, but the setup-apt script in debian.d in not suitable for Devuan.

cd /usr/share/xen-tools
cp -rp debian.d devuan.d
ln -s devuan.d ascii.d
ln -s devuan.d beowulf.d
ln -s devuan.d ceres.d

You will need to edit devuan.d/20-setup-apt to correct the sources.list for the security updates.
I give you here the diff, which you may be able to feed to patch

# diff debian.d/20-setup-apt devuan.d/
44c44
< # Setup the sources.list file for new installations of Debian GNU/Linux.
---
> # Setup the sources.list file for new installations of Devuan GNU/Linux.
65c65
< if ( test "${dist}" "!=" "sid" && test "${dist}" "!=" "unstable" && \
---
> if ( test "${dist}" "!=" "ceres" && test "${dist}" "!=" "unstable" && \
73,74c73,74
< deb     http://security.debian.org/ ${dist}/updates  main contrib non-free
< deb-src http://security.debian.org/ ${dist}/updates  main contrib non-free
---
> deb     ${mirror}    ${dist}-security  main contrib non-free
> deb-src ${mirror}    ${dist}-security  main contrib non-free
82,83c82,83
< # deb     http://security.debian.org/ ${dist}/updates  main contrib non-free
< # deb-src http://security.debian.org/ ${dist}/updates  main contrib non-free
---
> # deb     ${mirror}    ${dist}-security  main contrib non-free
> # deb-src ${mirror}    ${dist}-security  main contrib non-free
87c87
<     
---
> 

If you make a mistake in creating the image you may choose to delete it and start again. The command would be

xen-delete-image --lvm HDD0

where HDD0 is your lvm volume group.

Now you can try and install ASCII.
Issue the command, which may take about 6 minutes for the minimal install

xen-create-image --hostname ascii

Depending on your settings in xen-tools.conf, you may need to enter a root password.
If all goes well you should have a configuration file /etc/xen/ascii.cfg as well as 2 new volumes in LVM, such as

# lvs

  LV             VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  Flightgear     HDD0 -wi-ao----   2.29g                                                    
  archive        HDD0 -wi-ao---- 330.00g                                                    
  ascii-disk     HDD0 -wi-ao----  20.00g                                                    
  ascii-swap     HDD0 -wi-ao----   2.00g                                                    
  devuan-disk    HDD0 -wi-a-----  10.00g                                                    
  devuan-swap    HDD0 -wi-a-----   1.00g

You can now try and boot it up. Using a separate console command rather than adding the "-c" to the create command stops pygrub from setting the console window to 24x80!

xl create /etc/xen/ascii.cfg
xl console ascii

Log in as root

apt-get update
apt-get dist-upgrade

When I tried this it updated libssl and perl-base.

When I tried to install lxde it also pulled in xcfe, so I went for lxqt.

apt-get install task-lxqt-desktop vnc4server gksu synaptic

You will need to configure your keyboard in the dialogue.
In order to feel at home I added :-

apt-get install rxvt-unicode claws-mail xauth

You may want to add in some users with something along the lines of e.g.

addgroup --gid 1026 user1
adduser --uid 1026 --gid 1026 user1

and then set up the user to make vnc work

su - user1
mkdir .vnc
cd .vnc
cat << EOF >> vnc.conf
# This file, $(HOME)/.vnc/vnc.conf will be sourced after /etc/vnc.conf,
# so values can be
# overwritten on a per-user basis. If you want to reactivate the default
# value here, you have to specify an undef value. For example, $fontPath
# will set to the default value after
#
# $fontPath = "/foo";
# $fontPath = undef;

# set up the screen size which you would like
$geometry = "1900x1200";

# Tell vncserver to accept connections from addresses other than localhost
$localhost = "no";
EOF
cd
vncserver

The first time you run vncserver you will be asked for a VNC password.

Then from the Dom0 machine as the user

vncviewer ascii:1

you will need to supply the VNC password to be able to connect. The session should then open up, in this case running the LXQt destop environment.

Then you are ready to try out your new machine.

Geoff

Offline

#2 2018-12-21 10:21:45

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

Having installed LXQt as the desktop environment, I notice that it is running Xfwm4 as the window manager. This seems to work, but I am more familiar with Openbox, so I installed that, which, helpfully pulls in Obconf. Having done that it was necessary to select that WM in the LXQt Session Settings preferences. Logging out kills off VNC at both ends. It is then only required to re-run vncserver on the guest and then vncviewer on the host.

Geoff

Offline

#3 2018-12-22 16:21:08

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

Install ascii via the installer

Since using debootstrap is fairly straightforward and since there has been some
discussion about the installer, I though that I should try a manual install under Xen
using the installer. I gave this guest the host name "inst".

With this approach it is necessary to create the disk space ourselves :-

lvcreate -n inst-disk -L 20g HDD0
lvcreate -n inst-swap -L 4g HDD0

The I downloaded devuan_ascii_2.0.0_amd64_desktop-live.iso and mounted it

mkdir /mnt/inst_iso
mount -t iso9660 /home/user1/src/devuan_ascii_2.0.0_amd64_desktop-live.iso /mnt/inst_iso/
ls -alF /mnt/inst_iso/live/
total 1012311
dr-xr-xr-x 1 root root      2048 Jun  6  2018 ./
dr-xr-xr-x 1 root root      2048 Jun  6  2018 ../
-r--r--r-- 1 root root 999809024 Jun  6  2018 filesystem.squashfs
-r--r--r-- 1 root root  32567908 Jun  6  2018 initrd.img
-r--r--r-- 1 root root   4224800 Jun  6  2018 vmlinuz

My first attempts at booting this hung after the hardware was initialised but before init would run, or indeed found! It would dump me into busybox.
I noticed fsmithred's posts saying that it needs username=devuan on the command line, comparing this with
/mnt/inst_iso/boot/grub/grub.cfg I set up /etc/xen/inst.cfg to look like this :-

#
# Configuration file for the Xen instance inst for a Devuan iso
#

kernel = "/mnt/inst_iso/live/vmlinuz"
ramdisk = "/mnt/inst_iso/live/initrd.img"
extra  = "boot=live username=devuan console=hvc0 nomodeset"

#
#  Disk device(s).
#

disk        = [
                  'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/home/user1/src/devuan_ascii_2.0.0_amd64_desktop-live.iso',
                  'format=raw, vdev=xvda2, access=w, target=/dev/HDD0/inst-disk',
                  'format=raw, vdev=xvda1, access=w, target=/dev/HDD0/inst-swap'
              ]

#
#  Local set-up
#
#   Limits

vcpus       = '2'
memory      = '2048'

#
#  Hostname
#
name        = 'inst'

#
#  Networking
#

vif         = [ 'mac=00:16:3E:00:00:04, bridge=xenbr0' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

This now initialises the hardware and starts init, including wicd. Here is the end of the console output

[ ok ] Starting MTA: exim4.
[ ok ] Starting NTP server: ntpd.
[ ok ] Starting slim: slim.
[info] speech-dispatcher disabled; edit /etc/default/speech-dispatcher.
[ ok ] Starting Network connection manager: wicd.
[    8.650931] elogind[2202]: New session 3 of user devuan.
[    8.651551] elogind[2202]: New session 5 of user devuan.
[    8.655100] elogind[2202]: New session 6 of user devuan.
[    8.661163] elogind[2202]: New session 1 of user devuan.
[    8.662042] elogind[2202]: New session 2 of user devuan.
[    8.665095] elogind[2202]: New session 4 of user devuan.
[    8.836325] NET: Registered protocol family 4
[    8.859224] NET: Registered protocol family 3
[    8.863520] NET: Registered protocol family 5

At this point is just hangs. I can ping the virtual machine and nmap tells me that the only port which is open is rpcbind, but the console seems to be dead. I can, as usual, get back to the host (Dom0) with the usual "^]" and kill off the guest from there.

I feel that I am close to it working, but not quite there yet...

Geoff

Offline

#4 2018-12-23 11:00:01

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

I suspect that the live OS has finished booting, but the console has not been connected in inittab

https://wiki.xenproject.org/wiki/Xen_Co … rk_anymore

When I look at the ascii VM which I created with debootstrap, the console looks fairly similar to trying to boot the live iso, until it gets to the login prompt. On the ascii VM, inittab contains the line :-

1:2345:respawn:/sbin/getty 38400 hvc0

In order to have a look at the inittab on the live iso, I loop-back mounted the iso and then needed to loop-back mount the filesystem.squashfs, with the command :-

mount /mnt/inst_iso/live/filesystem.squashfs /mnt/clone/ -t squashfs -o loop

I was then able to look at that inittab, which has the line :-

1:2345:respawn:/sbin/getty 38400 tty1

which is what I would expect to see!

I suspect that if I want this to work that I will need to unpack the iso and then unsquash the squashed FS.
I could then edit the inittab line and re-squash the FS. I wonder if I could leave the iso unpacked in a directory and boot from that.

Geoff

Offline

#5 2018-12-23 11:37:30

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,501  

Re: Xen and the art of VM

The inittab in the live session does not contain the line you posted for the getty. It gets changed by /lib/live/config/0160-sysvinit to the following:

1:2345:respawn:/bin/login -f devuan </dev/tty1 >/dev/tty1 2>&1

If you want to change it again, you could make a hook script that runs after the other live-config scripts, but I'm not sure where you could put it without rebuilding the iso. In the refracta8 (jessie) isos, I put a hook script in /live/hooks and then add 'hooks=file:///live/hooks/myscript' to the boot command. (yes, three slashes, and this is from memory, so check man live-config)

Or, if you're going to mount the iso and mess with files, you could just change that live-config script to do what you want.

Offline

#6 2018-12-23 16:47:25

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

Thank you for pointing that out. I'm not sure what would be the "correct" thing to do, but I have temporarily tried hacking the line in /lib/live/config/0160-sysvinit. I have then re-squashed filesystem.squashfs with the command

mksquashfs sqfs filesystem.squashfs

and then copied this over the original one in the unpacked iso. I then repacked the iso with

genisoimage -o my-ascii-live.iso -R inst_iso

I did have a quick look at the refracta tools, but got a bugs warning when I tried to install them, so used genisoimage.

Now when I try and boot up the new live iso as a VM it actually comes to the Devuan banner and a prompt, already logged in as devuan. It does complain :-

-bash: cannot set terminal process group (2443): Inappropriate ioctl for device
-bash: no job control in this shell

and the prompt do not have a newline and commands don't seem to do anything, but I will carry on prodding it...

Thank you for your help

Geoff

Last edited by Geoff 42 (2018-12-23 16:59:55)

Offline

#7 2018-12-24 00:35:05

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,501  

Re: Xen and the art of VM

I didn't think of it this morning, but you could just add 'noautologin' to the boot command. That would do the same as commenting out the sed command in 0160-sysvinit.

You might need to add some options to the genisoimage command. The xorriso command used to create the iso looks something like this.

xorriso -as mkisofs -r -J -joliet-long -l ${isohybrid_opt} \
    -partition_offset 16 -V "snapshot-live-cd"  -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot \
    -boot-load-size 4 -boot-info-table ${uefi_opt} -o "$snapshot_dir"/"$filename" iso/

isohybrid_opt is the path to isohdpfx.bin which is somewhere in /usr/lib/syslinux or /usr/lib/ISOLINUX. The exact location varies with the version of syslinux.
uefi_opt="-eltorito-alt-boot -e boot/grub/efiboot.img -isohybrid-gpt-basdat -no-emul-boot"

I'd be interested to know what error messages you got when trying to install refracta tools. If you don't want to do that in this thread, feel free to start another or email me. Thanks.

Offline

#8 2018-12-24 09:37:24

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

I selected refractainstaller-base and refractasnapshot-base for installation in synaptic and got the message :-

Retrieving bug reports... Done
Parsing Found/Fixed information... Done
serious bugs of live-config (→ 5.20170112+deb9u1) <Resolved in some Version>
 b1 - #886009 - live-config: race condition between live-config and systemd-tmpfiles-setup (Fixed: live-config/5.20180224)
Summary:
 live-config(1 bug)
Are you sure you want to install/upgrade the above packages? [Y/n/?/...] 

Geoff

Offline

#9 2018-12-24 09:39:41

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

Trying to install xorriso also produces the same bug report.

Geoff

Offline

#10 2018-12-24 10:26:25

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

I think that my edit of the 0160-sysvinit script was causing too many logins as it edited all 6 of the getty lines to be login! I have rolled that edit back and then edited /etc/inittab. I finally re-read the link

https://wiki.xenproject.org/wiki/Xen_Co … rk_anymore

but read it more carefully. The edit they suggest is to add an extra line to inittab :-

vc:2345:respawn:/sbin/getty 38400 hvc0

rather than modifying a tty entry. I have now done this and it works. I now get a single login prompt and I am able to login as devuan. (Adding noautologin stopped it working! In that there was no login prompt.)

devuan@devuan:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            981M     0  981M   0% /dev
tmpfs           200M  200K  200M   1% /run
/dev/xvdc       1.2G  1.2G     0 100% /lib/live/mount/medium
/dev/loop0      1.2G  1.2G     0 100% /lib/live/mount/rootfs/filesystem.squashfs
tmpfs           999M     0  999M   0% /lib/live/mount/overlay
overlay         999M  8.9M  990M   1% /
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           400M     0  400M   0% /run/shm
tmpfs           999M     0  999M   0% /tmp
tmpfs           999M     0  999M   0% /sys/fs/cgroup
tmpfs           200M     0  200M   0% /run/user/1000

I think that your concerns about the command to re-create the iso are quite valid and I would not be surprised if my iso were not bootable, however, with this technique under Xen, it does not need to be bootable as it is being passed the kernel and initram and can boot these. I think that it only needs the iso as a filesystem and what I have done is good enough, if not strictly correct.

I see that the live system does not include vnc, so I will need to investigate the easiest or the best way to get at the graphics.

Geoff

Offline

#11 2018-12-24 11:50:09

fsmithred
Administrator
Registered: 2016-11-25
Posts: 2,501  

Re: Xen and the art of VM

Looks like that bug only affects systemd. I've been using that version of live-config in ascii and haven't run into problems with it. But what live iso are you using? Both the desktop-live and minimal-live should have refractainstaller installed already. You could use the cli version of the installer and then add vnc to the installed system later.

Offline

#12 2018-12-24 14:48:50

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

My host system is running ASCII, but has evolved from Debian Jessie to Devuan Jessie to ASCII. Debian had moved to systemd before I had moved to Devuan, so there may well be some remains lying around, although I have tried to remove any systemd stuff.

The devuan_ascii_2.0.0_amd64_desktop-live.iso does indeed have the Refracta tools installed. I am keen to check out the Live set up and then the installation process. I think that I have a few more things to try to see if I can view X programs and the Xfce DE.

Geoff

Offline

#13 2018-12-24 16:57:42

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

I have now have things tidied up quite a bit, which includes commenting out the editing line in 0160-sysvinit

   

if [ -n "${LIVE_USERNAME}" ]
	then
#		sed -i -e "s|^\([^:]*:[^:]*:[^:]*\):.*getty.*\<\(ttyS\?[0-9]*\).*$|\1:/bin/login -f ${LIVE_USERNAME} </dev/\2 >/dev/\2 2>\&1|" /etc/inittab

		init q
	fi

and in /etc/inittab the added line at the end is now

vc:2345:respawn:/bin/login -f devuan </dev/hvc0 >/dev/hvc0 2>&1

The overall effect is that the usual getty lines are unaffected and devuan is already logged in on the console.

I then suspected that if you get Xen to use vnc for the frame buffer, that is is running in the host not the guest, which is fine as I have it installed on the host. The side effect is that you connect the vncviewer to the host address, which is probably the localhost. I added the following lines to /etc/xen/inst.cfg :-

# Graphic display

vfb         = [ 'vnc = 1, vnclisten = 0.0.0.0:1, vncpasswd = "devuan"' ]

I did try setting keymap="en-gb" in vbf = [ ] but this had the side effect of preventing the VM from booting up, I think it was that it couldn't find en-gb.

After running

xl create inst.cfg -c

it boots as expected, with devuan logged in on the console. I was then able, as myself, on the host, to run :-

vncviewer :0

This then displays the Xfce DE. The window is a bit small and I have not spotted any way to set the size of the display, but the DE has been set with a desktop item to shrink the text, which is v. helpful.

The configuration file /etc/xen/inst.cfg now looks like this :-

#
# Configuration file for the Xen instance inst for a Devuan iso
#

# bootloader = '/usr/lib/xen-4.8/bin/pygrub'

kernel = "/mnt/inst_iso/live/vmlinuz"
ramdisk = "/mnt/inst_iso/live/initrd.img"
extra  = "boot=live username=devuan console=hvc0"

#
#  Disk device(s).
#

disk        = [
                  'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/archive/isos/Live/my-ascii-live.iso',
                  'format=raw, vdev=xvda2, access=w, target=/dev/HDD0/inst-disk',
                  'format=raw, vdev=xvda1, access=w, target=/dev/HDD0/inst-swap',
              ]

#
#  Local set-up
#
#   Limits

vcpus       = '2'
memory      = '2048'

#
#  Hostname
#
name        = 'inst'

#
#  Networking
#

vif         = [ 'mac=00:16:3E:00:00:04, bridge=xenbr0' ]

# Graphics display

vfb         = [ 'vnc = 1, vnclisten = 0.0.0.0:1, vncpasswd = "devuan"' ]

#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

This then appears to be fully working, so that I might now try out the installation...

Geoff

Offline

#14 2018-12-26 11:13:06

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

The installation went ok and grub was installed on the guest's disk /dev/xvda2.

The next thing to do is to reconfigure the configuration file, /etc/xen/inst.cfg, to boot off the disk. Instead of booting from a copy of the kernel in the hosts address space, we use pygrub to look through the guest's installed grub set-up. It is also necessary to specify where root is found. I have also removed any vnc options as vnc doesn't seem to take any notice of them :-

#
# Configuration file for the Xen instance inst for a Devuan iso
#

bootloader = '/usr/lib/xen-4.8/bin/pygrub'

# kernel = "/mnt/inst_iso/live/vmlinuz"
# ramdisk = "/mnt/inst_iso/live/initrd.img"
# extra  = "boot=live username=devuan console=hvc0"
extra  = "console=hvc0"

#
#  Disk device(s).
#
root        = '/dev/xvda2 ro'

disk        = [
#                  'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/archive/isos/Live/my-ascii-live.iso',
                  'format=raw, vdev=xvda2, access=w, target=/dev/HDD0/inst-disk',
                  'format=raw, vdev=xvda1, access=w, target=/dev/HDD0/inst-swap',
              ]

#
#  Local set-up
#
#   Limits

vcpus       = '2'
memory      = '2048'

#
#  Hostname
#
name        = 'inst'

#
#  Networking
#

vif         = [ 'mac=00:16:3E:00:00:04, bridge=xenbr0' ]

# Graphic display

vfb         = [ 'vnc = 1' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'

This works reasonably well. There is no login prompt on the console, but I can connect as myself using vnc from the host

vncviewer :0

The vnc window opens with slim and I can log in as expected.

Geoff

Last edited by Geoff 42 (2018-12-26 14:43:20)

Offline

#15 2018-12-26 11:29:53

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

For the installation process itself I used the gui and it generally went ok.
When it came to setting up the disk space I tried running gparted, but it could only see the CDROM image xvdc and not the 2 chunks of disk xvda1 and xvda2. When I came out of gparted I was offered a choice of disk on which to install, which included xvda2, which I accepted and it all well ok. At the end I let it install grub onto xvda2. I think that this was needed so that I could use pygrub to boot whatever is the current set up on the guest's disk. I had seen a warning about the graphics not working well under qemu, although I can't relocate this now! With this set-up, the frame buffer is handled by vnc running in the host's space, with some involvement from qemu. The installation process did not seem to follow the new (?) guide :-

https://devuan.org/os/documentation/ins … stall.html

Maybe that guide was not from the live iso. Now I know how to do it, I may have a few more goes at installation, including the ncurses interface.

Geoff

Offline

#16 2018-12-26 14:45:44

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

On the earlier question about Refracta tools, I had a look at that. The bug report referred to a race condition between live-config and systemd-tmpfiles-setup. I was unable to find a package called systemd-tmpfiles-setup, but I did see that live-config depended on either live-config-systemd or live-config-backend. I was unable to find live-config-systemd but I had got live-config-sysvinit installed. I therefore tried installing live-config and ignored the warning about the bug. I was then able to install refractainstaller-[base|installer] and refractasnapshot-base with no further warnings.

Geoff

Offline

#17 2018-12-26 17:49:35

golinux
Administrator
Registered: 2016-11-25
Posts: 3,345  

Re: Xen and the art of VM

Geoff 42 wrote:

The installation process did not seem to follow the new (?) guide :-

https://devuan.org/os/documentation/ins … stall.html

Maybe that guide was not from the live iso. Now I know how to do it, I may have a few more goes at installation, including the ncurses interface.

Geoff

That guide is for the classic Debian installer which most of our isos use.   Only the -live isos use the refracta installer.  We are currently working on a similar guide for the refractainstaller.

Online

#18 2018-12-27 10:13:03

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

OK, thank you for the clarification.

Geoff

Offline

#19 2018-12-27 15:52:43

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

I have tried running the installation from the Live set-up a few time now and it seems reasonably straightforward, whether with the GUI or from the CLI. One thing that it did highlight was that the first time through the installation process did not pick up the disk space I had allocated for swap, but had installed a swap file as /swapfile. I had allocated a disk partition /dev/xvda1. It was necessary to prepare it with

mkswap -c /dev/xvda1

which provided the UUID. This could then be edited into /etc/fstab to replace /swapfile. This was activated with

swapon -a
swapoff /swapfile
swapon -s
rm /swapfile

On later runs through the install, it picked up on the swap space.

One other problem I have encountered was the keyboard localisation. I told it to use en-GB with a 105 key KB, but after the installation it does not work as expected, including the absence of "#" and "|" which can make life a bit tricky. On the host machine, where it works, I find :-

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     gb

while on the guest which doesn't work correctly I find :-

$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     gb

I wonder whether this is related to the vncserver being run under qemu, which was unable to find en-gb.

Geoff

Offline

#20 2018-12-27 17:12:12

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

I have now tried installing the tightvncserver and the openssh-server on the new guest. If I then comment out the references to vnc in the configuration file for xl, in the example I am working on the is /etc/xen/inst.cfg, then I can run xl create inst.cfg. Once it has booted up I can ssh into it and then run vncserver and then on the host machine run vncviewer inst:1 and a reasonable sized window opens running the xfce DE. The keyboard now works correctly. I also believe that it is straightforward to be able to specify the size of the vnc display, when run this way.

Geoff

Offline

#21 2018-12-29 18:11:07

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

Netinstall

Having tried the Live iso, I then wanted to try the Netinst iso.

I download devuan_ascii_2.0.0_amd64_netinst.iso

mount -t iso9660 /home/user1/src/devuan_ascii_2.0.0_amd64_netinst.iso /mnt/inst_iso/

and then set up the disk space for the VM

lvcreate -n net-disk -L 20g HDD0
lvcreate -n net-swap -L 4g HDD0
mkfs.ext4 -L root /dev/HDD0/net-disk
mkswap -L swap /dev/HDD0/net-swap
cd /etc/xen

and set up the cfg file net.cfg

#
# Configuration file for the Xen instance net for a Devuan iso
#

kernel = "/mnt/inst_iso/install.amd/vmlinuz"
ramdisk = "/mnt/inst_iso/install.amd/initrd.gz"

# bootloader = '/usr/lib/xen-4.8/bin/pygrub'
# root        = '/dev/xvda2 ro'

extra  = "console=hvc0"

#
#  Disk device(s).
#

disk        = [
                  'format=raw, vdev=xvdc, access=r, devtype=cdrom, target=/home/user1/src/devuan_ascii_2.0.0_amd64_netinst.iso',
                  'format=raw, vdev=xvda2, access=w, target=/dev/HDD0/net-disk',
                  'format=raw, vdev=xvda1, access=w, target=/dev/HDD0/net-swap',
              ]

#
#  Local set-up
#
#   Limits

vcpus       = '2'
memory      = '2048'

#
#  Hostname
#
name        = 'net'

#
#  Networking
#

vif         = [ 'mac=00:16:3E:00:00:06, bridge=xenbr0' ]

#
#  Behaviour
#
on_poweroff = 'destroy'
on_reboot   = 'restart'
on_crash    = 'restart'
xl create net.cfg -c

This boots straight into the installation.

This runs nicely until the disk set up.
I would like to be able to tell you what I did to get it working, but I went round so many times that I am not sure what the magic incantation was. I did go back to the main menu and selected the shell. I was then able to run

mkfs.ext4 -L root /dev/xvda2
mkswap -L swap /dev/xvda1

Exiting the shell gets back to the main menu at the disk option and going round several more times it eventually worked. It wanted to chop up the main bit of disk for root and swap and not use the disk I wanted to use for swap. It was probably just a matter of getting the settings just right, but it was quite hard work. If the settings were not correct, then it would fail to set up the partitions.

Once the disk set-up was ok it went on and installed the base system and then went on to let me select what extra software I wanted:-

Devuan DE
LXQt
SSH server
std sys utils

But, what is Console productivity?

It went through the installion, but after installing LibreOffice-common got

                     Installation step failed  
     │ An installation step failed. You can try to run the failing item  │
     │ again from the menu, or skip it and choose something else. The    │
     │ failing step is: Select and install software                      │

After escaping out to the shell and then coming back to the menu, I re-ran "select and install software"

cleaning up...

and it seemed ok, but then

Installation step failed (grub)
no boot installed.

Dropping back to the shell again I could see :-

# df -h
Filesystem                Size      Used Available Use% Mounted on
none                    199.6M     36.0K    199.6M   0% /run
devtmpfs                972.1M         0    972.1M   0% /dev
/dev/xvda2               19.6G      4.0G     14.6G  21% /target
/dev/xvda2               19.6G      4.0G     14.6G  21% /dev/.static/dev
devtmpfs                972.1M         0    972.1M   0% /target/dev
/dev/xvdc               298.0M    298.0M         0 100% /target/media/cdrom0
/dev/xvdc               298.0M    298.0M         0 100% /cdrom

While I was there I quickly edited inittab to set up the virtual console :-

cd /target/etc
cat << EOF >> inittab
vc:2345:respawn:/sbin/getty 38400 hvc0
EOF

and then to sort out the grub situation I copied over /boot/grub from my earlier effort "inst" to "net" and
edited the uuid to be /dev/xvda2 and checked the kernel version number v. carefully!!!

coming back to the menu, it then wanted to reboot. I let it do this, but then from the host I killed it off :-

xl destroy net

After editing /etc/xen/net.cfg to boot off the disk rather than the iso, by commenting out the kernel and ramdisk lines along with the iso disk entry and uncommenting the bootloader and root line.

xl create net.cfg -c

booted correctly and I can login on the console as and run apt-get :-

apt-get install vnc4server
apt-get install grub-pc

I had to tell grub-pc to set up /dev/xvda2 which seems to have sorted the boot set-up

One way to access the new VM (called "net") is :-

ssh -L 5901:localhost:5901 net

and then on "net"

vncserver -geometry 1260x960

adjusting the size to suit, but possibly a little smaller than the clear area on your screen, to avoid getting scroll bars, etc.

Back on the host you connect over the ssh link with

vncviewer :1

This seems to work nicely and the keyboard is set up correctly and vnc works smoothly.

Geoff

Offline

#22 2019-01-02 16:25:50

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

Beowulf

What I really wanted to do was to try out Beowulf, installing it from scratch. The easiest way to install it under Xen is with xen-tools using debootstrap. I am assuming the modifications to the set up listed at the start of this rambling thread, including having set-up xen-tools.conf to install ASCII.

cd /etc/xen-tools

edit xen-tools.conf and change the distribution name to beowulf

xen-create-image --hostname beowulf
Use of uninitialized value within %DIST in pattern match (m//) at /usr/bin/xen-create-image line 1803.

But seems to run ok.
Give it the new root password and it's all done.

xl create beowulf.cfg -c

boots ok but for a pause for random, then login prompt appears.

root@beowulf:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            953M     0  953M   0% /dev
tmpfs           199M   60K  199M   1% /run
/dev/xvda2       20G  653M   18G   4% /
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           808M     0  808M   0% /run/shm
root@beowulf:~# swapon -s
Filename				Type		Size	Used	Priority
/dev/xvda1                             	partition	2097148	0	-2
root@beowulf:~# uname -a
Linux beowulf 4.19.0-1-amd64 #1 SMP Debian 4.19.12-1 (2018-12-22) x86_64 GNU/Linux

This is a fairly minimal installation, it uses 653M of dik. I now want to install LXQt

apt-get update
apt-get dist-upgrade
root@beowulf:~# apt-cache policy policykit-1
policykit-1:
  Installed: (none)
  Candidate: 0.105-23
  Version table:
     0.105-23 500
        500 http://deb.devuan.org/merged beowulf/main amd64 Packages

Following the advice from Fred43 in the Beowulf thread :-

https://dev1galaxy.org/viewtopic.php?id=2301

cd /etc/apt/preferences.d

edit avoid_some_beo

  Package: policykit-1
  Pin: release a=beowulf
  Pin-Priority: -1

  Package: libpolkit-agent-1-0
  Pin: release a=beowulf
  Pin-Priority: -1 

  Package: libpolkit-backend-1-0
  Pin: release a=beowulf
  Pin-Priority: -1

  Package: libpolkit-gobject-1-0
  Pin: release a=beowulf
  Pin-Priority: -1
cd ..

edit sources.list and add in :-

#
# ASCII for policykit-1 etc
#
deb     http://deb.devuan.org/merged     ascii main  

This on its own did not seem to be good enough

apt-get update
apt-get install policykit-1

pulls in the other ones listed above and someother stuff, but they are the wrong versions, from Beowulf.

root@beowulf:/etc/apt# apt-cache policy policykit-1
policykit-1:
  Installed: 0.105-23
  Candidate: 0.105-23
  Version table:
 *** 0.105-23 500
        500 http://deb.devuan.org/merged beowulf/main amd64 Packages
        100 /var/lib/dpkg/status
     0.105-18+devuan2.11 500
        500 http://deb.devuan.org/merged ascii/main amd64 Packages

apt-get purge policykit-1
apt-get autoremove

As I didn't trust myself to type in the version numbers correctly, I used the "/ascii" method to get the right versions

apt-get install policykit-1/ascii libpolkit-agent-1-0/ascii libpolkit-backend-1-0/ascii libpolkit-gobject-1-0/ascii
Selected version '0.105-18+devuan2.11' (Devuan:2.0/stable [amd64]) for 'policykit-1'
Selected version '0.105-18+devuan2.11' (Devuan:2.0/stable [amd64]) for 'libpolkit-agent-1-0'
Selected version '0.105-18+devuan2.11' (Devuan:2.0/stable [all]) for 'libpolkit-backend-1-0'
Selected version '0.105-18+devuan2.11' (Devuan:2.0/stable [all]) for 'libpolkit-gobject-1-0'
The following packages were automatically installed and are no longer required:
  elogind libelogind0
The following packages will be REMOVED:
  libpam-elogind

It does install a range of other stuff but looked ok.

edit sources.list and comment out the ascii line

apt-get update
apt-get install task-lxqt-desktop task-british-desktop
The following packages have unmet dependencies:
 task-lxqt-desktop : Depends: libpolkit-backend-elogind-1-0 but it is not installable

put back the ascii repositary and try again but specify /ascii

apt-get aptitude
apt-get install libpolkit-backend-elogind-1-0/ascii libpolkit-gobject-elogind-1-0/ascii

This was ok, but then the following fails.

apt-get install task-lxqt-desktop task-british-desktop

The following packages have unmet dependencies:
 task-lxqt-desktop : Depends: policykit-1 but it is not going to be installed
                     Depends: libpolkit-backend-elogind-1-0 but it is not going to be installed

They are on the ascii versions. I read that aptitude is better at conflict resolution, so tried

aptitude install task-lxqt-desktop task-british-desktop
 :
 :
 The following packages will be upgraded:
  libpolkit-agent-1-0 libpolkit-gobject-1-0 
2 packages upgraded, 1257 newly installed, 2 to remove and 2 not upgraded.
Need to get 861 MB/861 MB of archives. After unpacking 3212 MB will be used.
The following packages have unmet dependencies:
 libx11-6 : Depends: libx11-data but it is not going to be installed
 libpolkit-backend-elogind-1-0 : Depends: libpolkit-gobject-1-0 (= 0.105-18+devuan2.11) but 0.105-23 is to be installed
 policykit-1 : Depends: libpolkit-agent-1-0 (= 0.105-18+devuan2.11) but 0.105-23 is to be installed
               Depends: libpolkit-gobject-1-0 (= 0.105-18+devuan2.11) but 0.105-23 is to be installed
The following actions will resolve these dependencies:

     Keep the following packages at their current version:
1)     gir1.2-polkit-1.0 [Not Installed]                  
2)     libpolkit-agent-1-0 [0.105-18+devuan2.11 (now)]    
3)     libpolkit-gobject-1-0 [0.105-18+devuan2.11 (now)]  
4)     libx11-data [2:1.6.7-1 (now, testing)]             
5)     system-config-printer [Not Installed]              

     Leave the following dependencies unresolved:         
6)     lxqt-config recommends system-config-printer       
7)     task-lxqt-desktop recommends system-config-printer 

Accept this solution? [Y/n/q/?] y

This then proceeds and needs the keyboard setting up. I think that everything looks ok.

apt-get install vnc4server rxvt-unicode-256color

from the host machine :-

ssh -L 5901:localhost:5901 beowulf
vncserver -geometry 1260x960

then back on the host machine :-

vncviewer :1

and it is running LXQt ;-)

cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
proc            /proc           proc    defaults        0       0
devpts          /dev/pts        devpts  rw,noexec,nosuid,gid=5,mode=620 0  0
/dev/xvda1 none swap sw 0 0
/dev/xvda2 / ext4 noatime,nodiratime,errors=remount-ro 0 1

synaptic runs and I can install openbox and spacefm

Alternatively try this without running the vnc stream over ssh :-

ssh beowulf
vncserver -geometry 1260x960 -localhost no

then back on the host machine

vncviewer beowulf:1

You can try ssh -f which closes the link after running the command :-

ssh -f beowulf vncserver -geometry 1260x960 -localhost no

you may be asked for a password

vncviewer beowulf:1 &

you may be asked for the vnc connection password

This runs but seems to bugger up authentication!!! I can't run synaptic while leaving open the ssh link allows it to ask for a password in a separate X window via vnc.
I think that using ssh -f ends up closing the session on beowulf, which then interfers with the authentication process.

apt-get update
apt-get dist-upgrade

produces a very long list of packages which can be removed by autoremove as well as :-

The following packages will be REMOVED:
  libpolkit-backend-elogind-1-0 task-lxqt-desktop

I therefore tried using aptitude instead.

aptitude update
aptitude safe-upgrade

this looks ok and ends :-

Current status: 4 (-71) upgradable.

I can still run synaptic, so the authentication still works and reports :-

Installed (upgradable)

libpolkit-agent-1-0
libpolkit-backend-1-0
libpolkit-gobject-1-0
policykit-1

which is what I think I want!

Some minor tidying-up includes using Spacefm instead of PCmanfm :-

edit /etc/xdg/autostart/lxqt-desktop.desktop

change pcmanfm-qt into spacefm

Although gksu has been removed in Beowulf, lxqt-sudo works instead.

So far it looks good, although I am using aptitude for updates rather than apt-get.

Geoff

Last edited by Geoff 42 (2019-01-02 16:26:41)

Offline

#23 2019-01-03 15:50:53

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

I wanted to check whether I really needed to use aptitude for the upgrades, so I tried

apt-get update
apt-get upgrade

(selecting "no") and then

apt-get dist-upgrade

(again selecting "no")

apt-get upgrade wanted to do what I wanted

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 policykit-1
The following packages will be upgraded:
...

while dist-upgrade reported the following

The following packages will be REMOVED:
  libpolkit-backend-elogind-1-0 task-lxqt-desktop

as well as offering all the stuff I wanted for autoremove.

I let apt-get upgrade run and all seems well. I assume that this is because it corresponds to aptitude safe-upgrade rather than any special magic in aptitude! I think that aptitude was useful for sorting out the main install.

Geoff

Offline

#24 2019-01-24 10:44:16

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

Sound

Having got Beowulf running as a Xen guest VM (DomU), I wanted to check that things were working properly. I therefore needed to get the audio working. I added myself to the group 'audio' on DomU with something like

addgroup user1 audio

This does not take effect until re-logging in but it may even be necessary to reboot DomU.

I tried the emulated sound using qemu, so on Dom0 :-

$ qemu-system-i386 -soundhw help
Valid sound card names (comma separated):
sb16        Creative Sound Blaster 16
es1370      ENSONIQ AudioPCI ES1370
ac97        Intel 82801AA AC97 Audio
adlib       Yamaha YM3812 (OPL2)
gus         Gravis Ultrasound GF1
cs4231a     CS4231A
hda         Intel HD Audio
pcspk       PC speaker

I actually have an Intel card, so went for 'hda' and later tried 'all'.
I Tried adding this to the beowulf.cfg

soundhw     = 'hda'

which should use qemu to emulate a card, but this did not work. I then tried

vsnd        = [
                 [ 'CARD, short-name=Main',
                   'PCM, name=Main',
                       'STREAM, id=0, type=p',
                       'STREAM, id=1, type=c',
                 ]
              ]   

this still produces :-

aplay -l
aplay: device_list:272: no soundcards found...

The next thing to try was passing the hardware sound card through to DomU.

https://wiki.xenproject.org/wiki/Xen_PCI_Passthrough

On Dom0

lspci|grep -i audio

notice which is the sound card you want to use. Mine was 00:1b.0

modprobe xen-pciback
xl pci-assignable-add 00:1b.0
xl list
xl pci-attach beowulf '00:1b.0'

The DomU kernel does pick up the newly attached pci stuff without a reboot.

aplay /usr/share/sounds/alsa/*

This now works and both vlc and Firefox play stuff nicely on DomU,
but, of course, Dom0 can no longer access the sound card...

aplay -l
aplay: device_list:270: no soundcards found...

However, the passing through, by this method, is not persistant, so after a re-boot should revert to normal. But you can also revert manually :-

# xl pci-list beowulf
Vdev Device
00.0 0000:00:1b.0

# xl pci-assignable-remove -r '00:1b.0'
libxl: info: libxl_pci.c:844:libxl__device_pci_assignable_remove: Rebinding to driver at /sys/bus/pci/drivers/snd_hda_intel

and Dom0 can now see the card again

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC892 Analog [ALC892 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC892 Digital [ALC892 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

The sound works well in DomU and the set up is ok for testing purposes. It is possible to make the set-up persistant as described at the URL above.

I did spot a "Howto" using Jack between Dom0 and DomU to get sound working in both, although I have not tried it.
https://forums.linuxmint.com/viewtopic. … 2&t=160527

Geoff

Offline

#25 2019-02-03 15:57:37

Geoff 42
Member
Registered: 2016-12-15
Posts: 462  

Re: Xen and the art of VM

USB

The next thing I wanted to try was using USB devices in DomU.

The Xen's documentation on USB PassThrough
https://wiki.xenproject.org/wiki/Xen_USB_Passthrough
seems to hint that it doesn't work and if you are not able to use PCI PassThrough to give an entire USB hub to DomU then you could use client/server software to pass the USB control over the network connection, mentioning USBIP. I was unable to get the Xen USB PassThrough to work.

Some of the USBIP documentation seems to be a bit out of date.
https://sourceforge.net/p/usbip/git-win … ace/README

man usbip
usbip help

but with a bit of trial and error it works quite well. It is not restricted to Xen or VMs and should work between real machines as well.

On Dom0 (the host) install usbip:-

apt-get install usbip

modprobe usbip-core
modprobe usbip-host
usbipd -D
usbip list -l
 - busid 2-1 (046d:c52b)
   Logitech, Inc. : Unifying Receiver (046d:c52b)

 - busid 2-2 (0781:5151)
   SanDisk Corp. : Cruzer Micro Flash Drive (0781:5151)

usbip bind --busid 2-2
usbip: info: bind device on busid 2-2: complete

then on beowulf (DomU - the client) install usbip

apt-get install usbip

modprobe usbip-core
modprobe vhci_hcd

this only seems to work with the numeric address of the server

usbip list -r 192.168.42.9
Exportable USB devices
======================
 - 192.168.42.9
        2-2: SanDisk Corp. : Cruzer Micro Flash Drive (0781:5151)
           : /sys/devices/pci0000:00/0000:00:14.0/usb2/2-2
           : (Defined at Interface level) (00/00/00)

usbip attach -r 192.168.42.9 -b 2-2

I was then asked for authentication as Spacefm popped up. There was some confusion with one window complaining about another authentication in progress. I think this is a conflict between gvfs and Spacefm both trying to mount the device, with gvfs winning. I dismissed that one and authenticated as me and Spacefm had the usb memory stick mounted via gvfsd-fuse plus the 2 partitions displayed. I could unmount the gvfs in Spacefm and then unmount sda1 and sda2 (my 'real' disk is xvda2)

usbip port
Imported USB devices
====================
Port 00: <Port in Use> at High Speed(480Mbps)
       SanDisk Corp. : Cruzer Micro Flash Drive (0781:5151)
       1-1 -> usbip://192.168.42.9:3240/2-2
           -> remote bus/dev 002/005

usbip detach -p 0
usbip: info: Port 0 is now detached!

I have now removed gvfs and installed udevil. There is now no conflict over authentication. I can now mount and unmount the partitions at will in Spacefm.

Using usbip attach and detach seems to be like plugging and unplugging the memory stick.

usbip attach -r 192.168.42.9 -b 2-2
lsusb
Bus 016 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 015 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 014 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 013 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 012 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 011 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 009 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 010 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 008 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 007 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 006 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 005 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 002: ID 0781:5151 SanDisk Corp. Cruzer Micro Flash Drive
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

usbip detach -p 0
usbip: info: Port 0 is now detached!

Back on Dom0 (the server) :-

usbip unbind -b 2-2
usbip: info: unbind device on busid 2-2: complete

and the device is again available on Dom0.

I have only tested this with a memory stick so far, but will try some other devices.

Geoff

Offline

Board footer