Tutorials

1, 2, 3, Ubuntu

How to install Ubuntu and Windows for OSS Developing Purposes

This pages describes how to get Ubuntu 16.04 (resp. Ubuntu 14.04) installed on a PC for software developing purposes. The main objective is to get a system that supports switching back and forth between Linux and Windows to develop and test OSS software on both platforms. This includes the installation of a virtual machine running Windows.

The Ubuntu installation procedure is organized in the following three main stages:

  1. Ubuntu Installation
  2. Ubuntu Tweaking
  3. Additional Software

The Windows installation procedure is organized in the following three main stages:

  1. Virtual Box Installation
  2. Windows 7 Installation
  3. Visual Studio Installation

The background story is that I used to be pretty content with developing on a MacBook Pro. The main focus of my open-source development projects was Mac and Linux, but I also needed to test my software on a Windows platform, since I am mostly using Qt as underlying UI. For the latter purpose I had another ASUS laptop with Windows 7 around. This had been working very well for quite a while until the file system of my Windows box just passed Jordan. When trying to reinstall Windows 7, I needed to identify all necessary drivers due to the lack of a recovery DVD. After numerous failing attempts, I remembered how easy the installation of my Linux box was. It was setup in less than an hour and has been working ever since as a reliable and speedy work horse.

At that point I decided, that I won’t try to to install Windows any more. Period. I’d rather install Ubuntu as primary operating system and have a virtual machine running Windows 7 (or XP). If Windows will ever crash again, I will just happily press the “roll back” button of the virtual machine.

So here is what I did in short:

  • Installed Ubuntu Desktop 16.04 LTS 64bit (resp. Ubuntu 14.04 LTS)
  • Installed Virtual Box
  • Installed Windows 7 in a virtual machine.
  • Installed MSVC 2010 on the VM.
  • Took a snapshot of the virtual machine.
  • Saved a clone of the VM on an external hard drive that gets a daily backup.

1) Here is the Ubuntu installation in more detail:

  1. Get Ubuntu LTS 64bit from www.ubuntu.com.
    1. In particular get the Ubuntu 16.04.3 LTS Desktop AMD64 or Ubuntu 14.04 LTS Desktop AMD64 installer iso image.
  2. Prepare a DVD containing the Ubuntu iso image. To burn the DVD I used the disk utility of my MacBook Pro.
  3. Change the boot order in the ASUS bios setup to first boot from CD/DVD. To enter the ASUS bios one needs to press and hold F2 during boot.
  4. Boot from the disc drive.
  5. After booting into the Ubuntu installer there is a popup window with two options. We select the “Install Ubuntu” option.
  6. In the installer window we select the following options:
    1. Select the option “Install third party software”.
      1. Caution: If you have a computer with NVIDIA Optimus, be cautious to select that option, since it will install the NVIDIA drivers. Those may cause problems with Optimus! It may be a better option to stick with the INTEL drivers!
    2. If you have your computer connected to the internet via ethernet cable, select “Download software updates while installing”.
  7. Installation method is “Replace Windows”.
  8. Select the location (in my case “Nuernberg”).
  9. Select “English (US)” keyboard.
  10. Enter name, login name and password.
  11. After ca. 15 minutes of installation, eject the DVD and click “Restart” to reboot your system.

2) Some fine tuning after we have booted into Ubuntu:

  1. In the top right menu, click at the network symbol and select your WLAN connection from the popup list or use the ethernet, which is detected automatically.
  2. Turn off auto-updating, because on a development platform we would like to trigger updates manually.
    1. In the Software Center (the symbol with the “A” icon in the dock on the left) choose the tab “Updates” and set “Automatically check for updates” to “Never”.
    2. Manual updates are done with the “Software Updater”.
  3. Enable multiple keyboard layouts.
    1. Go into the system settings and select “Text Entry”.
    2. Add the keyboard layout of your choice.
    3. Then in the top right corner, a menu icon appears which let’s you choose between the layouts.
  4. Tweak the Terminal preferences
    1. Search for “Terminal” with the Ubuntu Search Center (top left icon).
    2. Drag the “Terminal” icon into the sidebar.
    3. Open the terminal (or hit Ctrl-Alt-T).
    4. Change the scrolling preference to unlimited in the Terminal’s “Profile Preferences”.
    5. Change the login shell to “/bin/tcsh” or “/bin/bash” or whatever your favorite shell is.
  5. Turn off the “Guest” session, which allows all users to login without a password.
    1. Open a terminal (by hitting Ctrl-Alt-T) and edit the loggin settings by typing:
      1. sudo gedit /etc/lightdm/lightdm.conf
    2. In the editor, disable the guest session as follows:
      [SeatDefaults]
      user-session=ubuntu
      greeter-session=unity-greeter
      allow-guest=false
    3. The same as a single command line:
      1. sudo sh -c 'printf "[Seat:*]\nallow-guest=false\n" >/etc/lightdm/lightdm.conf.d/50-disable-guest-session.conf'
  6. Personalize the desktop by right-clicking at the background, then choose “Change Desktop Background”.
    1. For example choose the following 32:9 virtual panorama of Lanikai, Hawai’i:
    2. Or whatever:
  7. Just for curiousity, we print some information about the system (using the terminal):
    1. cat /proc/version
    2. cat /proc/cpuinfo
    3. cat /proc/meminfo

