Was in the middle of important data processing when my Linux froze. It did it again a few hours later. The culprit turned out to be the nvidia + linux open source (nouveau) driver.
I had struggled to set up linux Thinkpad W520 to work correctly with external monitor on docking station about 5 years ago. I had to use Linux in a windows virtual machine on my laptop until I get a radeon laptop. 5 years later, it is not so much better for whatever reason.
One of solutions online was to replace nouveau with proprietary nvidia driver. But, unlike the last time, it worked ! The following is a step-by-step solution to getting nvidia proprietary driver working :
step 1: find out the model of your nvidia gpu with the following command
ubuntu-drivers devices
step 2 : locate and download respective driver from nvidia website
https://www.nvidia.com/Download/index.aspx
step 3 : make the downloaded file executable and install necessary perquisites/dependencies to build the driver modules
chmod +x NVIDIA-Linux-x86_64-XXX.XX.run
sudo apt-get install gcc make
step 4 : stop the default nouveau driver from loading and prepare initramfs
sudo bash -c “echo blacklist nouveau > /etc/modprobe.d/blacklist-nvidia-nouveau.conf”
sudo bash -c “echo options nouveau modeset=0 >> /etc/modprobe.d/blacklist-nvidia-nouveau.conf”
sudo update-initramfs -u
step 5 : reboot the system, go to command line tty and set the runlevel to 3
ctrl + alt + F2
sudo telinit 3
sudo bash NVIDIA-Linux-x86_64-XXX.XX.run
apt install xserver-xorg-input-all
/sbin/reboot
Cheers !!