Installing VirtualBox on Fedora 20 but kernel mismatch - linux-kernel

1) Hi i am trying to install virtualbox.
but something is wrong with my kernel, the commands below always mismatch.
[ ~]# uname -r
3.15.6-200.fc20.i686+PAE
[root#amidala ~]# rpm -qa | grep kernel
kernel-PAE-modules-extra-3.15.10-201.fc20.i686
abrt-addon-kerneloops-2.2.2-1.fc20.i686
kernel-headers-3.15.10-201.fc20.i686
kernel-modules-extra-3.15.6-200.fc20.i686
kernel-PAE-devel-3.15.10-201.fc20.i686
kernel-devel-3.15.10-201.fc20.i686
kernel-PAE-3.15.6-200.fc20.i686
kernel-3.15.10-201.fc20.i686
kernel-PAE-modules-extra-3.15.6-200.fc20.i686
kernel-modules-extra-3.15.10-201.fc20.i686
kernel-PAE-3.13.5-202.fc20.i686
kernel-PAE-modules-extra-3.13.5-202.fc20.i686
kernel-3.15.6-200.fc20.i686
kernel-PAE-3.15.10-201.fc20.i686
libreport-plugin-kerneloops-2.2.3-2.fc20.i686
2) so when i do command:
Trying to register the VirtualBox kernel modules using DKMSError! echo
Your kernel headers for kernel 3.15.6-200.fc20.i686+PAE cannot be found at
/lib/modules/3.15.6-200.fc20.i686+PAE/build or /lib/modules/3.15.6-200.fc20.i686+PAE/source.
[FAILED]
(Failed, trying without DKMS)
Recompiling VirtualBox kernel modules [FAILED]
3) so cause of 2) i created new ln -s to 3.15.10, doesnt work anyway so when I do:
/etc/init.d/vboxdrv setup
OUTPUT:
Stopping VirtualBox kernel modules [ OK ]
Uninstalling old VirtualBox DKMS kernel modules [ OK ]
Trying to register the VirtualBox kernel modules using DKMS[ OK ]
Starting VirtualBox kernel modules [FAILED]
and then:
vboxdrv: version magic '3.15.10-201.fc20.i686+PAE SMP mod_unload 686 ' should be '3.15.6-200.fc20.i686+PAE SMP mod_unload 686 '
5) any idea? also my kernel does not match the kernel-devel if you see the BOLD text.
6) yum update only updated my chrome.

The following worked.
617 cp /boot/grub2/grub.cfg /tmp/
618 grub2-mkconfig
619 grub2-mkconfig > /tmp/grub.cfg.new
627 cd /boot/
629 cd grub2/
631 mv grub.cfg grub.cfg.old
632 mv /tmp/grub.cfg.new grub.cfg
634 reboot

Related

yocto - User-Agent: falling back to 'libdnf': could not detect OS or basearch