3) NVIDIA Graphics drivers

  1. In case we have an NVIDIA graphics chip, we install the NVIDIA drivers using the Unix terminal:
    1. Open a terminal (Ctrl-Alt-T).
    2. In the terminal type:
      1. sudo apt-get install nvidia-current
      2. Note: the above package is already installed if we checked “third party software” during Ubuntu installation.
  2. We also install some useful graphics tools:
    1. sudo apt-get install mesa-utils
  3. To find out about the actual installed graphics drivers, type:
    1. glxinfo | grep "OpenGL renderer string"
  4. To test the driver installation, we run the following graphics program that shows a 3D animation of three rotating gears:
    1. glxgears

4) Additional software packages

  1. Software development packages to be installed on the command line:
    1. Install Tom’s C shell (tcsh):
      1. sudo apt-get install tcsh
    2. Install the GNU C++ compiler an debugger:
      1. sudo apt-get install g++ gdb
    3. Install the Subversion software revisioning tool:
      1. sudo apt-get install subversion
    4. Install the CMake build system:
      1. sudo apt-get install cmake cmake-curses-gui
    5. Install the documentation generator Doxygen:
      1. sudo apt-get install doxygen graphviz
    6. OpenGL related development packages:
      1. sudo apt-get install freeglut3-dev mesa-utils
    7. We also install some common development packages:
      1. sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
    8. We also install some not so common development packages (at your option):
      1. sudo apt-get install libcurl4-openssl-dev libexpat1-dev libexiv2-dev libgdal-dev gdal-bin
    9. If we need Qt, we also install the Qt4 development package:
      1. sudo apt-get install libqt4-dev
    10. If we want to log onto our Linux box via ssh, we also install the ssh server:
      1. sudo apt-get install openssh-server
    11. For java development we install the OpenJDK:
      1. sudo apt-get install openjdk-7-jdk
    12. We also install some helpful utilities and programs:
      1. sudo apt-get install wget curl git cvs kate
  2. Optional graphical packages to be installed through the Software Center
    1. System Load Indicator
    2. Emacs24
    3. Gimp
    4. Inkscape
    5. ImageMagick
    6. KDevelop4
    7. QtCreator & QtAssistant
    8. Blender
    9. VLC

As a short cut, here is all the above stuff in a single install command line:

sudo apt-get update && sudo apt-get install tcsh g++ gdb subversion openssh-server cmake cmake-curses-gui doxygen freeglut3-dev mesa-utils libjpeg-dev libpng-dev libtiff-dev libcurl4-openssl-dev libexpat1-dev libexiv2-dev libgdal-dev gdal-bin libqt4-dev xorg-dev libglib2.0-dev libpulse-dev openjdk-8-jdk wget curl git cvs kate indicator-multiload emacs24 gimp inkscape imagemagick kdevelop qtcreator qt4-dev-tools blender vlc virtualbox

If you are running OpenSuse 13+, the package names on the install line are a bit different:

sudo zypper install tcsh gcc-c++ subversion cmake cmake-gui doxygen graphviz freeglut-devel libjpeg-devel libpng-devel libtiff-devel libcurl-devel libexpat-devel libexiv2-devel libqt4-devel xorg-x11-devel wget curl git cvs kate emacs gimp inkscape imagemagick kdevelop4 qt-creator blender vlc

