Add a keyboard shortcut on Ubuntu

Tired of typing the same thing repeatedly?

If you need to type a certain string on regular basis, you may want to set it up as a keyboard shortcut. But one cannot just associate a hot key with the string. Here is how to do it on Ubuntu without installing any extra package.

Continue reading “Add a keyboard shortcut on Ubuntu”

Trade security with performance

The recent CPU flaw caused quite a mess. Most recent linux kernels have the problems patched, but what if I am willing to trade security for performance? I’ll need to compile my own kernel and here is how to do that on Ubuntu 17.

apt install git build-essential kernel-package fakeroot libncurses5-dev libssl-dev ccache
wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.15.tar.xz
tar Jxvf linux-4.15.tar.xz
cd linux-4.15

First, we need to make oldconfig. Basically copy the kernel compile config from Ubuntu and decide whether new features should be enabled

cp /boot/config-4.13.0-32-generic .config
make oldconfig

Here I disabled the first feature related to spectre and meltdown

RETPOLINE=n

Next, in menuconfig, disable another feature which was already enabled in 4.13.0-32

Remove the kernel mapping in user mode (aka CONFIG_PAGE_TABLE_ISOLATION=n)

If like me you have no plan to debug kernel issues, disable the kernel debug package which can save a lot of time. Disable it from Kernel hacking > Compile-time checks…

Probably all the staging drivers can be skipped too. Uncheck them from Device Driver > Staging…

Disabling debug and staging drivers reduce the compilation time by almost 50%. On my machine, that is about 30 minutes.

We are now ready to compile the kernel and create deb packages.

make -j 8 deb-pkg LOCALVERSION=-pos

The above will provide deb packages in the parent directory. It takes about 50 minutes for all of the above on a c5.2xlarge. $0.34 plus storage and network transfer price. Kernel compilation is no longer an excuse to upgrade to faster CPUs!

linux-headers-4.15.0-pos_4.15.0-pos-1_amd64.deb
linux-image-4.15.0-pos_4.15.0-pos-1_amd64.deb

I installed the Performance Over Security (pos) kernel on my desktop. The performance gain is noticeable. Do it at your own risk though.

Update

It may be possible to turn off these CPU fixes without compiling your own kernel. Add the followings to kernel boot parameters. Reference https://www.linux.com/blog/intro-to-linux/2018/1/linux-kernel-415-unusual-release-cycle

spectre_v2=off pti=off

The new kernel comes with an interesting sysfs entry:

# ls -1 /sys/devices/system/cpu/vulnerabilities
meltdown
spectre_v1
spectre_v2

Adding SystemRescueCD to grub2

Adding a bootable ISO image to grub will be very useful for recovering Linux systems. Here we add the systemrescuecd iso to grub2 on Ubuntu 15.04. It’s really easy and I recommend adding it to every Linux systems!

This will be very useful for recovering Linux systems. Here we add the systemrescuecd iso to grub2 on Ubuntu 15.04. It’s really easy and I recommend adding it to every Linux systems! Continue reading “Adding SystemRescueCD to grub2”

Flash on Ubuntu+Firefox

It’s the most annoying thing when every now and then, your flash version is outdated and it won’t load the pages you visit every day.

For me, this solved the problem:

First, install pepperflashplugin-nonfree. It’s avaialble from official repository on Ubuntu 14.04. But this only install the plugin for chrome.

Second, install the Fresh Player plugin from http://www.webupd8.org/2014/05/install-fresh-player-plugin-in-ubuntu.html

Restart Firefox and that’s it. Sadly, the plugin still consume a considerable amount of CPU resources. It feels faster than the official player from Adobe though.