Install and Optimize Linux Mint 21

This article is about installing and optimizing Linux Mint. The focus is on Mint 21, but it’s relevant to all versions. The best disk layout is discussed at the end of the article.

Install vs Update

If Mint is already installed on your system, then updating to the latest version is an option. I would recommend updating between minor versions, but for major versions, a fresh install is better.

For example, if you have version 21.0 already running, and you want to move to 21.1, just follow the regular update procedure. Packages will install and update, just like regular patching, and complete in short order.

For a major version upgrade, eg. 20.x to 21.x, I would recommend a fresh install instead. Although major version updates are supported, the procedure is lengthy and complex, and the results far from certain. It’s generally true for any OS that updating across major versions leaves behind something of a “patchwork”. A clean install, on the other hand, will be consistent and fully functional.

Disk Considerations

How your disk is partitioned makes a big difference. Please see the Appendix for disk partitioning recommendations.

Download and Install Linux Mint

Download the latest version of Mint and “burn” it to a USB stick. There are options for Cinnamon, MATE and XFCE. Choose your favourite. Graphical programs for writing the image are available in both Windows and Linux. Alternatively, if you are using Linux, shell commands can be used, such as:

$ wget https://mirrors.kernel.org/linuxmint/stable/21.1/linuxmint-21.1-cinnamon-64bit.iso

$ dd if=linuxmint-21.1-cinnamon-64bit.iso of=/dev/sdc bs=1M

…where /dev/sdc is the device of my usb thumb drive.

Installation

Once the image is created, boot your system from the USB stick. On the Linux Mint desktop which opens, click on the “install” icon or similar, and follow the instructions.

Post Installation Recommendations

Below are a few simple adjustments that might be useful. None are strictly necessary. Some might reduce system load and or boot time, or make your PC run slightly quicker/quieter/cooler.

Deactivate ZFS

Linux Mint 21 has openZFS installed and running by default. ZFS is fantastic, but not hugely useful on a single disk system. If you don’t intend to use it, disable ZFS as follows.

Check ZFS drivers are running:

$ lsmod | grep zfs
zfs                  3821568  6
zunicode              348160  1 zfs
zzstd                 491520  1 zfs
zlua                  163840  1 zfs
zavl                   20480  1 zfs
icp                   323584  1 zfs
zcommon               106496  2 zfs,icp
znvpair                98304  2 zfs,zcommon
spl                   118784  6 zfs,icp,zzstd,znvpair,zcommon,zavl

Disable all ZFS services:

sudo systemctl disable zfs-load-module.service
sudo systemctl disable zfs-mount.service
sudo systemctl disable zfs-share.service
sudo systemctl disable zfs-volume-wait.service
sudo systemctl disable zfs-zed.service
sudo systemctl disable zfs-import.target
sudo systemctl disable zfs-volumes.target
sudo systemctl disable zfs.target