Optionally: When OpenSSL is required for development purposes, we need to take into account that Ubuntu 14.04 contains OpenSSL 1.0.0f, which is affected by the Heart-Bleed bug. At the time of this writing (28.6.2014), libssl-dev should not be installed for obvious security reasons. To add development files for OpenSSL we need to download version 1.0.1g and compile it from source:

curl -O http://www.openssl.org/source/openssl-1.0.1h.tar.gz
tar zxf openssl-1.0.1h.tar.gz
cd openssl-1.0.1h
./config --prefix=/usr/local --openssldir=/usr/local/openssl
make
sudo make install

Optionally: In case we need Qt5 instead of Qt4 for development, we install the Qt5 development packages from source (prebuilt packages are not recommended):

Optionally: Some development packages like GDAL require libiconv. In such a case we install libiconv from source:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.11.tar.gz
tar zxf libiconv-1.11.tar.gz 
cd libiconv-1.11/

./configure 
make
sudo make install

5) Testing

Now our system is basically setup and ready for OSS development. It took about an hour or so.

To test that everything went fine, we check out, compile and install the libsquish package with svn/cmake/gcc:

svn checkout http://svn.code.sf.net/p/libsquish/code/trunk libsquish
cd libsquish
cmake .
make
sudo make install

6) Installation of Virtual Box:

sudo apt-get install virtualbox

The above command installs VirtualBox 4.3. Virtual Box is available as desktop application in the search bar: Click at the top left Ubuntu icon and type “virtual box” on the search line. Then double click on “Virtual Box”.

7) Installation of Windows on a virtual machine:

  1. Launch Virtual Box.
  2. Click at the “New” button to create a new virtual machine (VM):
    1. Choose “Windows” as VM type.
    2. As VM size, select about a quarter of what your PC has. E.g. select 1024 MB on a machine with 4GB of RAM.
    3. Create a virtual hard drive of 32GB with otherwise default settings.
  3. Check VM settings:
    1. In the Virtual Box settings, make sure that the VM network mode is set to “NAT” and that the emulated network adapter is set to “Intel PRO/1000 MT Desktop” in case you are running Windows 7 or Vista. On Windows XP you need to choose the “PCnet-FAST III” adapter.
  4. Trouble Shooting:
    1. If you happen to experience “mouse freezes” while running Virtual Box, then switch to the console (Ctrl-Alt-F1) and back (Ctrl-Alt-F7).
  5. Start the virtual machine with the “Start” button.
    1. When asked, insert your Windows installer disc into your physical disc drive or mount a respective iso image as a virtual disc device. The latter is faster.
    2. Standby while the VM boots from the Windows installation disc and performs the installation…
      1. As for myself, I have chosen to install Windows 7 Professional (32 bit) /w Service Pack 1 from an iso image.
      2. This took about 30 minutes!

8) Finetuning Windows 7 (or XP):

  1. Change screen resolution
    1. Right-click at the desktop and choose “Screen resolution” from the context-menu (“Properties→Settings” on XP). Then set the resolution to 1024×768 or whatever you may find appropriate.
    2. Now press Right-Ctrl-F to switch to fullscreen mode.
    3. Press Right-Ctrl alone to uncapture the mouse.
  2. Guest additions
    1. It is recommended (although not necessary) to install the guest additions, which contain additional drivers for ease of use of the VM, as follows:
    2. Goto the VM’s menu, click at “Devices” and select “Insert Guest Additions CD image”. This mounts a CD containing additional drivers for your VM. Just wait until the driver installer starts automatically. Most notably a graphics driver for unconstrained screen sizes and extended copy&pasting from host to guest is installed. Also drivers for various network cards and media devices are installed that might not be part of the actual guest system.
  3. Virtual Box compatibility
    1. Windows 7 works properly on Ubuntu 13.10 with Virtual Box 3.1.8 and above.
    2. Same for or MacOS X 10.5 Leopard.
  4. Troubleshoot internet
    1. In case your internet connection is not working, try to “ping www.google.com” on the “cmd” command prompt.
    2. If there is no ping from google, then open the “Network and Sharing Center” and click at “Local Area Connection”. Look at the “Details” and check that the IP settings are ok. The IP address should be 10.0.2.x, the gateway 10.0.2.2 and the DNS server 10.0.2.3.
  5. Stopping Automatic Updates
    1. In a virtual machine that is safe behind the host’s firewall, we would like to stop automatic updates that would otherwise alter our working system.
    2. In the “Control Panel” select “System and Security→Windows Update→Change Settings” and set the policy to “Never check for updates”.
    3. And now for a last time, we may perform an update of our system by selecting “System and Security→Windows Update”.
      1. Due to problems with Visual Studio 10, it is not recommended to update your system, if you want to use Visual Studio 10! However, updating is recommended for Visual Studio 2013.
      2. Be aware that updating Windows 7 will amount to 150 updates with about 350MB in total and more than 3 hours of drinking coffee.
  6. Personalize the desktop
    1. Right-click at the desktop and choose “Personalize” from the context-menu. Then set the theme and the desktop background to your personal preferences (“Properties→Themes” resp. “Properties→Background” on XP). I prefer the classic theme with a solid blue background.
    2. I do not like IE. I am installing Firefox right away to get rid of that bloated web browser.
  7. Create a snapshot!!!
    1. Unmount the installer image (“Devices→CD/DVD Devices→Unmount”).
    2. Close the VM window to save the machine state (Right-Ctrl-Q) or simply power-off Windows.
    3. In the VirtualBox main window, click at “Snapshots” and take a snapshot of the actual VM’s state. If anything goes wrong with the VM, you can roll back the state of the machine to a prior snapshot.

