[Solved] Missing Guest Additions after silent installation

This is for discussing general topics about how to use VirtualBox.
Post Reply
treimers
Posts: 5
Joined: 4. May 2020, 10:39

[Solved] Missing Guest Additions after silent installation

Post by treimers »

Hello,

I am using Virtual Box to setup a Centos7 vm on my Mac OS X. This worked seemless in the past but suddenly I am running into problems. Don't know why.

I did create a script to automate the whole process. The script does mainly a VBoxManage unattended installation of Centos based on a minimal ISO installer.

Code: Select all

VBoxManage unattended install centos7 --user=datasqill --password=pwd --country=DE --locale=de_DE --time-zone=UTC --hostname=centos7.treimers --iso=/Users/treimers/Projekte/Linux/CentOS-7-x86_64-Minimal-1908.iso --post-install-template redhat_postinstall.sh --script-template redhat67_ks.cfg --install-additions --start-vm=gui
I used to call

Code: Select all

VBoxManage guestproperty wait centos7 /VirtualBox/GuestInfo/OS/NoLoggedInUsers
in order to wait for the installation process to finish. The wait does not terminate and seems to wait forever. I think that this reason is that the guest additions are not installed.

Find attached my script and the resource files redhat67_ks.cfg and redhat_postinstall.sh that I am using. My environment is

OS: Mac OS X 10.11.6 (El Capitan)
Virtual Box: 6.1.6 r137129
CentOS Image: CentOS-7-x86_64-Minimal-1908.iso

Maybe somebody has an idea what might be wrong with my set up.

Thanks in advance
Thorsten
Attachments
createVM.zip
(12.54 KiB) Downloaded 35 times
Last edited by treimers on 7. May 2020, 22:30, edited 1 time in total.
treimers
Posts: 5
Joined: 4. May 2020, 10:39

Re: Missing Guest Additions after silent installation

Post by treimers »

Hi,

I finally solved my problem. RTFL = Read the f.. log.

The system was unable to find and install the package for kernel devel using

Code: Select all

log_command_in_target yum -y install "kernel-devel-$(uname -r)"
This is required in order to install the Virtual Box guest additions.

My guest system was CentOS 7 but I used the minimal ISO for installing (CentOS-7-x86_64-Minimal-1908.iso) and that did not contain the kernel devel package. I switched to the full ISO image (CentOS-7-x86_64-DVD-1908.iso) and violá suddenly it worked without any problems.
Last edited by treimers on 27. May 2020, 13:11, edited 1 time in total.
scottgus1
Site Moderator
Posts: 20945
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: [Solved] Missing Guest Additions after silent installation

Post by scottgus1 »

Thanks, treimers, for your info & fix!
treimers
Posts: 5
Joined: 4. May 2020, 10:39

Re: [Solved] Missing Guest Additions after silent installation

Post by treimers »

As my set up worked in the past and did not work suddenly I took a closer look to the problem again.

I found that yum is unable to install the kernel devel package from disk and from internet.

One solution is to switch to the DVD image that does contain the required package.

But in my environment it worked with the minimal image in the past. Thus yum was able to install the package from internet. This was broken suddenly and I came to the conclusion that something must have been changed in the CentOS repositories. I then tried the current version which is CentOS-7-x86_64-Minimal-2003.iso and voilá this worked!

So I searched around how to convince yum to install packages for an older version and found the file

Code: Select all

/etc/yum.repos.d/CentOS-Vault.repo
There was no entry in the installed version of this file for my release, but I created a new one and that helped.

I modified the file

Code: Select all

redhat_postinstall.sh
and added code to create a correct version of this file that corresponds to the CentOS release used (lines with leading +):
echo "--------------------------------------------------" >> "${MY_LOGFILE}"
echo '** Installing packages for building kernel modules...' | tee -a "${MY_LOGFILE}"

+ # set vault repo for our CentOS release
+ log_command_in_target mv etc/yum.repos.d/CentOS-Vault.repo /root
+ export redhat_version=`cut -d" " -f4 < /etc/redhat-release`
+ log_command_in_target ex -sc "a|# C${redhat_version}" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ for n in Base Updates Extras CentOSPlus Fasttrack
+ do
+ low=${n,,}
+ if [ ${low} = "base" ]
+ then
+ path=os
+ else
+ path=${low}
+ fi
+ log_command_in_target ex -sc "a|[C${redhat_version}-${low}]" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ log_command_in_target ex -sc "a|name=CentOS-${redhat_version} - ${n}" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ log_command_in_target ex -sc "a|baseurl=http://vault.centos.org/${redhat_versio ... $basearch/" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ log_command_in_target ex -sc "a|gpgcheck=1" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ log_command_in_target ex -sc "a|gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ log_command_in_target ex -sc "a|enabled=1" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ log_command_in_target ex -sc "a|" -cx /etc/yum.repos.d/CentOS-Vault.repo
+ done

log_command_in_target yum -y install "kernel-devel-$(uname -r)"
log_command_in_target yum -y install "kernel-headers-$(uname -r)"
log_command_in_target yum -y install gcc
log_command_in_target yum -y install binutils
log_command_in_target yum -y install make
log_command_in_target yum -y install dkms
log_command_in_target yum -y install make
log_command_in_target yum -y install bzip2
log_command_in_target yum -y install perl

+ # remove vault repo
+ log_command_in_target mv etc/yum.repos.d/CentOS-Vault.repo /root/CentOS-Vault.repo.new
+ log_command_in_target mv /root/CentOS-Vault.repo etc/yum.repos.d
With that enhancement I was able to install the version CentOS-7-x86_64-Minimal-1908.iso without any problems.

Maybe Virtual Box team would like to add it to future versions?!
Post Reply