Converting a Bionic install to Kali on the Lenovo C630

May 30, 2020

Since I’m a Kali developer for my day job, I like to “dogfood” and run Kali on most of my machines. Recently, since the majority of the support is in a 5.7-ish kernel, I went ahead and installed Bionic to a partition on the internal storage, and then went about “upgrading” it to run Kali instead of the Bionic install. This will be a bit of a walkthrough to show how I did it, and can be used as a general guide for converting an Ubuntu install to Kali, without reinstalling.

First thing I did was follow the steps listed at https://github.com/aarch64-laptops/build under Use an enabled installer - I personally did minimal install because I knew I’d be converting to a Kali installation afterwards.

After first booting into Ubuntu, I went ahead and disabled natural scrolling and turned on tap to click in the settings, and connecting to my wifi network using an external device, as the 5.2 kernel does not support the built-in wifi card. An ethernet connection would work as well if you have one on a usb-c hub, but my hub recently died so…

Then I purged both snapd and unattended-upgrades - I did NOT autoremove anything, as I don’t want to do that til near the end of converting to Kali. We remove snapd because Kali doesn’t use snapd, and unattended-upgrades because… I don’t like apt running things in the background behind my back.

sudo apt purge snapd unattended-upgrades

Now we download the Kali archive keyring, so that we can install packages from the Kali distro.

wget https://kali.download/kali/pool/main/k/kali-archive-keyring/kali-archive-keyring_2020.2_all.deb
sudo dpkg -i ./kali-archive-keyring_2020.2_all.deb

Now we edit the /etc/sources.list so that we point to the Kali repos.

deb https://http.kali.org/kali kali-rolling main contrib non-free

Because of the grub packages having some changes, we’ll go ahead and apt-mark hold the grub packages.

sudo apt-mark hold grub2-common
sudo apt-mark hold grub-efi-arm64-bin
sudo apt-mark hold grub-efi-arm64
sudo apt-mark hold grub-common

Also, because we’re going to be regenerating the initramfs a few times as part of this process, let’s put the dtb file where flash-kernel can find it…

sudo mkdir -p /etc/flash-kernel/dtbs/qcom
sudo cp /boot/dtbs/5.2.0-99-generic/laptop-lenovo-yoga-c630.dtb /etc/flash-kernel/dtbs/qcom/

Now we can start breaking things…

Update our repository information, and then do the dist-upgrade, passing a few options because, well, I don’t really want to babysit it, and I know some contents have changed packages, and won’t update cleanly.

sudo apt update
sudo apt dist-upgrade --download-only # This allows us to download all the updates, before running the update command.
sudo env DEBIAN_FRONTEND=noninteractive dist-upgrade -o dpkg::options::=--force-confnew -o dpkg::options::=--force-overwrite

Go grab a cup of coffee, or your preferred beverage of choice.

Once the update completes, we need to “downgrade” a few packages, because Ubuntu changes the epoch in their package version so it only ever updates to theirs despite new versions coming in from Debian, and Kali tends to follow Debian’s versioning a bit closer.

sudo apt install --allow-downgrades libnautilus-extension1a=3.36.2-2 nautilus-data=3.36.2-2 python3-software-properties-0.96.20.2-2.1 libgudev-1.0-0=233.1 gcc-8-base

Now lets install the Kali metapackages…

sudo apt install kali-desktop-gnome # You can also use kali-desktop-xfce, but for now, I'd suggest sticking with gnome due to the mesa issue that hasn't been patched just yet in Debian.

We’re gonna have a bit of repeats here, because once we’ve done these updates, we’re going to remove a bunch of packages, and part of that will likely uninstall the Kali metapackages as well. But now we’re going to remove Ubuntu specific packages, or packages that we’re not going to be using. I got this list with a fairly quick dpkg -l | grep ubuntu so you may want to check that output, rather than blindly copying in my command below.