9) Installing MSVC++:

  1. Insert your MSVC++ iso image into the virtual disc device of the VM by choosing VM→Menu→Devices→CD/DVD Devices→Choose a virtual CD/DVD disk file.
  2. Open the installer application contained on the virtual disc.
  3. Standby while MSVC is being installed…
    1. When opting to install the latest Visual Studio 2013 it is 7.7 GB of disk space /wo all the optional addons.
    2. Visual Studio 2010 is “only” 4GB.
  4. Finally, create another snapshot!!!

10) Cloning a VM:

If you want to run a virtual machine on a different host you can do it like so:

  • Power-off the machine which you want to clone. A running machine cannot be cloned.
  • Select the “Snapshots” tab of the machine.
  • Create a snapshot of the current machine.
  • Delete all previous snapshots by repeatedly removing the topmost snapshot.
  • Clone the current machine state with the “Sheep” symbol.
    • You must give the cloned machine a different name. The suggested name with the “_clone” extension will suffice.
    • This produces a .vdi file that is located under ~/Virtual Box/ on Unixes or in ~/Library/Virtual Box/ under MacOS X.
  • If you have an old version of Virtual Box like 3.1.6, you need to use the command line tool VBoxManage to clone the machine:
    • VBoxManage clonehd /full/path/to/harddisk.vdi /full/path/to/clone.vdi
  • Copy that .vdi file to the Virtual Box directory of the host machine you want to run your virtual machine on.
  • Then create a new machine. The process of creating the new virtual machine will be the same as if you were creating a standard virtual machine until you get to the “Virtual Hard Disk” creation screen. You will select “Use Existing Hard Disk”, click the folder icon, navigate to the newly copied .vdi file, select the file in question, and then click “Next”.
  • The new machine will be running in exactly the same fashion, regardless if you copied it from Linux→Linux, Linux→Mac or Mac-Linux, Mac→Windows or the other way round.
  • BTW: The .vdi images compress very well when compressing with tar/gzip:
    • tar zcf VM.tgz VM.vdi

11) Results:

After all is said and done, the entire Ubuntu/Win7 installation consumed about 6GB of disk space for Ubuntu and 20GB for the Windows 7 VM. The VM itself has 13GB space left on a hard drive with 32GB.

For an experienced developer, installing Ubuntu will roughly take about an hour /wo tweaking. Installing Windows 7 on a virtual machine will also take about an hour /wo updating the system. Installing Visual Studio 10 is about 30 minutes /wo updating. Updating will take more than 3 hours. In total be prepared to reserve an entire day for the installation of Ubuntu and the Windows 7 VM.

But more important, reserve an additional day or two for trouble shooting and testing. It took me about 3 days to work around the usual pitfalls and to get everything working as explained above.

UbuntuWinXP MacWin7

12) Backing things up:

As you certainly understand, backing things up is important! If something can go wrong, it will go wrong eventually. In particular when you need it most.

So please be sure, to clone your newly setup VM and copy the .vdi file to a place where it is safe.

For that purpose I personally recommend to have a pair of identical external hard drives, where all your important data is stored on one of the hard drives so that the current machine you are working with does not contain any data that shouldn’t get lost. Then backup the external drive to the other one, by using an automatic incremental backup via rsync as explained in this tutorial.

