Skip to main content

Using one file as Linux Swap instead of a partition

Sometimes wasting a partition for Linux Swap is quite annoying, so let's use a file instead.

Steps are simple:

cd /whatever-dir/
dd if=/dev/zero of=./swapfile bs=1024 count=<num in KB>
mkswap ./swapfile
swapon ./swapfile

# That's it, you just enabled your swapfile

If you'd hope that it'll start at boot, add it to your /etc/fstab:

echo "/whatever-dir/swapfile none swap sw 0 0" >> /etc/fstab

Exchange 'Caps_Lock' and 'Control_L' (Left Control) using xmodmap

The man page of xmodmap is showing us a way of exchanging/swaping Caps_Lock and Control_L:

! file: ~/.xmodmap

! Swap Caps_Lock and Control_L
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

How to run the script:

  1. Save the script in ~/.xmodmap.
  2. Run xmodmap ~/.xmodmap
  3. Check your Caps Lock and Left Control to see the effect.

However, the script will really swap it. Because if you rerun the script again, it'll swap it back.

Read more…