2

I am trying to write a shell script to build a custom kernel on Arch Linux.

I have succeeded to do write all the steps described in the Arch Linux kernel compilation page: https://wiki.archlinux.org/index.php/Kernels/Compilation/Traditional

But I am stuck on the last step to "Recompile VirtualBox guest module":

We need to do one more thing before we reboot to our new kernel. We have to recompile the VirtualBox guest module so that things like screen resizing will still work when we reboot to the new kernel.

First, make sure you have the virtualbox-guest-dkms package installed:

sudo pacman -S virtualbox-guest-dkms
If you have it installed already, pacman will ask you if you want to reinstall. Say no, but note the version number of the module.

Recompile the VirtualBox guest module by running:

sudo dkms remove  vboxguest/version-number -k kernel-version
sudo dkms install vboxguest/version-number -k kernel-version

Substitute your vboxguest version number and your kernel version string.

If I run sudo pacman -S virtualbox-guest-dkms in the terminal, I would get following output:

warning: virtualbox-guest-dkms-4.3.26-2 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) virtualbox-guest-dkms-4.3.26-2

Total Installed Size:  5.26 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n]

If I choose to install it, it will tell me to proceed installation by running the command -- dkms install vboxguest/version-number

Since I want to make the shell script as robust as possible, I would need to do the following:

  1. If the guest module has already been installed, just grap the version-number from the pacman query and exit.

Then I just need to run the following two commands:

sudo dkms remove  vboxguest/version-number -k kernel-version
sudo dkms install vboxguest/version-number -k kernel-version
  1. If guest module is not installed, do installation and grap the dkms install vboxguest/version-number command from the pacman query and exit.

Run sudo dkms install vboxguest/version-number.

The rest is the same as the scenario one above.

The first scenario is the most likely one.

Could someone please give me a hand on this?

Thanks in advance!

  • I would use expac to query the current required version: expac -S '%v' virtualbox-guest-dkms and compare to what you have installed: expac -Q '%v' virtualbox-guest-dkms; if those numbers are not the same, run pacman... Having said that, you are better off just putting a depends in the PKGBUILD and letting makepkg work it out. – jasonwryan Mar 29 '15 at 6:42
  • Sorry, I am a newbie to linux system, could you please elaborate on PKGBUILD a bit more? Thanks @jasonwryan – Jialun Liu Mar 29 '15 at 13:47
  • See the Arch Wiki entry. – jasonwryan Mar 29 '15 at 16:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.