www.alxm.org

Linux Mint Notes

Here is a collection of Linux Mint notes on a variety of topics. I only tried these on the amd64 Cinnamon editions, and there may be mistakes and omissions; please remember to backup your files before making system changes!


Disable Swap on Linux Mint 19

My computer doesn't have too much RAM, but I don't run anything that intense so I don't use swap and get that storage space back. However small that space is, now it'll be put to good use by the drive's wear leveling.

The Linux Mint 18 installer lets you choose not to use a swap partition, but Linux Mint 19 always uses a swap file located at /swapfile instead of a separate file system partition.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Turn off swap
$ sudo swapoff -a

# Edit file systems config
$ sudo nano /etc/fstab

    # Comment out these lines, insert a `#` at the start of each
    /swapfile none swap sw 0 0
    /dev/mapper/cryptswap1 none swap sw 0 0

# Edit encrypted block devices config
$ sudo nano /etc/crypttab

    # Comment out this line
    cryptswap1 /swapfile /dev/urandom swap, ...

# Delete the file and reclaim some space! Mine was 1.4GB
$ ls -l /swapfile
$ sudo rm /swapfile

# Finally, reboot for changes to take effect
$ reboot

At first I only ran swapoff -a without editing the files. This caused some issues that added 30s to the kernel boot time (according to systemd-analyze)! The boot time is back to normal after doing all the others steps.


Show the Time and Git Branch on the Shell Prompt

I customized my Bash prompt to show the current time at the start of every line, and if inside a Git repo also the name of the current branch. This comes in handy a lot, for starters you get a coarse always-there timer for every command you run!

This goes at the end of ~/.bashrc,

1
2
3
4
5
6
git_branch() {
    branch_name=$(git symbolic-ref --short HEAD 2>/dev/null)
    [ $? -eq 0 ] && echo "[$branch_name]"
}

export PS1="\t \u@\h \w\$(git_branch) \$ "

The shell prompt should look something like this now:

1
2
3
4
18:44:05 alex@laptop ~ $
18:44:06 alex@laptop ~ $ mkdir MyProject && cd MyProject
18:44:14 alex@laptop ~/MyProject $ git init
18:44:20 alex@laptop ~/MyProject[master] $

Page History