How to install Wi-Fi driver for Realtek RTL8821CE on Ubuntu 18.04? [duplicate]

(This question is a duplicate of Wi-Fi not working on Lenovo ThinkPad E570 (Realtek RTL8821CE) but I was pleased that we eventually found a solution so will write up what worked for Haz.)

As far as I can tell, at the time of writing this, there is not yet a Wifi Driver for the Realtek RTL8821CE in the official Ubuntu Repositories.

Over on github there is a repository with an RTL8821CE driver aimed at kernels 4.14 and above and specifically for Arch Linux with no support provided for other Linux Distros: https://github.com/tomaspinho/rtl8821ce

(Minor note: as of February 2019 tomaspinho is sadly no longer able to maintain the driver as he no longer has access to a computer with this chipset, and so a new maintainer may be needed, but the driver still works with Ubuntu 18.04 as at that time.)

It has, however, been reported to work just fine with Ubuntu 18.04.

The solution is taken directly from post #4 by Praseodym: https://ubuntuforums.org/showthread.php?t=2398917 and will install a number of packages for building the wifi driver module (git, dkms, build-essential & linux-headers) and clone the git repository from tomaspinho.

DKMS is used because it's "a system which will automatically recompile and install a kernel module when a new kernel gets installed or updated."


Open up a terminal and type the following lines (You can cut and paste if you prefer):

sudo apt-get install --reinstall git dkms build-essential linux-headers-$(uname -r)
git clone https://github.com/tomaspinho/rtl8821ce
cd rtl8821ce
chmod +x dkms-install.sh
chmod +x dkms-remove.sh
sudo ./dkms-install.sh

After this is completed successfully, you should reboot and find that your Wifi is working.

You also want to make sure SecureBoot is Disabled in the BIOS settings or it won't let you load the unsigned self-complied kernel module.

OR

Sign the 8821ce.ko file yourself as per command given here

kmodsign sha512 \
    /var/lib/shim-signed/mok/MOK.priv \
    /var/lib/shim-signed/mok/MOK.der \
    /usr/lib/modules/$(uname -r)/kernel/drivers/net/wireless/8821ce.ko

@pHeLiOn's answer helped me out, but it wasn't enough. So here is exactly what I did to get it working on my HP.

Make sure to remove the driver if you have previously unsuccessfully installed it via sudo ./dkms-install.sh and then the directory rm -rf rtl8821ce. It may be located in cd /var/lib/dkms/, delete it there too.

  1. I disabled secure boot (you need to reboot after this command and enter the password chars on the blue screen):

    sudo mokutil --disable-validation
  2. I upgraded the Kernel from 4.15 to 4.18, cuz for some reason it wouldn't work with 4.15. Use uname -a to check your kernel version.

    sudo apt install linux-generic-hwe-18.04
    sudo apt update && sudo apt upgrade -y
  3. Then I reinstalled the dkms headers:

    sudo apt-get install --reinstall git dkms build-essential linux-headers-$(uname -r)
  4. I pulled the github respiratory:

    git clone https://github.com/tomaspinho/rtl8821ce
  5. Entered the new directory:

    cd rtl8821ce
  6. I changed the the file permissions:

    chmod +x dkms-install.sh
    chmod +x dkms-remove.sh
  7. I synced the driver to the correct kernel version:

    make
    sudo make install
  8. I installed the driver:

    sudo ./dkms-install.sh
  9. Finally I rebooted, and to my amazement it worked.

Additionally I changed my PCIe Activate State Power Management as suggested in the github respiratory.