I am using Yocto (Hardknott) to build an image and to create the package-feed(rpm packages). One of the image dependencies is u-boot-karo (it's a custom u-boot for karo modules) and it seems this recipe has some issue with the libdnf. Could anyone help me with this, below you will find more details about the error from the do_rootfs.log
NOTE: ###### Generate rootfs #######
NOTE: Executing '/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/recipe-sysroot-native/usr/bin/createrepo_c --update -q /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/oe-rootfs-repo' ...
NOTE: Running /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/etc/yum.repos.d --installroot=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs --setopt=logdir=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/temp --repofrompath=oe-repo,/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/oe-rootfs-repo makecache --refresh
DEBUG: DNF version: 4.6.0
cachedir: /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/var/cache/dnf
Added oe-repo repo from /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/oe-rootfs-repo
Making cache files for all metadata files.
oe-repo: has expired and will be refreshed.
repo: downloading from remote: oe-repo
oe-repo 343 MB/s | 1.2 MB 00:00
oe-repo: using metadata from Thu 14 Apr 2022 12:20:13 PM UTC.
Last metadata expiration check: 0:00:01 ago on Thu 14 Apr 2022 12:20:13 PM UTC.
User-Agent: falling back to 'libdnf': could not detect OS or basearch
Metadata cache created.
NOTE: Running /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/etc/yum.repos.d --installroot=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs --setopt=logdir=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/temp --repofrompath=oe-repo,/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/oe-rootfs-repo --nogpgcheck install alsa-utils-alsamixer alsa-utils-amixer alsa-utils-aplay amr-ipconfig avahi-daemon avahi-utils avahiservice bash canutils coreutils dhcpcd dosfstools e2fsprogs e2fsprogs-resize2fs file gdbserver i2c-tools initscript kernel-modules kmod ldd less libgpiod libgpiod-tools libstdc++ lsof mmc-utils ncurses nfs-utils nginx ntp ntpdate packagegroup-base-extended packagegroup-core-boot packagegroup-core-ssh-openssh parted psplash rauc rsync run-postinsts ssh-keys strace sudo systemd tcp-wrappers tzdata u-boot-karo ufw util-linux util-linux-fsck util-linux-mkfs util-linux-mount util-linux-setterm locale-base-de-de
ERROR: Could not invoke dnf. Command '/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/etc/yum.repos.d --installroot=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs --setopt=logdir=/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/temp --repofrompath=oe-repo,/amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/oe-rootfs-repo --nogpgcheck install alsa-utils-alsamixer alsa-utils-amixer alsa-utils-aplay amr-ipconfig avahi-daemon avahi-utils avahiservice bash canutils coreutils dhcpcd dosfstools e2fsprogs e2fsprogs-resize2fs file gdbserver i2c-tools initscript kernel-modules kmod ldd less libgpiod libgpiod-tools libstdc++ lsof mmc-utils ncurses nfs-utils nginx ntp ntpdate packagegroup-base-extended packagegroup-core-boot packagegroup-core-ssh-openssh parted psplash rauc rsync run-postinsts ssh-keys strace sudo systemd tcp-wrappers tzdata u-boot-karo ufw util-linux util-linux-fsck util-linux-mkfs util-linux-mount util-linux-setterm locale-base-de-de' returned 1:
DNF version: 4.6.0
cachedir: /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/rootfs/var/cache/dnf
Added oe-repo repo from /amr-bsp/build/tmp/work/amr1-poky-linux-gnueabi/amr-image-dev/1.0-r0/oe-rootfs-repo
User-Agent: falling back to 'libdnf': could not detect OS or basearch
repo: using cache for: oe-repo
oe-repo: using metadata from Thu 14 Apr 2022 12:20:13 PM UTC.
Last metadata expiration check: 0:00:01 ago on Thu 14 Apr 2022 12:20:13 PM UTC.
No match for argument: u-boot-karo
Error: Unable to find a match: u-boot-karo

grub2-mkconfig is taking fedora path instead of centos while installing centos7 via kickstart file and in UEFI mode

I am trying to install centos7 ISO using kickstart and ISO installation is working fine but during post installation setup procedure getting error when installing Bootloader.
BootLoaderError: failed to write boot loader configuration
Log shows,
efibootmgr -c -w -L CentOS 7 -d /dev/sda -p 1 -l \EFI\fedora\shimx64.efi
..
..
.
.
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
/sbin/grub2-mkconfig : line 244: /boot/efi/EFI/fedora/grub.cfg.new: No such file or directory
Any pointers why it is taking fedora inside the efibootmgr path and grub-mkconfig path. It should take centos instead of fedora.
I already checked that there is directory of centos at path /boot/efi/EFI/centos/
Thanks in advance.

Iptables v1.6.1 can't initialize iptables table `filter' Ubuntu 18.04 Bash Windows

I'm running Ubuntu 18.04 from Windows Bash:
uname -a
Linux DESKTOP-M87DGAS 4.4.0-17134-Microsoft #112-Microsoft Thu Jun 07 22:57:00 PST 2018 x86_64 x86_64 x86_64 GNU/Linux
I need to open some port with:
sudo ufw allow 22/tcp
But I get the following error:
ERROR: initcaps
[Errno 2] iptables v1.6.1: can't initialize iptables table `filter': Table
does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
I get the same error by typing:
iptables -L
I've already upgrade my kernel with:
sudo apt-get update
sudo apt-get full-upgrade
I've tried to reboot the system but it didn't work.
How can I initiate the iptable filter?
According to the Microsoft WSL page on github.com, iptables isn't supported.
https://github.com/Microsoft/WSL/issues/767
There is a uservoice page for requesting support at
https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/32025199-support-iptables
Windows restrict that command in WSL without authorization from administrator.
You just have to run WSL on CMD/Powershell/Ubuntu.exe as administator, then try this command again:
sudo iptables -L -v
I tested on WSL v1, but it should also work on WSL v2.

VirtualBox: mount.vboxsf: mounting failed with the error: No such device [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I'm using VirtualBox with OS X as host and CentOS on the guest VM.
In OS X I created folder myfolder, added it as shared folder to the VM, turned on the VM, in CentOS created folder /home/user/myfolder and typing:
sudo mount -t vboxsf myfolder /home/user/myfolder
and have output:
/sbin/mount.vboxsf: mounting failed with the error: No such device
What I'm doing wrong?
UPDATED:
Guest Additions installed.
My shared folder/clipboard stopped to work for some reason (probably due to a patch installation on my virtual machine).
sudo mount -t vboxsf Shared_Folder ~/SF/
Gave following result:
VirtualBox: mount.vboxsf: mounting failed with the error: No such device
The solution for me was to stop vboxadd and do a setup after that:
cd /opt/VBoxGuestAdditions-*/init
sudo ./vboxadd setup
You're using share folders, so you need to install VirtualBox Guest Additions inside your virtual machine to support that feature.
Vagrant
If you're using Vagrant (OS X: brew cask install vagrant), run:
vagrant plugin install vagrant-vbguest
vagrant vbguest
In case it fails, check the logs, e.g.
vagrant ssh -c "cat /var/log/vboxadd-install.log"
Maybe you're just missing the kernel header files.
VM
Inside VM, you should install Guest Additions, kernel headers and start the service and double check if kernel extension is running.
This depends on the guest operating system, so here are brief steps:
Install kernel include headers (required by VBoxLinuxAdditions).
RHEL: sudo apt-get update && sudo apt-get install kernel-devel
CentOS: sudo yum update && sudo yum -y install kernel-headers kernel-devel
Install Guest Additions (this depends on the operating system).
Ubuntu: sudo apt-get -y install dkms build-essential linux-headers-$(uname -r) virtualbox-guest-additions-iso
If you can't find it, check by aptitude search virtualbox.
Debian: sudo apt-get -y install build-essential module-assistant virtualbox-ose-guest-utils
If you can't find it, check by dpkg -l | grep virtualbox.
manually by downloading the iso file inside VM (e.g. wget) and installing it, e.g.
wget http://download.virtualbox.org/virtualbox/5.0.16/VBoxGuestAdditions_5.0.16.iso -P /tmp
sudo mount -o loop /tmp/VBoxGuestAdditions_5.0.16.iso /mnt
sudo sh -x /mnt/VBoxLinuxAdditions.run # --keep
Extra debug: cd ~/install && sh -x ./install.sh /mnt/VBoxLinuxAdditions.run
Double check that kernel extensions are up and running:
sudo modprobe vboxsf
Start/restart the service:
manually: sudo /opt/VBoxGuestAdditions*/init/vboxadd setup (add sudo sh -x to debug)
Debian: sudo /etc/init.d/vboxadd-service start
Fedora: sudo /etc/init.d/vboxdrv setup
CentOS: sudo service VBoxService start
Building the main Guest Additions module
If above didn't work, here are more sophisticated steps to fix it. This assumes that you've already VBoxGuestAdditions installed (as shown above).
The most common reason why mounting shared folder doesn't work may related to building Guest Additions module which failed. If in /var/log/vboxadd-install.log you've the following error:
The headers for the current running kernel were not found.
this means either you didn't install kernel sources, or they cannot be found.
If you installed them already as instructed above, run this command:
$ sudo sh -x /opt/VBoxGuestAdditions-5.0.16/init/vboxadd setup 2>&1 | grep KERN
+ KERN_VER=2.6.32-573.18.1.el6.x86_64
+ KERN_DIR=/lib/modules/2.6.32-573.18.1.el6.x86_64/build
So basically vboxadd script is expecting your kernel sources to be available at the following dir:
ls -la /lib/modules/$(uname -r)/build
Check if the kernel dir exists (symbolic link points to the existing folder). If it's not, please install them to the right folder (e.g. in /usr/src/kernels).
So vboxadd script can enter your kernel source directory and run make kernelrelease, get the value and compare with your current kernel version.
Here is the logic:
KERN_VER=`uname -r`
KERN_DIR="/lib/modules/$KERN_VER/build"
if [ -d "$KERN_DIR" ]; then
KERN_REL=`make -sC $KERN_DIR --no-print-directory kernelrelease 2>/dev/null || true`
if [ -z "$KERN_REL" -o "x$KERN_REL" = "x$KERN_VER" ]; then
return 0
fi
fi
If the kernel version doesn't match with the sources, maybe you've to upgrade your Linux kernel (in case the sources are newer than your kernel).
CentOS
Try:
vagrant plugin install vagrant-vbguest vagrant vbgues
If won't work, try the following manual steps for CentOS:
$ sudo yum update
$ sudo yum install kernel-$(uname -r) kernel-devel kernel-headers # or: reinstall
$ rpm -qf /lib/modules/$(uname -r)/build
kernel-2.6.32-573.18.1.el6.x86_64
$ ls -la /lib/modules/$(uname -r)/build
$ sudo reboot # and re-login
$ sudo ln -sv /usr/src/kernels/$(uname -r) /lib/modules/$(uname -r)/build
$ sudo /opt/VBoxGuestAdditions-*/init/vboxadd setup
I am able to resolved this by running below commmand
modprobe -a vboxguest vboxsf vboxvideo
In addition to #Mats answer, I'm adding some more info (it helped me on Debian 8).
My shared folder/clipboard stopped to work for some reason (probably due to a patch installation on my virtual machine).
sudo mount -t vboxsf Shared_Folder ~/SF/
Gave me following result:
VirtualBox: mount.vboxsf: mounting failed with the error: No such device
The solution for me was to stop vboxadd and do a setup after that:
cd /opt/VBoxGuestAdditions-*/init
sudo ./vboxadd setup
At this point, if you still get the following error:
No such device. The Guest Additions installation may have failed. The error has been logged in /var/log/vboxadd-install.log
You need to install linux headers:
apt-get install linux-headers-$(uname -r)
then you can install Guest Additions:
sh /media/cdrom/VBoxLinuxAdditions.run --nox11
and restart your Linux by:
reboot
then you will be able to mount your shared folder!
mount -t vboxsf Shared_Folder ~/SF/
More informations (in French), check this page.
This was the only solution what worked for me:
Install Vagrant plugin: vagrant-vbguest, which can keep your VirtualBox Guest Additions up to date.
vagrant plugin install vagrant-vbguest
Source: https://github.com/aidanns/vagrant-reload/issues/4#issuecomment-230134083
This was resolved by:
yum install gcc kernel-devel make
workaround is here: https://gist.github.com/larsar/1687725
Shared folder was earlier working for me but all f sudden it stopped working (Virualbox - host was Windows 7, Guest was OpenSuSe)
modprobe -a vboxguest vboxsf vboxvideo
then
mount -t vboxsf testsf /opt/tsf (testsf was the folder in Windows C drive which was added in Virtualbox shared folder --- and /opt/tsf is the folder in OpenSuse
My host is Windows10 my VM guest is ubuntu build by vagrant. This worked for me:
vagrant plugin install vagrant-winnfsd
The solution for me was to update guest additions
(click Devices -> Insert Guest Additions CD image)
I also had a working system that suddenly stopped working with the described error.
After furtling around in my /lib/modules it would appear that the vboxvfs module is no more. Instead modprobe vboxsf was the required incantation to get things restarted.
Not sure when that change ocurred, but it caught me out.
I am running VirtualBox 5.1.20, and had a similar issue. Here is a url to where I found the fix, and the fix I implemented:
# https://dsin.wordpress.com/2016/08/17/ubuntu-wrong-fs-type-bad-option-bad-superblock/
if [ "5.1.20" == "${VBOXVER}" ]; then
rm /sbin/mount.vboxsf
ln -s /usr/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf
fi
The link had something similar to /usr/lib/VBoxGuestAdditions/other/mount.vboxsf, rather than what I have in the script excerpt.
For a build script I use in vagrant for the additions:
https://github.com/rburkholder/vagrant/blob/master/scripts/additions.sh
Seems to be a fix at https://www.virtualbox.org/ticket/16670
For me, on a mac, it turned out I had an old VirtualBox image stored on my machine that didn't have metadata, so it wasn't being updated to the latest version.
That old image had an older version of the vbguest plugin installed in it, which the newer vbguest plugin on my machine couldn't work with.
So to fix it, I just removed the image that my Vagrant was based on, and then Vagrant downloaded the newer version and it worked fine.
# Remove an old version of the virtual box image that my vagrant was using
$ vagrant box remove centos/7
You can find out which boxes you have cached on your machine by running:
$ vagrant box list
I had also upgraded my vbguest plugin in my earlier attempts at getting this to work, using the following process, but I don't think this helped. FYI !
# Get rid of old plugins
vagrant plugin expunge
# Globally install the latest version of the vbguest plugin`
vagrant plugin install vagrant-vbguest
If you find bring the box fails on guest addtions, you can try doing the following to ensure the plugins install correctly. This downloads the latest based image for your system (for me CentOS), and may resolve the issue (it did for me!)
$ vagrant box update
There can be errors/incorrect approach in two scenarios. Check both of it and figure it out
SCENARIO 1 :
Once you are running the VBoxLinuxAdditions.run or VBoxSolarisAdditions.pkg or VBoxWindowsAdditions.exe , check if all the modules are getting installed properly.
1.1.a. In case of VBoxLinuxAdditions, if Building the VirtualBox Guest Additions kernel modules gets failed,
check the log file in /var/log/vboxadd-install.log . If the error is due to kernel version update your kernel and reboot the vm. In case of fedora,
1.1.b. yum update kernel*
1.1.c. reboot
1.2. If nothing gets failed, then all is fine. You are already having the expected kernel version
SCENARIO 2 :
If the VBoxGuestAdditions is installed (check for a folder /opt/VBoxGuestAdditions-* is present .... * represents version) you need to start it before mounting.
2.1. cd /opt/VBoxGuestAdditions-*/init && ./vboxadd start
You need to specify the user id and group id of your vm user as options to the mount command.
2.2.a. Getting uid and gid of a user:
id -u <'user'>
id -g <'user'>
2.2.b. Setting uid and gid in options of mount command:
mount -t vboxsf -o uid=x,gid=x shared_folder_name guest_folder
On Ubuntu this worked:
sudo apt-get install build-essential linux-headers-`uname -r` dkms
Had the same issue with VirtualBox 5.0.16/rXXX
Installed latest VirtualBox 5.0.18 and installed latest Vagrant 1.9.3, issue went toodles.
I added as root user
/etc/rc.d/rc.local
/root/mount-vboxsf.sh
then
chmod +x /etc/rc.d/rc.local
and the sample script /root/mount-vboxsf.sh (set your own the uid and gid options)
modprobe -a vboxguest vboxsf vboxvideo
mount -t vboxsf NAME_SHARED_DIRECTORY /media/sf_NAME_SHARED_DIRECTORY -o rw,uid=0,gid=0
you need add
chmod + /root/mount-vboxsf.sh
I have similar issue, check header if it's not match then run below command
CentOS: sudo yum update && sudo yum -y install kernel-headers kernel-devel
If you're on Debian:
1) remove all installed package through Virtualbox Guest Additions ISO file:
sh /media/cdrom/VBoxLinuxAdditions.run uninstall
2) install Virtualbox packages:
apt-get install build-essential module-assistant virtualbox-guest-dkms virtualbox-guest-utils
Note that even with modprobe vboxsf returning nothing (so the module is correctly loaded), the vboxsf.so will call an executable named mount.vboxsf, which is provided by virtualbox-guest-utils. Ignoring this one will prevent you from understanding the real cause of the error.
strace mount /your-directory was a great help (No such file or directory on /sbin/mount.vboxsf).
An update did the trick for me !
$ vagrant box update
$ vagrant plugin install vagrant-vbguest
Below two commands works for me.
vagrant ssh
sudo mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant
Okay everyone is missing a basic fact.
mkdir /test - Makes sub directory in current directory.
sudo mkdir /test - Make directory in Root.
So if your shared directory name is shared and you do the following:
mkdir /test
sudo mount -t vboxsf shared /test
It generates this error:
sbin/mount.vboxsf: mounting failed with the error: No such file or directory
Because the directory is in the wrong place! Yes that's what this error is saying. The error is not saying reload the VBOX guest options.
But if you do this:
sudo mkdir ~/test
sudo mount -t vboxsf shared ~/test
Then it works fine.
It really amazes me how many people suggest reloading the Vbox guest additions to solve this error or writing a complex program to solve a directory created in the wrong place.

VBoxLinuxAdditions.run never exits with 0

I am trying to automate the installation of Virtualbox guest additions using Chef, however I am running into an issue where VBoxLinuxAdditions.run never exists with exit code 0. I always get exit code 1, even without any errors being reported in scripts printout.
It seems that they are getting installed, so I do not understand why this script always returns 1.
I am working on a Windows 8.1 host, Virtualbox 4.3.12 with Debian 6 guest os.
I am trying to accomplish this by running the following recipe using kitchen:
include_recipe "apt"
%W[make gcc xserver-xorg xserver-xorg-core linux-headers-#{node['kernel']['release']} dkms].each do |p|
package p do
action :install
end
end
# get additions iso file
remote_file "#{Chef::Config[:file_cache_path]}/vboxAdditions.iso" do
source "http://download.virtualbox.org/virtualbox/#{node['virtualbox']['version']}/VBoxGuestAdditions_#{node['virtualbox']['version']}.iso"
end
# create the mount point
directory "/mnt/vboxAdditions" do
owner "root"
group "root"
mode "0755"
action :create
end
# mount the iso
mount "/mnt/vboxAdditions" do
action :mount
device "#{Chef::Config[:file_cache_path]}/vboxAdditions.iso"
fstype "iso9660"
options "loop"
end
# run the installer script
execute "install vbox guest additions" do
command "sh /mnt/vboxAdditions/VBoxLinuxAdditions.run"
end
My .kitchen.yml file:
---
driver_plugin: vagrant
platforms:
- name: debian-6
driver_config:
box: opscode-debian-6.0.7
box_url: http://opscode-vm.s3.amazonaws.com/vagrant/opscode_debian-6.0.7_chef-11.2.0.box
require_chef_omnibus: 11.4.0
suites:
- name: guest_additions
run_list: ["recipe[virtualbox::guest_additions]"]
attributes: {
"virtualbox": {
"version": "4.3.12"
}
}
Below is the output I receive:
================================================================================
Error executing action `run` on resource 'execute[install vbox guest additions]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
STDOUT: Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.12 Guest Additions for Linux............
STDERR: VirtualBox Guest Additions installer
Removing installed version 4.2.6 of VirtualBox Guest Additions...
Copying additional installer modules ...
add_symlink: link file /usr/lib/VBoxGuestAdditions already exists
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers
Installing X.Org Server 1.7 modules ...done.
Setting up the Window System to use the Guest Additions ...done.
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.
Installing graphics libraries and desktop services components ...done.
---- End output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
Ran sh /mnt/vboxAdditions/VBoxLinuxAdditions.run returned 1
Resource Declaration:
---------------------
# In /tmp/kitchen/cookbooks/virtualbox/recipes/guest_additions.rb
70: execute "install vbox guest additions" do
71: command "sh /mnt/vboxAdditions/VBoxLinuxAdditions.run"
72: end
73:
Compiled Resource:
------------------
# Declared in /tmp/kitchen/cookbooks/virtualbox/recipes/guest_additions.rb:70:in `from_file'
execute("install vbox guest additions") do
action "run"
retries 0
retry_delay 2
command "sh /mnt/vboxAdditions/VBoxLinuxAdditions.run"
backup 5
returns 0
cookbook_name :virtualbox
recipe_name "guest_additions"
end
[2014-08-21T19:34:55+00:00] INFO: Running queued delayed notifications before re-raising exception
[2014-08-21T19:34:55+00:00] ERROR: Running exception handlers
[2014-08-21T19:34:55+00:00] ERROR: Exception handlers complete
Chef Client failed. 14 resources updated
[2014-08-21T19:34:55+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
[2014-08-21T19:34:55+00:00] FATAL: Mixlib::ShellOut::ShellCommandFailed: execute[install vbox guest additions] (virtualbox::guest_additions line 70) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
STDOUT: Verifying archive integrity... All good.
Uncompressing VirtualBox 4.3.12 Guest Additions for Linux............
STDERR: VirtualBox Guest Additions installer
Removing installed version 4.2.6 of VirtualBox Guest Additions...
Copying additional installer modules ...
add_symlink: link file /usr/lib/VBoxGuestAdditions already exists
Installing additional modules ...
Removing existing VirtualBox DKMS kernel modules ...done.
Removing existing VirtualBox non-DKMS kernel modules ...done.
Building the VirtualBox Guest Additions kernel modules ...done.
Doing non-kernel setup of the Guest Additions ...done.
Starting the VirtualBox Guest Additions ...done.
Installing the Window System drivers
Installing X.Org Server 1.7 modules ...done.
Setting up the Window System to use the Guest Additions ...done.
You may need to restart the hal service and the Window System (or just restart
the guest system) to enable the Guest Additions.
Installing graphics libraries and desktop services components ...done.
---- End output of sh /mnt/vboxAdditions/VBoxLinuxAdditions.run ----
Ran sh /mnt/vboxAdditions/VBoxLinuxAdditions.run returned 1
>>>>>> Converge failed on instance <guest-additions-debian-6>.
>>>>>> Please see .kitchen/logs/guest-additions-debian-6.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sudo -E chef-solo --config /tmp/kitchen/solo.rb --json-attributes /tmp/kitchen/dna.json --log_level info]
>>>>>> ----------------------
bash.exe"-3.1$
I am running 4.3.16 on Linux, and ran into the same problem. My installation is also embedded in an automated process.
You can unpack the archive to inspect the files with
./VBoxLinuxAdditions.run --target foo --noexec
The offending and useless piece of code that is causing the problem is in the install.sh starts here:
test ! -d "$INSTALLATION_DIR" && REMOVE_INSTALLATION_DIR=1
(REMOVE_INSTALLATION_DIR never gets set to 1 despite whether or not $INSTALLATION_DIR exists).
The bug, at the end of the file, is this:
test -n "$REMOVE_INSTALLATION_DIR" &&
echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG_FILES"
Since $REMOVE_INSTALLATION_DIR never gets set, test -n returns 1 (fail), and instead of providing an exit 0 at the end of the install script like the author should have, it falls off the end and gives that last exit code to the shell.
Successful workaround:
# REMOVE_INSTALLATION_DIR=0 ./VBoxLinuxAdditions.run
# echo $?
0
A followup to Victor Roetman's method, which avoids some pathing issues:
if ! modinfo vboxsf >/dev/null 2>&1; then
echo "Cannot find vbox kernel module. Installation of guest additions unsuccessful!"
exit 1
fi
I can confirm that the problem still exists in the install.sh script for version 5.0.4 - and that Derek's workaround is still good. I've included the relevant snippets in the code sample below:
27 PACKAGE="VBoxGuestAdditions"
...
32 INSTALLATION_VER="5.0.4"
33 INSTALLATION_REV="102546"
...
38 INSTALLATION_DIR="/opt/$PACKAGE-$INSTALLATION_VER"
...
324 INSTALLATION_MODULES_DIR="$INSTALLATION_DIR/installer/"
...
329 mkdir -p -m 755 "$INSTALLATION_MODULES_DIR"
...
343 test ! -d "$INSTALLATION_DIR" && REMOVE_INSTALLATION_DIR=1
344 mkdir -p -m 755 "$INSTALLATION_DIR"
...
531 test -n "$REMOVE_INSTALLATION_DIR" &&
532 echo "$INSTALLATION_DIR/" >> "$CONFIG_DIR/$CONFIG/FILES"
REMOVE_INSTALLATION_DIR will never be set to 1 on line 343 because INSTALLATION_DIR is created (as a parent directory) for the INSTALLATION_MODULES_DIR on line 329.
Even with VirtualBox 5.0 guest additions, I find the return code of VBoxLinuxAdditions.run to be completely unreliable. For example, if I remove gcc from the box, and run with
REMOVE_INSTALLATION_DIR=0 ./VBoxLinuxAdditions.run
as stated in another answer, it will fail to build but still give a return code of 0.
My solution is to check if the kernel modules were built. So I run it like this:
/location/of/VBoxLinuxAdditions.run || true
if ! test -f /lib/modules/$(uname -r)/extra/vboxsf.ko
then
echo "installation of guest additions unsuccessful"
exit 1
fi
I tried Derek's solution and it did not worked. I am scripting the creation of VMs using vagrant's packer. What I did was the following:
echo "sudo /path/to/installer/VBoxLinuxAdditions.run" > /tmp/install_va.sh
/bin/bash /tmp/install_va.sh
sudo /usr/sbin/VBoxService --version
This way, the spurious error result (which in my case was making Vagrant's packer to destroy the VM) will happen in the subprocess and not catched in the current process. The last operation's result will be the result of the script. If the last check errored, something went wrong in the installation.

Resources