and reboot. After the reboot, check ZFS is no longer running (that the zfs modules are not loaded into the kernel – the following command should produce no output.

$ lsmod | grep zfs
$

Note: ZFS is still installed on the system at this point, but not active or running.

Deactivate Bluetooth

If you don’t need Bluetooth, it can be deactivated like this.

# service bluetooth stop
# systemctl disable bluetooth

Disable IPV6 Networking

IPV6 might be the future, but currently it’s not widely used. IPV6 addresses can be seen in the output of command ifconfig -a. On my system, I deactivated IPV6 to save overhead. If you want to, add these lines to the end of /etc/systemctl.conf and reboot:

# IPv6 disabled
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

Run ifconfig -a again and check those references are gone.

Putting /tmp into RAM

Converting /tmp to a memory based filesystem can have performance benefits. I would recommend it if your server has plenty of memory to spare, and particularly if your disk is the spinning type (ie. not SSD). It’s not a huge thing, but can be achieved like this:

Delete all the files under /tmp, then add this line to /etc/fstab:

tmpfs   /tmp    tmpfs   mode=1777,size=1G,nodev 0       0

… and reboot. Once booted, check the new status of /tmp:

$ df -h /tmp
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.0G   15M 1010M   2% /tmp

Notice /tmp is only 2% (15MB) used here. It can grow to a maximum of 1 GB, a limit that stops items in /tmp hogging memory.

Disable or Reconfigure Network Manager Connectivity Checking

By default, every 5 minutes, Network Manager tries to contact the endpoint http://connectivity-check.ubuntu.com, in order to determine if the system has Internet access or is (for example) behind a captive portal. However, the endpoint sometimes doesn’t respond, or does so slowly, potentially causing problems for programs like VMware. See my separate article on Network Connectivity Checks for more info.

Disable the connectivity check as follows. Note however that connecting to public wi-fi networks might subsequently become difficult. If you often connect to hotel or coffee shop wi-fi, don’t execute the following command. Instead see “Alternative Solutions” in the Network Connectivity Checks article.

sudo touch /etc/NetworkManager/conf.d/20-connectivity-ubuntu.conf


then reboot.

Reducing Boot Pause Time

By default, the grub menu will be displayed for up to 10 seconds every time the system boots. I shortened it to 3 seconds like this. Edit the file /etc/default/grub and change

GRUB_TIMEOUT=10

to:

GRUB_TIMEOUT=3

Save the file and rebuild the grub menu by typing:

$ sudo update-grub

…and reboot.


Removing mlocate/plocate

mlocate is a command line tool for finding files. It’s an alternative to the “find” command. plocate is a recent, faster improvement. Both use a database at /var/lib/mlocate/mlocate.db, which is maintained by “updatedb“, a process controlled by anacron that runs daily, 5 minutes after boot.

If you are not interested in using plocate/mlocate, it can be removed as below, removing a small amount of overhead, like that daily job.

The configuration file /etc/updatedb.conf instructs mlocate to skip some file systems, including ecryptfs mount points and folders including /tmp. Skipping ecryptfs is presumably to stop encrypted file names being exposed to unauthorized users, or perhaps the updatedb job can’t read the files. Either way, if your home directory is encrypted in this way, it won’t be indexed or searchable by mlocate, making the tool fairly useless.

To remove mlocate/plocate and its database:

$ sudo apt-get purge locate plocate 

Removing Zeitgeist

Zeitgeist is a software framework that monitors and logs user activity. Other applications can read the data, for example Gnome Activity Journal. Web searches, sites visited, files opened, chats emails are among the stuff potentially stored. The database is located in $HOME/.local/share/zeitgeist.

Zeitgeist has been described as intrusive and a privacy issue. It isn’t necessarily so, given the data remains local and never leaves your PC. All the same, not everyone wants to be tracked, even with local storage and even if there is some convenience in browsing your own history.

Personally, I tried Gnome Activity Journal for a few weeks and wasn’t impressed. The interface was rather sparse and only seemed to show a few web searches. Opened files were missing, and there were many items marked “unknown”, or similar. I removed it for simplification, and for the slight benefit performance and boot time benefits.

To remove Zeitgeist:

First, kill the running zeitgeist deamons:

$ ps -elf | grep zeitgeist
0 S fred       1775    1561  0  80   0   00:00:00 zeitgeist-datahub
0 S fred       1793    1534  0  80   0   00:00:01 /usr/bin/zeitgeist-daemon
0 S fred       1816    1534  0  80   0   00:00:00 /usr/lib/zeitgeist/zeitgeist-fts
$
$ kill 1775 1793 1816

Remove and purge Zeitgeist packages:

$ sudo apt-get purge zeitgeist zeitgeist-core zeitgeist-datahub

Finally, remove the Zeitgeist database:

$ cd ~/.local/share
$ rm -r zeitgeist

Install Parcellite Clipboard Manager

The very handy paste buffer manager “clipit” has been discontinued in Mint 21. A good replacement is “parcellite“:

$ sudo apt-get install parcellite

The app runs in the system tray. Click it to recall previous contents of your paste buffer.

X applications like “xterm” use their own clipboard. Text you select in an xterm will not be available to paste into none X windows and vice-versa, and won’t appear in parcellite. If your an X user, install autocutsel. It runs in the background and merges the X and none X clipboard. Very handy. First install it:

$ sudo apt-get install autocutsel

To have autocutsel start automatically at login, add these lines to your ~/.profile file:

# Start autocutsel for clipboard merging
/usr/bin/autocutsel &

Note: Some alternative clipboard managers, such as diodon, are equally effective. However, they depend on, and install zeitgeist-core, which we just removed above. Parcellite, on the other hand, does not use zeitgeist, is lightweight and seems to work well.

Appendix: Disk Partitioning

Running and upgrading Linux can be much easier if your disk is partitioned appropriately. People sometimes “dual boot” their PCs with Windows and Linux both installed. At boot time, one or the other can be chosen through the simple grub menu. Taking the same idea a little further, two (or more) versions of Linux can be available. I would recommend the following partition layout, or something like it.

Have Your Home Directory on it’s own Partition.

Having your data separate from the OS makes it impervious to operating system installs and upgrades. Special backups or snapshots need not form part of the OS install/upgrade process. (Though regular backups should be taken, obviously).

The second advantage is that your settings will follow from one version of Linux Mint to another. Most of these are under “dot” folders in your home directory (eg. ~/.local). So if you have Mint 21 set up just so, Mint 22, when installed, will include your familiar settings and appearance.

Have Windows on it’s own Partition

If you but a new laptop with Windows, it’s partition can be shrunk, creating room for more partitions while still allowing Windows to function properly. For example, my laptop came with Windows installed on a 1 TB drive. I reduced the Windows partition to about 100 GB. Windows, which I don’t use much, remains functional and has moderate space for more programs to be installed.

Put Linux (say Mint 21) on a Third Partition

The first installation of Linux (Mint) can go in another partition, sized at (say) about 30 GB.

Have Another Version of Linux (Mint) on a Fourth Partition

Create another partition, the same size as the third. Again 30 GB is ample for Mint.

This is where a second version of Linux can be installed. It will become your next, or previous version of Mint (or your preferred distro). When version 22 of Mint is launched (next year), put it here. Meanwhile version 21 will continue on it’s own partition, and GRUB will allow you to choose either version 21 or 22 at boot time. When version 23 is eventually released, install it over version 21, and so on, with successive versions.

In this way, two versions are always installed. You can always “roll back” to a previous version if you don’t like the new one or there is a technical problem.

Put Linux Swap on a Fifth Partition

Swap can be on a partition sized about the same as your RAM, or bigger if you have special memory requirements. If your disk is of the spinning type, put it near the OS partitions, ideally. On an SSD it probably doesn’t matter.

To create and adjust partitions, use parted, gparted or similar. Disk tools are available on Windows and Linux. For example, here is the layout of my 1 TB disk. X and Y are both 30 GB partitions, one containing Mint 20, currently, and the other Mint 21. The big area “sda9” is my home directory. Linux swap is the small partition at the far right (“s”)

w x y home s

Windows 10 is on there too, in the (50 GB) partition on the left, below the “w”. Any of the 3 operating systems can be booted.

The sizes above are for a 1 TB disk. If your disk is smaller or larger, change the size of the large area (/home) accordingly.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.