Showing posts with label swap. Show all posts
Showing posts with label swap. Show all posts

Friday, July 13, 2012

Got swap partition back - Ubuntu 12.04 custom kernel

I am making efforts to save time for others, and to show how not to name symbols, how not to miss information required for kernel config help, and broken sanity checks.

Many days after I started using custom built kernel with Ubuntu 12.04 LTS, I noticed that the swap partition was missing. During a busy session involving Google Chrome, the biggest memory hog of all apps I use, VirtualBox, LibreOffice, etc., the system was thrashing non-stop. I had to power off the PC to gain any control! The swap was present with the stock kernel. So, the obvious candidate was tried: update-initramfs. No change.

Inspection of fstab config revealed that cryptswap is being used now! So far, I did not have any of the related settings in my custom config. Worse, there was no hint while wading through the config to let me know of this change and the needful config setting. That is the real culprit!

$ cat /etc/fstab...
# swap was on /dev/sdaX during installation
#UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx none  swap  sw  0  0
/dev/mapper/cryptswap1 none swap sw 0 0


$ cat /etc/crypttab 
#
cryptswap1 /dev/sdaX /dev/urandom swap,cipher=aes-cbc-xxx...
$ file  /dev/mapper/cryptswap1 
/dev/mapper/cryptswap1: symbolic link to `../dm-0'

These config flags are hidden under apparently unrelated sub-part "Multiple device driver support (RAID and LVM)" under Drivers config:

CONFIG_DM_CRYPT=m
CONFIG_MD=y

These flags cannot be searched under xconfig. You will have to enable "Device mapper support" and only then they appear in search. Due to bad inter-dependent code, the compilation fails on usage of debug output function/ macros; so you will have to also enable "RAID support". For brevity I have not listed config settings that get enabled due to that.

Encrypted file system config is (still!?) under experimental. I learned that earlier, similarly the hard way. It will be nice if these changes are available on the Ubuntu wiki that lists instructions for building custom kernels using Ubuntu released kernel code.
CONFIG_ECRYPT_FS=y


Backgrounder about crypt on Ubuntu:

Sunday, February 28, 2010

Fit more in limited RAM -- compcache

'What's new' for Linux kernel version 2.6.33 had mention for it; so I tried out this compcache--using part of RAM for saving swapped out memory contents after compressing them to fit more. While the argument for using it is to let CPU do more work and save on disk access latencies, after having configured it the difference in responsiveness on my desktop was somewhat noticeable. The mouse movements were jerky. Firefox browser was not responding for tab switch when loading a large Web page... Guess, this argument works better on multi-core, faster processors than my single core 1.6GHz Intel P4 running Ubuntu.

Was going to disable it. However, when I re-ran the same tests without compcache configured, the issue with Firefox persisted. So, in the interest of using less of my aging disk having the swap partition, I have retained compcache and bear with that minor mouse jerkiness :-). To benefit better from the same, I have increased the value for swappiness kernel tunable parameter to 50 from a previous lower value of 40.

Using SSD memory for swap partition may be a better idea. A good friend had originally mentioned this idea to me few months back. What do you say?

Tuesday, September 8, 2009

Frugal configuration for an optimal performance Ubuntu Linux desktop

Further to the kernel reconfiguration done earlier, I continued my quest to make life better with the limited resources on my seven year old PC with just 512MB DDR RAM. These things helped reduce total memory consumption and thrashing:

Choosing leaner desktop environment
While fvwm was the leanest, it was provided crappiest user experience. More so after you are used to GNOME or Windows. I did not have enough patience to customize fluxbox to the nth degree to come up with an acceptable set. Using it with iDesk made life a bit easier; but still laborious to keep creating those icons for commonly used applications. I felt as if I had deprived myself of something. WindowMaker (WM) and Xfce provided more acceptable, closer-to-GNOME GUI in that order. Needed to add a taskbar and notification area using perlpanel under WM environment. The real turn-off with WM was its inability to properly show OpenOffice.org Spreadsheet. Though Xfce is not as lean as WM, it is still leaner than GNOME and yet provides almost similar functionality as GNOME. Interestingly, I found application response (GUI update) was faster with Xfce than even fluxbox!

Kernel tunable parameters
swappiness: reduced the default value 60 to 40. More memory available for applications and less greediness in dedicating it for buffers/ cache. Resulting in lesser swap out. I open multiple programs and my usage needs frequent switch between them; hence this choice. I read in [2, 3] that for I/O intensive applications, more aggressive value is recommended.

Useful references
  1. Reduce your Linux memory footprint
  2. 2.6 swapping behavior 
  3. Linux: Tuning Swappiness