13) Next Steps for Software Development on Windows:

On the VM we need the following tools to start developing:

In the home folder we create a Projects folder, were we check out the OSS projects that we want to work with. To check out a project we use Tortoise SVN.

Example checkout of libsquish.sourceforge.net:

  • Navigate into the Projects folder in Windows Explorer.
  • Right click at the folder window in Windows Explorer.

Build the OSS project. We use the CMake build system for that purpose.

  • Start the CMake GUI.
  • Locate the project directory (e.g. libsquish) by clicking on the “Browse Source” button. Win7cmake
  • Locate the build directory by clicking at the “Browse Build” button. For an in-place build we use the same directory as the source directory.
  • Click “Configure”.
  • If you’d like to modify the default build configuration, make your changes.
  • Click “Configure” again to accept the configuration.
  • Click “Generate”.
  • Open the generated Visual Studio 10 solution file in the build directory:
    • e.g. double click at …/Projects/libsquish/squish.sln Win7vs10
  • In VS10 select “Build” in the “Build” menu.
  • Standby while the project is being built.

Rebuild the OSS project after an update:

  • Right click at the projects folder. Win7svnup
  • Choose “SVN Update” from the context menu.
  • Reopen the VS10 solution file and choose “Build→Build” again.

Change VC++ Text Editor Settings:

  • Tools→Options→Text Editor→C/C+±>Tabs→Tab→Insert Spaces

Enable OpenGL support:

  • Make sure that you have installed the guest additions (Step 7).
  • Shut down the VM.
  • Click at “Settings”.
  • Choose “Display” and enable “3D Acceleration”.
  • Now OpenGL is enabled!
  • Do not be too surprised, though, when you find out that only OpenGL 1.2 compatible programs with a few common OpenGL extensions actually work.
  • But that is something ;-)
  • Now, create another snapshot!

14) Next Steps for Software Development on Ubuntu:

As outlined in Steps 1–3 of this tutorial, the described Ubuntu system is ready for developing OSS, which has already been demonstrated by building the libsquish project.

For developing your own OSS software projects, the default settings of the bash terminal are ok, but could be improved. The following tarball home.tgz contains improved configurations for the tcsh, emacs and other Unix tools, that make working with the terminal more comfortable. To use those settings, download the tarball and extract it to your home folder (caution: original dot-files files may get overridden in your home folder!):

cd ~
tar zxf home.tgz

You are welcome to improve on the above settings and find a shell configuration that works best for yourself. I have been working with it since 1995 on MacOS X, Ubuntu, OpenSuse and even Iris4D.

15) Tips, Tricks and Tweaks on Ubuntu:

Ubuntu installation via USB Stick:
  • Download an iso image of Ubuntu
  • Use the usb-creator-gtk tool to create a bootable USB stick from the iso image
    • Start it from the command line with root permissions: sudo usb-creator-gtk
    • Choose iso image
    • Erase USB stick
    • Open USB stick
    • Deselect option for persistence file
    • Make startup disk
  • Check file integrity:
    • Run “md5sum -c md5sum.txt” in the directory of the mounted USB stick
    • If the integrity of the USB stick cannot not verified successfully, the USB stick has memory defects and needs to be replaced before proceeding with the installation
  • Reboot and enter the BIOS by holding F2
  • Change the boot order in the BIOS to boot from the USB drive first
  • Now reboot again
  • After the Ubuntu live system has booted, proceed to install Ubuntu…
Add support for local keyboard layouts:
  • In the “Preferences” go to the “Text Entry” section and add your local language, for example “German”.
  • Then go to the “Keyboard” section and select “Shortcuts”:
    • Enter a new keyboard shortcut for “Typing” and “Switch to next source”.
    • The default is “Super+Space”, but I prefer to have the keyboard layout switch on “Alt+Space”.
On systems with NVIDIA Optimus, the nvidia-331 drivers are buggy.
  • For example, the track pad may freeze occasionally.
  • To get the track pad working again:
    • Hit Ctrl-Alt-F1 and then Ctrl-Alt-F7 again.
  • To prevent the track pad from freezing permanently:
    • Uninstall the NVIDIA drivers with
sudo apt-get remove nvidia\*
How to install the latest NVIDIA drivers:
  • Install the drivers from the xorg-edgers PPA:
