This show has been flagged as Clean by the host.
Setting up Linux Mint with Custom LVM and Luks
The current Linux Mint installer doesn't support custom partitions when setting up a new machine with LUKS encryption using LVM. I prefer having a separate partition for my home directory and a backup partition for Timeshift, so that reinstalling or fixing issues won't overwrite my home directory.
I found several approaches to achieve this. One method involves setting up partitions first and then using the installer to select them, but this requires extensive post-installation configuration to get boot working with the encrypted drive.
I discovered this blog which explains how to repartition your drive after installation. Combined with my guide on setting up hibernation, I created this documentation to help remember how to install a fresh copy of Linux Mint with LVM and LUKS.
Tested on: Linux Mint 22 Cinnamon
For this guide, I'm working with a 1TB drive that will be split into the following logical volumes:
This setup ensures that system snapshots and user data remain separate, making system recovery much easier.
Start the Linux Mint installation process as normal:
Important: Do NOT reboot after installation completes. We need to repartition before the first boot.
After installation finishes, open a terminal and switch to root:
sudo -i
This gives you administrative privileges needed for disk operations.
View your current partition structure:
lsblk -f
This displays your filesystem layout. You should see your encrypted volume group (typically vgmint) with a large root partition consuming most of the space.
Shrink the root partition from its default size (nearly full disk) to 100GB:
lvresize -L 100G --resizefs vgmint/root
What this does:
-L 100G sets the logical volume size to exactly 100GB--resizefs automatically resizes the filesystem to matchThe default swap is usually small (a few GB). We need to increase it to 32GB for hibernation:
lvresize --verbose -L +32G /dev/mapper/vgmint-swap_1
What this does:
-L +32G adds 32GB to the current swap size--verbose shows detailed progress informationNote: For hibernation to work, swap should be at least equal to your RAM size. Adjust accordingly.
Create a new logical volume for your home directory:
lvcreate -L 700G vgmint -n home
What this does:
-L 700G creates a 700GB logical volumevgmint is the volume group name-n home names the new volume "home"Create a logical volume for Timeshift backups:
lvcreate -L 100G vgmint -n backup
What this does:
Format both new partitions with the ext4 filesystem:
mkfs.ext4 /dev/vgmint/backup
mkfs.ext4 /dev/vgmint/home
What this does:
Create mount points and mount your partitions:
mkdir /mnt/{root,home}
mount /dev/vgmint/root /mnt/root/
mount /dev/vgmint/home /mnt/home/
What this does:
Move the existing home directory contents from the root partition to the new home partition:
mv /mnt/root/home/* /mnt/home/
What this does:
Add the home partition to the system's fstab file so it mounts automatically at boot:
echo "/dev/mapper/vgmint-home /home ext4 defaults 0 2" >> /mnt/root/etc/fstab
What this does:
/etc/fstab/home partition mounts automatically at startup0 2 values enable filesystem checks during bootUnmount the partitions and deactivate the volume group:
umount /mnt/root
umount /mnt/home
swapoff -a
lvchange -an vgmint
What this does:
Now you can safely reboot into your new system:
reboot
Enter your LUKS encryption password at boot, then log in normally.
After rebooting, verify your partition setup:
lsblk -f
df -h
You should see:
/) mounted with ~100GB/home) mounted with ~700GBTo complete your backup solution:
sudo apt install timeshiftThis setup gives you the best of both worlds: the security of full-disk encryption with LUKS, and the flexibility of custom LVM partitions. Your home directory and system backups are now isolated, making system recovery and upgrades much safer and more manageable.
Automating Your Linux Mint Setup After a Fresh Install
Setting up a fresh Linux Mint installation can be time-consuming, especially when you want to replicate your perfect development environment. This guide will show you how to automate the entire process using Ansible and configuration backups, so you can go from a fresh install to a fully configured system in minutes.
Whether you're setting up a new machine, recovering from a system failure, or just want to maintain consistency across multiple computers, automation offers several key benefits:
Before creating your automation setup, you need to identify which applications you've manually installed since the initial OS installation. This helps you build a complete picture of your custom environment.
To see all manually installed packages (excluding those that came with the OS):
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u)
What this does:
apt-mark showmanual lists all manually installed packages/var/log/installer/initial-status.gz contains packages from the initial installationcomm -23 compares the two lists and shows only packages you installed after setupTip: Save this output to a file for reference:
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u) > manually-installed-packages.txt
To list all installed Flatpak applications:
flatpak list --app
What this does:
--app flag filters out runtimes and shows only applicationsGetting more details:
# Show application IDs (needed for Ansible)
flatpak list --app --columns=application
# Show with origin (where it was installed from)
flatpak list --app --columns=application,origin
Use these commands to build a comprehensive inventory:
# Create a directory for your automation files
mkdir -p ~/linux-mint-automation
# Save APT packages
comm -23 <(apt-mark showmanual | sort -u) <(gzip -dc /var/log/installer/initial-status.gz | sed -n 's/^Package: //p' | sort -u) > ~/linux-mint-automation/apt-packages.txt
# Save Flatpak apps
flatpak list --app --columns=application > ~/linux-mint-automation/flatpak-apps.txt
Now you have a clear reference of what needs to be included in your automation setup!
This guide uses a three-part approach:
.configI store all configurations in a private repository to protect any sensitive information while keeping everything version-controlled and easily accessible.
Before you begin, make sure you have:
First things first—let's make sure your system is up to date:
sudo apt update
sudo apt upgrade -y
What this does:
-y flag automatically confirms all promptsAnsible is a powerful automation tool that will handle the bulk of our software installation. Add the official Ansible PPA and install it:
sudo apt-add-repository ppa:ansible/ansible
sudo apt update
sudo apt install ansible
What this does:
Create an Ansible playbook that defines your entire system configuration. This YAML file will automate software installation from multiple sources.
Create a file named localsetup.yml:
- hosts: localhost
become: true
vars:
# Add any variables here (URLs, versions, etc.)
tasks:
# Install prerequisites
- name: Install prerequisites for Ansible to install .deb via apt module
apt:
name:
- xz-utils
state: present
- name: Ensure wget and gpg are installed
apt:
name:
- wget
- gpg
state: present
# Install applications from .deb packages
- name: Install Google Chrome
apt:
deb: https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
# Add third-party repositories
- name: Add signing key for Tailscale
get_url:
url: https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg
dest: /usr/share/keyrings/tailscale.gpg
mode: '0644'
- name: Add Tailscale repository
apt_repository:
repo: "deb [signed-by=/usr/share/keyrings/tailscale.gpg] https://pkgs.tailscale.com/stable/ubuntu jammy main"
filename: tailscale
state: present
- name: Update package cache after adding repositories
ansible.builtin.apt:
update_cache: yes
# Install standard packages from Ubuntu/Mint repositories
- name: Install essential applications
apt:
pkg:
- tailscale
- git
- diodon # Clipboard manager
- pavucontrol # PulseAudio volume control
- guake # Drop-down terminal
- vim
- curl
- htop
state: present
# Install Flatpak applications
- name: Install Flatpak applications
community.general.flatpak:
name:
- org.gimp.GIMP
- org.inkscape.Inkscape
state: present
Understanding the playbook structure:
Customization tips:
pkg list under "Install essential applications".deb packages using the deb: parameterNavigate to the directory containing your localsetup.yml file and execute the playbook:
sudo ansible-playbook localsetup.yml --connection=local
What this does:
Note: This may take several minutes to complete, depending on your internet connection and the number of packages being installed. You'll see progress output for each task.
Application settings are typically stored in the ~/.config directory. If you have a backup of your configuration files, restore them:
# Clone your private configuration repository
git clone https://github.com/yourusername/your-config-repo.git
cd your-config-repo
# Copy configuration files to your home directory
cp -r .config/* ~/.config/
What this restores:
Tip: Press Ctrl + H in your file manager to show hidden files and folders (those starting with .).
Important configurations to backup:
~/.config/ - Most modern application settings~/.bashrc or ~/.zshrc - Shell configuration~/.gitconfig - Git configurationRestore your Cinnamon/GNOME desktop environment settings using dconf. This includes themes, panels, applets, and all desktop preferences.
# Export all settings
dconf dump / > my_dconf_backup.conf
# Or export specific paths
dconf dump /org/cinnamon/ > cinnamon_settings.conf
# Navigate to your dconf backup location
cd /path/to/your/backups/dconf
# Restore all settings
dconf load / < my_dconf_backup.conf
What this restores:
Note: You may need to log out and log back in for all changes to take effect.
You can extend this setup to include:
# Install development tools
- name: Install development tools
apt:
pkg:
- build-essential
- docker.io
- python3-pip
- nodejs
- npm
# Install VS Code
- name: Add VS Code repository key
apt_key:
url: "https://packages.microsoft.com/keys/microsoft.asc"
state: present
- name: Add VS Code repository
apt_repository:
repo: "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
filename: vscode
state: present
- name: Install VS Code
apt:
name: code
state: present
# Configure git
- name: Configure git user
community.general.git_config:
name: "{{ item.name }}"
value: "{{ item.value }}"
scope: global
loop:
- { name: 'user.name', value: 'Your Name' }
- { name: 'user.email', value: 'your.email@example.com' }
Ansible not found after installation:
# Verify installation
ansible --version
# If not found, check PATH
echo $PATH
Permission denied errors:
sudochmod 644 localsetup.ymlPackage conflicts:
sudo apt update before running the playbooksudo apt-cache policy <package-name>dconf restore doesn't seem to work:
head my_dconf_backup.confAutomating your Linux Mint setup transforms a tedious manual process into a quick, repeatable procedure. With Ansible handling software installation, configuration file backups preserving application settings, and dconf managing desktop preferences, you can rebuild your perfect development environment in minutes rather than hours.
The time invested in creating these automation scripts pays dividends every time you set up a new machine, recover from a failure, or help a colleague replicate your environment.
Unless otherwise stated, our shows are released under a Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license.
The HPR Website Design is released to the Public Domain.