sudo apt purge adium-theme-ubuntu alsa-base apport apport-gtk aptdaemon aptdaemon-data apturl-common dmz-cursor-theme fonts-khmeros-core fonts-lao gcc-7-base gnome-accessibility-themese gnome-shell-extension-ubuntu-dock gnome-themes-extra gnome-themes-extra-data gsettings-ubuntu-schemas kerneloops libao-common libappindicator3-1 libappindicator37 libprocps6 libpulse-mainloop-glib0 libpulse0 libpulsedsp libsane1 libssl1.0.0 libwhoopsie0 libxcb-util1 linux-firmware linux-sound-base ltrace multiarch-support network-manager-config-connectivity-ubuntu nplan perl-modules-5.26 pppoeconf printer-driver-pnm2ppa pulseaudio pulseaudio-module-bluetooth pulseaudio-utils python3-apport python3-aptdaemon python3-aptdaemon.gtk3widgets python3-xkit sound-theme-freedesktop ubuntu-advantage-tools ubuntu-artwork ubuntu-docs ubuntu-drivers-common ubuntu-keyring ubuntu-minimal ubuntu-mono ubuntu-release-upgrader-core ubunt-release-upgrader-gtk ubuntu-report ubuntu-settings ubuntu-software ubuntu-sounds ubuntu-standard ubuntu-system-service ubuntu-wallpapers ubuntu-wallpapers-bionic whoopsie xserver-xorg-input-wacom xul-ext-ubufox

Now, this likely also removed some of our wanted Kali packages, so to be sure we get them back, we’re going to reinstall the gnome desktop, and then we will install the kali-linux-default metapackage which gives us the packages that a default Kali installation would have.

sudo apt install kali-desktop-gnome
sudo apt install kali-linux-default

At this point, before rebooting, you would want to follow the steps from my previous post for upgrading the kernel. I happen to have the packages still, for the kernel, and mesa, so I don’t need to rebuild them, but I do need to make a couple small modifications when upgrading to 5.7.0-rc7, which is the current kernel version I’m patching.

Remember how earlier we put the dtb file into place so flash-kernel doesn’t complain? Well now we need to remove it, and we also need to update the flash-kernel database because the 5.7 kernel changes the name of the dtb file we use.

sudo rm -rf /etc/flash-kernel/dtbs/qcom
sudo $EDITOR /usr/share/flash-kernel/db/aarch64-laptops.db

In the aarch64-laptops.db file, we want to change the last line, from the old dtb filename, to the new one. The line should now be DTB-Id: qcom/sdm850-lenovo-yoga-c630.dtb.

Now that we’ve made this change, we can go ahead an install our 5.7 kernel debs

sudo dpkg -i kernel*.deb

If you’ve also rebuilt mesa with the freedreno fix, you probably want to install those now as well. Locally, I’ve just gone ahead and cloned the mesa repo from debian, added the patch for freedreno into the debian build sources for 20.0 (debian-unstable branch) and then built the packages, and then we go ahead and install them.

sudo apt install ./libegl-mesa0_20.0.7-1_arm64.deb ./libgbm1_20.0.7-1_arm64.deb ./libgl1-mesa-dri_20.0.7-1_arm64.deb ./libgl1-mesa-glx_20.0.7-1_arm64.deb ./libglapi-mesa_20.0.7-1_arm64.deb ./libglx-mesa0_20.0.7-1_arm64.deb ./mesa-va-drivers_20.0.7-1_arm64.deb ./mesa-vdpau-drivers_20.0.7-1_arm64.deb ./mesa-vulkan-drivers_20.0.7-1_arm64.deb

At this point, we should be good to reboot into our “new” Kali installation.


As of June 16, 2020, we have Mesa 20.1.1 in Kali, which includes the freedreno fix, so there’s no need to build the mesa packages anymore.

textlinuxc630lenovoarm64kali

steev

Gentoo Linux developer, Kali Linux developer

Lenovo Yoga C630 Progress