sudo apt-get remove nvidia-\*
sudo add-apt-repository ppa:xorg-edgers/ppa -y
sudo apt-get update
sudo apt-get install nvidia-346
  • Or install the drivers from nvidia.com directly:
    • Download the latest “NVIDIA*.run” installer from
    • Switch to the Linux console by hitting Ctrl-Alt-F1:
      • sudo apt-get remove nvidia-\*
        sudo service lightdm stop
        
    • Run the NVIDIA installer and opt for DKMS but do NOT opt to rewrite the xorg.conf configuration:
      • chmod +x NVIDIA*.run
        sudo ./NVIDIA*.run
        
  • If the NVIDIA drivers messed up something, just reinstall the stock nvidia package via “sudo apt-get install nvidia-331”
How to use the OpenGL software rasterizer

If we want to deactivate any graphics hardware acceleration and use the Mesa software rasterizer, we do so with:

export LIBGL_ALWAYS_SOFTWARE=1
How to mirror 4K material over HDMI to a UHDTV
  • With NVIDIA drivers later than “nvidia-360” this should work out-of-the-box
  • For prior driver versions we need to install at least NVIDIA drivers nvidia-346 (nvidia-331 don’t work at all)
  • use xrandr to set the resolution and video rate manually
    • set the resolution of the UHDTV
      • xrandr --output HDMI-0 --mode 3840x2160 --rate 25
    • set the panning area of the primary monitor to match the area of the UHDTV
      • xrandr --output DVI-I-1 --panning 3840x2160
How to mirror two screens
  • nvidia-xconfig --twinview --twinview-orientation="Clone"
If the mouse cursor flickers, this may be related to improper display settings:
  • Go into the system settings and select “Displays”.
  • If the monitor overview shows a second “Unknown Display”, disable it.
How to install the Brackets editor from a PPA:
sudo add-apt-repository ppa:webupd8team/brackets
sudo apt-get update
sudo apt-get install brackets
How to auto-start a program, shell script or demo

Supposed we want to auto-start an application when the computer is turned on, for example to run a demo in endless mode, then we need to enable auto-logon, add the application to the auto-start list and disable a variety of settings that relate to the screen saver and power management:

  • in the user tab of the systems prefs, enable auto-login for the user that should get auto-started
  • in the dock search menu, search for “Startup Applications”
  • in the startup preferences, add your app or script so that it is going to be auto-started on auto-login
  • to make the app run endlessly as demo, we need to deactivate the screen saver, the display power management and three finger mouse gestures:
xset s off
gsettings set org.gnome.desktop.session idle-delay 0

xset -dpms
xset dpms 0 0 0
gsettings set org.gnome.settings-daemon.plugins.power active false

synclient ClickFinger3=0
synclient TapButton3=0
How to adjust the screen gamma
xgamma -display :0 -gamma 0.7
How to change the default settings of the Ubuntu Desktop
  • reset all desktop settings:
gsettings reset-recursively org.gnome.desktop.interface
  • change the default font size of the terminal:
gsettings set org.gnome.desktop.interface monospace-font-name 'Ubuntu Mono 16'
How to change the default window manager from Unity to a more lightweight one

Select from one of the following available window managers:

  • choose Xubuntu (wm=xfce):
sudo apt-get install xubuntu-desktop
  • or choose lubuntu (wm=lxde):
sudo apt-get install lubuntu-desktop

In the login screen:

  • Click at icon on the right side of the login bar, and choose the window manager from the unfolding list.
  • Upon login the choosen window manager will be remembered for the next reboot and also for auto-login.
How can I fix the touchpad right-click issue with Ubuntu 18.04?

gsettings set org.gnome.desktop.peripherals.touchpad click-method areas

How can I access an external hard drive?

http://help.ubuntu.com/community/InstallingANewHardDrive

Ubuntu on the Lenovo Yoga3 11”

Ubuntu 16.04 works fine on a Lenove Yoga 3, but to get the wireless adaptor working reliably, we need to install the proprietary ath10k firmware, which may not part of the base Ubuntu distribution.

If so, please download the latest firmware from:

Now transfer the firmware to the Yoga3, open a terminal and type:

sudo dpkg -i <path/to/the/transferred/file>
sudo modprobe -r ath10k_pci
sudo modprobe ath10k_pci

Edit /etc/modprobe.d/ath10k_core.conf with the following content:

options ath10k_core skip_otp=y

