Systemd using systemctl and legacy init scripts

I recently played with the Solus Linux distribution to check out budgie on the desktop. Solus(previously evolveOS) use systemd like most distributions now do. Of course anything I test is inside a VM and I wanted to get the Virtualbox Guest Additions to work. During the guest additions install from ISO it does complain about not knowing the distribution and for the most part when the OS is not recognized Virtualbox Guest Additions install then just stick the init scripts in /etc/init.d and let you figure it out.

Since I wanted to play with systemd a little bit here is what I did to make the guest additions scripts run at boot.  Here is a link with some comparisons between systemd and sysvinit: https://fedoraproject.org/wiki/SysVinit_to_Systemd_Cheatsheet

Lets add some units so systemctl can do its work.

$ pwd
/usr/lib/systemd/system

$ cat vboxadd.service
[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/vboxadd
Description=LSB: VirtualBox Linux Additions kernel modules
Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/init.d/vboxadd start
ExecStop=/etc/init.d/vboxadd stop

[Install]
WantedBy=multi-user.target

Ok let’s enable the unit.

$ systemctl enable vboxadd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vboxadd.service to /usr/lib64/systemd/system/vboxadd.service.

$ systemctl status vboxadd.service
● vboxadd.service - LSB: VirtualBox Linux Additions kernel modules
   Loaded: loaded (/etc/init.d/vboxadd; enabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:systemd-sysv-generator(8)

Now start this service.

$ systemctl start vboxadd.service

And check it’s status.

$ systemctl status vboxadd.service
● vboxadd.service - LSB: VirtualBox Linux Additions kernel modules
   Loaded: loaded (/etc/init.d/vboxadd; enabled; vendor preset: enabled)
   Active: active (exited) since Thu 2015-05-14 13:39:40 CDT; 2s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 610 ExecStart=/etc/init.d/vboxadd start (code=exited, status=0/SUCCESS)

May 14 13:39:40 solus vboxadd[610]: Starting the VirtualBox Guest Additions ...done.

You can now do the same for the other two init scripts namely vboxadd-service and vboxadd-x11.

$ cat vboxadd-service.service
[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/vboxadd-service
Description=LSB: VirtualBox Additions service
Before=runlevel2.target runlevel3.target runlevel4.target runlevel5.target shutdown.target
After=vboxadd.service
Conflicts=shutdown.target

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/init.d/vboxadd-service start
ExecStop=/etc/init.d/vboxadd-service stop

[Install]
WantedBy=multi-user.target

$ systemctl enable vboxadd-service.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vboxadd-service.service to /usr/lib64/systemd/system/vboxadd-service.service.

$ systemctl start vboxadd-service.service

$ systemctl status vboxadd-service.service
● vboxadd-service.service - LSB: VirtualBox Additions service
   Loaded: loaded (/etc/init.d/vboxadd-service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2015-05-14 13:46:01 CDT; 1s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 614 ExecStart=/etc/init.d/vboxadd-service start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/vboxadd-service.service
           └─622 /usr/sbin/VBoxService

May 14 13:46:01 solus vboxadd-service[614]: Starting VirtualBox Guest Addition service  ...done.

$ cat vboxadd-x11.service
[Unit]
Documentation=man:systemd-sysv-generator(8)
SourcePath=/etc/init.d/vboxadd-x11
Description=LSB: VirtualBox Linux Additions kernel modules

[Service]
Type=forking
Restart=no
TimeoutSec=5min
IgnoreSIGPIPE=no
KillMode=process
GuessMainPID=no
RemainAfterExit=yes
ExecStart=/etc/init.d/vboxadd-x11 start
ExecStop=/etc/init.d/vboxadd-x11 stop

[Install]
WantedBy=multi-user.target

$ systemctl enable vboxadd-x11.service
Created symlink from /etc/systemd/system/multi-user.target.wants/vboxadd-x11.service to /usr/lib64/systemd/system/vboxadd-x11.service.

$ systemctl start vboxadd-x11.service

$ systemctl status vboxadd-x11.service
● vboxadd-x11.service - LSB: VirtualBox Linux Additions kernel modules
   Loaded: loaded (/etc/init.d/vboxadd-x11; enabled; vendor preset: enabled)
   Active: active (exited) since Thu 2015-05-14 13:47:04 CDT; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 649 ExecStart=/etc/init.d/vboxadd-x11 start (code=exited, status=0/SUCCESS)

At this point after reboot looks like systemd ran the scripts.  Let’s see if the vbox scripts/units show as a dependency for multi-user.

$ systemctl show -p "Wants" multi-user.target
Wants=systemd-logind.service systemd-update-utmp-runlevel.service NetworkManager.service dbus.service getty.target vboxadd.service vboxadd-x11.service systemd-resolved.service vboxadd-service.service remote-fs.target systemd-ask-password-wall.path systemd-user-sessions.service

Virtualbox and Windows OEM Guest

Sometimes you have a Window client sitting around running an important piece of software and the hardware is ancient. All you want to do is run this OS + critical application AS-IS and not risk the hardware failing. And yes you should upgrade, migrate whatever but that is just not in scope for you at the moment. Virtualization is ideal but Microsoft licensing might make it difficult. I am still unclear if it is legal or not to run an OEM Windows OS inside a virtual machine.

If you have no other option and virtualization is the only choice this post might come in handy when you are bumping into Windows Activation issues and using Virtualbox.  I am sure other virtualization solutions have their own options to simulate BIOS configurations.

You can play with simulating the PC BIOS (read further down). Or you can also try the SLIC ACPI table option.

For my test the SLIC option worked.

Using SLIC tables:

$ VBoxManage setextradata win7 "VBoxInternal/Devices/acpi/0/Config/CustomTable" "/tmp/SLIC"

That worked!!

Trying on a completely different Virtualbox host (different physical attributes).

$ VBoxManage setextradata win7-vostro "VBoxInternal/Devices/acpi/0/Config/CustomTable" "/DATA/VirtualBox/Machines/win7-vostro/SLIC"

If you need to play with emulating your BIOS:

# dmidecode -t0
# dmidecode 2.12
SMBIOS 2.5 present.

Handle 0x0001, DMI type 0, 24 bytes
BIOS Information
Vendor: Dell Inc.
Version: A08
Release Date: 03/05/2010
Address: 0xE2480
Runtime Size: 121728 bytes
ROM Size: 64 kB
Characteristics:
ISA is supported
PCI is supported
PC Card (PCMCIA) is supported
PNP is supported
BIOS is upgradeable
BIOS shadowing is allowed
ESCD support is available
Boot from CD is supported
ACPI is supported
USB legacy is supported
AGP is supported
BIOS boot specification is supported
Targeted content distribution is supported
BIOS Revision: 1.1
Firmware Revision: 1.1

# dmidecode -t1
# dmidecode 2.12
SMBIOS 2.5 present.

Handle 0x0002, DMI type 1, 27 bytes
System Information
Manufacturer: Dell Inc.
Product Name: Vostro 1520
Version: Null
Serial Number: 30Z90M1
UUID: 44454C4C-3000-105A-8039-B3C04F304D31
Wake-up Type: Power Switch
SKU Number: Null
Family: Vostro

An example:

VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVendor" "Dell Inc."
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVersion" "1.0.3"
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseDate" "06/20/2008"
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseMajor" 2
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseMinor" 1
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSFirmwareMajor" 2
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSFirmwareMinor" 1
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVendor" "Dell Inc."
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemProduct" "Vostro 410"
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVersion" "<EMPTY>"
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemSerial" "DJX9DH1"
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemFamily" "86-based PC"
VBoxManage setextradata WINXP2 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemUuid" "44454C4C-4A00-1058-8039-C4C04F444831"

<span style="text-decoration: underline;"><strong>I set mine as follow:</strong></span>

VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVendor" "Dell Inc."
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSVersion" "A08"
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseDate" "03/05/2010"
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseMajor" 1
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSReleaseMinor" 1
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSFirmwareMajor" 1
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiBIOSFirmwareMinor" 1
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVendor" "Dell Inc."
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemProduct" "Vostro 1520"
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemVersion" "<EMPTY>"
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemSerial" "30Z90M1"
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemFamily" "86-based PC"
VBoxManage setextradata win7 "VBoxInternal/Devices/pcbios/0/Config/DmiSystemUuid" "44454C4C-3000-105A-8039-B3C04F304D31"

Links:
https://forums.virtualbox.org/viewtopic.php?f=5&t=21471
https://www.virtualbox.org/ticket/9231

Virtualbox Guest Additions on Ubuntu 14.04

Just a few notes on getting the VirtualBox Guest Additions to work on Ubuntu 14.04 alpha1.

1. Unknown version of X
“Installing the Window System drivers
Warning: unknown version of the X Window System installed. Not installing
X Window System drivers.”

Explanation at the following links.  You need to use a newer version of the Guest Additions.
virtualbox and the latest 14.04… display stuck at low resolution
https://www.virtualbox.org/ticket/12623

2. Headers for the running kernel not installed.

http://askubuntu.com/questions/98416/error-kernel-headers-not-found-but-they-are-in-place

The message is misleading.  In my case it was actually missing dkms so before you install the addition run
sudo apt-get install build-essential linux-headers-`uname -r` dkms

Above helped with getting the Guest Additions running but still had some issue.  Looks like graphics resolution is ok but Unity not running.  I will investigate and update more.

SUN Oracle ZFS Storage Simulator

Previously I wrote an article on getting the ZFS simulator to run on OVM.

Until recently I did not realize that I could upgrade the ZFS simulator on Virtualbox.  I kind of assumed the appliance is checking in the background and showing possible upgrades in the Available Updates page.  None of my simulators or real ZFS appliances was showing new Available updates either.  So here is what I did to update the simulator.  I assume it will work with the OVM ported version also.

If you go to this page https://wikis.oracle.com/display/fishworks/Software+Updates you can see what updates are available for your hardware or simulator.   Then updating is easy.  Just download the zip file you need.  Read the Release Notes.  Then uncompress the file where you are staging.  In the Maintenance > System screen click the plus sign next to Available Updates.  Find the .gz file in the folder structure and upload the image.  Follow the questions.

My simulator running under Virtualbox now shows the below version.  Note that the simulator was too far behind to skip to the latest version so I had to do an extra 2011.04.24 version also.

Fedora 20 Alpha Virtualbox Guest Additions

Just a quick note on getting the guest additions to work on Fedora 20 Alpha. In my setup I was getting the below error when installing VBOXADDITIONS_4.2.18_88780.

...
Building the VirtualBox Guest Additions kernel modules
The headers for the current running kernel were not found. If the following
module compilation fails then this could be the reason.
The missing package can be probably installed with
yum install kernel-devel-3.11.3-301.fc20.i686+PAE

Building the main Guest Additions module [FAILED]
...

As you can see the suggestion above was wrong.  After installing the correct package I could install ok.

# yum install kernel-PAE-devel.i686

Virtualbox Guest Additions Linux

If you experience issues with installing the Virtualbox Guest Additions it could be that the build environment, dkms or kernel headers are not installed.

Messages typically look something like the following:

/tmp/vbox.0/Makefile.include.header:97: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR= and run Make again.  Stop

Install the following packages and retry the Guest Additions install:

# apt-get install build-essential dkms linux-headers-generic

Sun ZFS Storage Appliance Simulator on OVM or KVM

For those familiar with the excellent ZFS file system and the Sun(now Oracle) storage products built on ZFS, the ZFS storage appliance interface is very easy to use; and definitely worth considering when looking at when purchasing a SAN.

Oracle has a simulator virtual machine to try out the interface.  Unfortunately it only runs on Virtualbox which is fine for those running Virtualbox on a desktop.  If you would like to run it on something more accessible by multiple users(KVM or OVM); the Solaris based image has some issues running.

I recently got the Virtualbox image to run on OVM and subsequently also got it to work on KVM.  This is a quick guide how to get the Virtualbox image to run as a qcow2 image on a KVM hypervisor.
Update: Changed to qed format. If you don’t have qed, qcow2 worked for me also.

As I understand there was also a vmware image but it disappeared from the Oracle website.  I am not sure why Oracle does not publish at least OVM images or make an effort to run the simulator on OVM.  Maybe there is a good reason and it’s possible that Oracle want to discourage it being used other than on Virtualbox.  Really not sure.

Stage the Image:
Download the simulator (link should be on this page somewhere): http://www.oracle.com/us/products/servers-storage/storage/nas/zfs-appliance-software/overview/index.html

From the vbox-2011.1.0.0.1.1.8 folder copy the Sun ZFS Storage 7000-disk1.vmdk file to the KVM host and convert to qcow2.

** Note my first attempt I used qcow and not qcow2 format and had issues starting the image so make sure and convert to qcow2.

# qemu-img convert "Sun ZFS Storage 7000-disk1.vmdk" -O qed SunZFSStorage7000-d1.qed
# image: SunZFSStorage7000-d1.qed
file format: qed
virtual size: 20G (21474836480 bytes)
disk size: 1.9G
cluster_size: 65536

Create Guest:
Create KVM guest. Use ide disk for SunZFSStorage7000-disk1.qed and specify qed format.

# virsh dumpxml ZfsApp

  ZfsApp
...

</pre>
<address> </address>
<pre>
...

</pre>
<address> </address>
<pre>
...

Boot new Virtual Machine from the sol-11_1-text-x86.iso. Choose language etc. Select shell when menu appears.

Update ZFS Image:

Now import and mount the ZFS file system.  Find the correct device name and update bootenv.rc:

In my case the disk device name for the boot disk is c7d0.  I use format to see the disk device name and then find the correct slice for the root partition.  You can use “par” and “pr” commands in format to see partitions.  In my case we are after /dev/dsk/c7d0s0 and we need to find the correct entry in the /device tree.

# format
Searching for disks...done

AVAILABLE DISK SELECTIONS:
0. c7d0
/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0
Specify disk (enter its number): ^C

# ls -l /dev/dsk/c7d0s0
lrwxrwxrwx 1 root root 50 May 26 10:35 /dev/dsk/c7d0s0 -> ../../devices/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0:a

From above I found the exact device name: /devices/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0:a

Lets go update the bootenv.rc now.

# zpool import -f system

# zpool list
NAME SIZE ALLOC FREE CAP DEDUP HEALTH ALTROOT
system 19.9G 2.03G 17.8G 10% 1.00x ONLINE -

# zfs list | grep root
system/ak-nas-2011.04.24.1.0_1-1.8/root 1.26G 14.4G 1.25G legacy

# mkdir /a
# mount -F zfs system/ak-nas-2011.04.24.1.0_1-1.8/root /a

# zfs set readonly=off system/ak-nas-2011.04.24.1.0_1-1.8/root

# cp /etc/path_to_inst /a/etc
# vi /a/boot/solaris/bootenv.rc
...
setprop boot /devices/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0:a

# tail -1 /a/boot/solaris/bootenv.rc
setprop boot /devices/pci@0,0/pci-ide@1,1/ide@0/cmdk@0,0:a

# bootadm update-archive -R /a
updating /a/platform/i86pc/boot_archive
updating /a/platform/i86pc/amd64/boot_archive

# cd /
root@solaris:~/# umount /a
root@solaris:~/# zpool export system

# init 0

On next boot lets make sure Solaris detect the hardware correct.  When you see grub booting edit the kernel boot line and add “-arvs”.  Then continue booting.

Probably only need to add “-r” but I did “-arvs” to see more and also get into single user mode in case I needed to do more.

Once in single user mode with prompt just reboot.

For me at this point the image was booting into the zfs appliance setup and I could configure it.  Also on KVM adding SATA disks worked and the zfs appliance interface could use them for pools.

Update 04.23.14
I recently tried to update a simulator running on KVM but the update did not want to complete. Not sure if too many versions elapsed or something it does not like about being under KVM. Anyhow I tried moving an up to date (ak-2013.06.05.1.1) image on Virtualbox to KVM and that did work.

Import Virtualbox Image Into Oracle VM

C:\Program Files\Oracle\VirtualBox>VBoxManage.exe showhdinfo c:\DATA\VirtualBox_VMs\fc18\fc18.vdi
UUID:                 3909d478-3ba5-4de5-bda1-65e802451aa0
Accessible:           yes
Logical size:         8192 MBytes
Current size on disk: 6192 MBytes
Type:                 normal (base)
Storage format:       VDI
Format variant:       dynamic default
In use by VMs:        fc18 (UUID: 5cc6b364-e935-4d00-a10a-da6aa3e1592f)
Location:             C:\DATA\VirtualBox_VMs\fc18\fc18.vdi

C:\DATA\VirtualBox_VMs\fc18>"c:\Program Files\Oracle\VirtualBox\VBoxManage.exe" clonehd fc18.vmdk fc18.img --format raw

– Run Filezilla FTP server local. Setup an user and share folder.
– Import Virtual disk in OVMM ftp://anonymous:rr@/fc18/system.img
– Rename appropriately something like vmname_system.img
– Create VM and attach disk image(s).

Virtualbox additions on Redhat

I use Virtualbox for a lot of desktop related projects.  Although it is not really the first choice for server related virtualization projects, sometimes you might just need to proof or test something quickly.  Here is what I did to enable the guest additions on a Redhat server running as a Virtualbox guest.

Note since I did not want to waste an entitlement license on RHN I installed packages from the DVD.  Yum can do a group install for the Development tools which would be easier.

Install some compile tools:

[root@localhost Server]# rpm -i glibc-headers-2.5-105.x86_64.rpm libstdc++-devel-4.1.2-54.el5.x86_64.rpm gcc-4.1.2-54.el5.x86_64.rpm gcc-c++-4.1.2-54.el5.x86_64.rpm glibc-devel-2.5-105.x86_64.rpm

Install kernel headers:

[root@localhost Server]# rpm -i kernel-devel-2.6.18-339.el5.x86_64.rpm kernel-headers-2.6.18-339.el5.x86_64.rpm

Install guest additions:

[root@localhost VBOXADDITIONS_4.2.6_82870]# ./VBoxLinuxAdditions.run
Building the main Guest Additions module
...

That was it and I could use copy/paste, better screen resolution and share files from the local host.