I have found that the driver does not suspend properly in power-save mode and that it does not establish connections reliably on the 5GHz band (wireless mode 802.11a) even with the very latest firmware package and kernel 4.10. Every 5 minutes or so the firmware crashes. Normally the driver would recover automatically from a crash, but for whatever reasons the recovery does not work also.

Therefore, I limited the connections to the 2.4GHz band (wireless mode 802.11bg) and disabled power-save by adding the lines “band=bg”, “channel=6” and “powersave=2” to the “[wifi]” section of the connection settings in “/etc/NetworkManager/system-connections/your-connection-name”.

Now the wireless should be working after a restart:

sudo service network-manager restart

Update: As of December 2017, an Ubuntu update of the Linux kernel 4.10.0–42 seems to address most of the Ath10k driver issues.

How can I switch back to an old kernel, if the latest one breaks something?
  • First open a terminal and find out which kernel your are running:
    • uname -r
  • This will identify something like “4.15.0–72-generic” as the kernel release that we do not want
  • Boot your system into the grub menu (press and hold ESC during UEFI boot)
    • If grub does not show up:
      • add “GRUB_TIMEOUT=5” to /etc/default/grub
      • sudo update-grub
      • reboot
      • Now you should be presented with the grub menu during boot
  • In the advanced options menu of the grub boot loader there should be an older kernel available like “4.15.0–70-generic”
  • Then we boot into this older version of the kernel
  • Now it is safe to remove the troublesome kernel from the system
    • sudo apt-get purge linux-image-4.15.0–72-generic linux-headers-4.15.0–72-generic
  • Alternatively, we can just make the boot option with the older kernel the default
    • We do so by editing /etc/default/grub
    • We change the grub default option, e.g.: GRUB_DEFAULT=“1>2”
    • This means that the third entry (2) in the “Advanced boot options” menu (1), which corresponds to loading the older kernel in this case, is becoming the default
  • Next we update grub so that there are no more boot options that link to the removed kernel:
    • sudo update-grub2
  • Another option is to remember the last grub selection:
    • add GRUB_DEFAULT=saved and GRUB_SAVEDEFAULT=true
  • Sometimes the automatic update of the grub menu still leaves the outdated entries in the menu. Then we need to remove the outdated modules from the /boot folder manually:
    • sudo rm /boot/*−4.15.0–72-generic
  • Next time the software update is running again, any new kernel version will likely break things again and most probably at a time we need it least. To prevent this, we disable the automatic software update check by setting “Automatically check for updates” to “Never”. This will leave it to us to check for software updates manually and see if the kernel issue has been fixed in the mean time. Now we control the kernel and the kernel is not controlling our work flow.
How can I stop those annoying “system detected a problem” popups?

sudo vi /etc/default/apport → change enable=1 to 0

Fix ImageMagick security policy problems with PDF

Support for writing PDFs has been disabled by default due to security issues. You can reenable it by running the following one-liner:

sudo sed -i 's#<policy domain="coder" rights="none" pattern="PDF" />#<policy domain="coder" rights="read|write" pattern="PDF" />#' /etc/ImageMagick-6/policy.xml

Memory limits may also need to be changed in /etc/ImageMagick-6/policy.xml, e.g. enlarged to:

<policy domain="resource" name="memory" value="20000MiB"/>
<policy domain="resource" name="map" value="20000MiB"/>
<policy domain="resource" name="width" value="3200KP"/>
<policy domain="resource" name="height" value="3200KP"/>
<policy domain="resource" name="area" value="25600MB"/>
<policy domain="resource" name="disk" value="16GiB"/>
Install latest discord package
sudo apt install gdebi-core wget
wget -O ./discord.deb "https://discordapp.com/api/download?platform=linux&format=deb"
sudo gdebi ./discord.deb
Make Ubuntu 18.04 behave more like 16.04
  • move the window buttons to the left
    • gsettings set org.gnome.desktop.wm.preferences button-layout ',close,minimize,maximize:'
    • gsettings set org.gnome.settings-daemon.plugins.xsettings overrides "{'Gtk/DecorationLayout':<'close,minimize,maximize:'>}"
Make Ubuntu 18.04 work with NVidia drivers
  • Ubuntu 18.04.4 has 5.3 series kernel that is incompatible with NVidia drivers (as of 13.2.2020)
  • Ubuntu 18.04.3 still has 4.15 series kernel that is compatible with NVidia drivers
  • So the NVidia drivers require the Ubuntu 18.04.3 iso image
  • sudo apt-get install nvidia-384

EOF!

Options: