This show has been flagged as Clean by the host.
Setting up Linux Mint with Custom LVM and Luks
Linux Mint with Custom LVM on LUKS
Overview
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
Partition Layout
For this guide, I'm working with a 1TB drive that will be split into the following logical volumes:
Root - 100GB (system files and applications)Swap - 32GB (for hibernation support)Home - 700GB (user files and documents)Backup - 100GB (Timeshift snapshots)Unallocated - ~68GB (reserved for future expansion)This setup ensures that system snapshots and user data remain separate, making system recovery much easier.
Installation Guide
Step 1: Initial Linux Mint Installation
Start the Linux Mint installation process as normal:
Boot from your Linux Mint installation mediaFollow the installation wizard (language, keyboard layout, etc.)When you reach the Installation type screen: Select "Erase disk and install Linux Mint"Click "Advanced features"✓ Use LVM with the new Linux Mint installation✓ Encrypt the new Linux Mint installation for securityClick ContinueEnter a strong encryption password when promptedComplete the rest of the installation (timezone, user account, etc.)When installation finishes, do NOT click "Restart Now" - we'll repartition firstImportant: Do NOT reboot after installation completes. We need to repartition before the first boot.
Step 2: Access Root Terminal
After installation finishes, open a terminal and switch to root:
sudo -i
This gives you administrative privileges needed for disk operations.
Step 3: Check Current Disk Layout
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.
Step 4: Resize Root Partition
Shrink the root partition from its default size (nearly full disk) to 100GB:
lvresize -L 100G --resizefs vgmint/root
-L 100G sets the logical volume size to exactly 100GB--resizefs automatically resizes the filesystem to matchThis frees up ~900GB for our other partitionsStep 5: Resize Swap Partition
The 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
-L +32G adds 32GB to the current swap size--verbose shows detailed progress informationThis ensures enough swap space for RAM contents during hibernationNote: For hibernation to work, swap should be at least equal to your RAM size. Adjust accordingly.
Step 6: Create Home Partition
Create a new logical volume for your home directory:
lvcreate -L 700G vgmint -n home
-L 700G creates a 700GB logical volumevgmint is the volume group name-n home names the new volume "home"Step 7: Create Backup Partition
Create a logical volume for Timeshift backups:
lvcreate -L 100G vgmint -n backup
Creates a dedicated 100GB space for system snapshotsKeeps backups separate from user dataPrevents backups from filling up your home partitionStep 8: Format New Partitions
Format both new partitions with the ext4 filesystem:
mkfs.ext4 /dev/vgmint/backup
mkfs.ext4 /dev/vgmint/home
Creates ext4 filesystems on both logical volumesext4 is the standard Linux filesystem with good performance and reliabilityStep 9: Mount Partitions
Create mount points and mount your partitions:
mkdir /mnt/{root,home}
mount /dev/vgmint/root /mnt/root/
mount /dev/vgmint/home /mnt/home/
Creates temporary directories to access the filesystemsMounts root and home so we can configure themStep 10: Move Home Directory Contents
Move the existing home directory contents from the root partition to the new home partition:
mv /mnt/root/home/* /mnt/home/
Transfers all user files and directories from the old location to the new home partitionPreserves your user account settings and any files created during installationWithout this step, your home directory would be empty on first bootStep 11: Update fstab
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
Appends a mount entry to /etc/fstabEnsures /home partition mounts automatically at startupThe 0 2 values enable filesystem checks during bootStep 12: Clean Up and Prepare for Reboot
Unmount the partitions and deactivate the volume group:
umount /mnt/root
umount /mnt/home
swapoff -a
lvchange -an vgmint
Safely unmounts all mounted filesystemsTurns off swapDeactivates the volume group to prevent conflictsEnsures everything is properly closed before rebootStep 13: Reboot
Now you can safely reboot into your new system:
reboot
Enter your LUKS encryption password at boot, then log in normally.
Verification
After rebooting, verify your partition setup:
lsblk -f
df -h
Root (/) mounted with ~100GBHome (/home) mounted with ~700GBSwap available with 32GBBackup partition ready for Timeshift configurationSetting Up Timeshift
To complete your backup solution:
Install Timeshift (if not already installed): sudo apt install timeshiftLaunch Timeshift and select RSYNC modeChoose the backup partition as your snapshot locationConfigure your backup schedule (daily, weekly, monthly)Create your first snapshotAdditional Resources
Original blog post on LVM rearrangementSetting up hibernation on Linux MintConclusion
This 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
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.
Why Automate Your Setup?
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:
Time Savings: What normally takes hours can be done in minutesConsistency: Identical setup across all your machinesDocumentation: Your setup becomes self-documentingRecovery: Quick recovery from system failuresReproducibility: Never forget to install that one crucial tool againDiscovering Your Installed Applications
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.
Finding APT and .deb Packages
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)
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 setupThis helps you identify exactly what to include in your Ansible playbookTip: 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
Finding Flatpak Applications
To list all installed Flatpak applications:
flatpak list --app
Lists all Flatpak applications installed on your systemThe --app flag filters out runtimes and shows only applicationsUse this list to populate the Flatpak section of your Ansible playbook# 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
Creating Your Package Inventory
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!
Overview of the Automation Strategy
This guide uses a three-part approach:
Ansible Playbook - Automates software installation and system configurationConfiguration Files - Backs up and restores application settings from .configdconf Backup - Preserves desktop environment settings (Cinnamon/GNOME)I store all configurations in a private repository to protect any sensitive information while keeping everything version-controlled and easily accessible.
Prerequisites
Before you begin, make sure you have:
A fresh Linux Mint installationTerminal accessAn internet connectionBasic familiarity with the command lineStep-by-Step Setup Process
Step 1: Update Your System
First things first—let's make sure your system is up to date:
sudo apt update
sudo apt upgrade -y
Updates the package index to get the latest package informationUpgrades all installed packages to their latest versionsThe -y flag automatically confirms all promptsStep 2: Install Ansible
Ansible 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
Adds the official Ansible Personal Package Archive (PPA)Refreshes package information to include Ansible packagesInstalls the latest version of AnsibleStep 3: Create Your Ansible Playbook
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:
hosts: localhost - Runs on your local machinebecome: true - Executes tasks with sudo privilegestasks - List of operations to performapt module - Installs packages from repositories or .deb filesapt_repository - Adds third-party repositoriesflatpak module - Installs Flatpak applicationsAdd more packages to the pkg list under "Install essential applications"Include additional .deb packages using the deb: parameterAdd more third-party repositories following the Tailscale exampleExtend with Flatpak apps, snap packages, or pip packages as neededStep 4: Run the Ansible Playbook
Navigate to the directory containing your localsetup.yml file and execute the playbook:
sudo ansible-playbook localsetup.yml --connection=local
Executes all tasks defined in your playbookInstalls all specified software automaticallyConfigures repositories and signing keysRuns with local connection (no SSH required)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.
Step 5: Restore Configuration Files
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/
Application preferences and settingsCustom keyboard shortcutsEditor configurations (VS Code, Vim, etc.)Terminal emulator settingsAny other application-specific configurationsTip: 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 configurationStep 6: Import Desktop Environment Settings
Restore your Cinnamon/GNOME desktop environment settings using dconf. This includes themes, panels, applets, and all desktop preferences.
Creating a dconf Backup (do this on your working system first):
# Export all settings
dconf dump / > my_dconf_backup.conf
# Or export specific paths
dconf dump /org/cinnamon/ > cinnamon_settings.conf
Restoring dconf Settings:
# Navigate to your dconf backup location
cd /path/to/your/backups/dconf
# Restore all settings
dconf load / < my_dconf_backup.conf
Desktop themes and appearancePanel configuration and appletsKeyboard shortcutsWindow manager preferencesDisplay settingsPower management settingsAll other desktop environment preferencesNote: You may need to log out and log back in for all changes to take effect.
Advanced Tips and Best Practices
Maintaining Your Automation Setup
Version Control: Keep your playbook and configs in a Git repositoryRegular Updates: Update your backup after making configuration changesTest on VMs: Test your automation on a virtual machine before using on productionDocument Changes: Add comments to your playbook explaining custom configurationsSecuring Sensitive Information
Use Ansible Vault to encrypt sensitive data in your playbooksNever commit SSH private keys or passwords to repositoriesUse environment variables for sensitive configuration valuesKeep your configuration repository privateExtending Your Automation
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: '[email protected]' }
Troubleshooting
Common Issues
Ansible not found after installation:
# Verify installation
ansible --version
# If not found, check PATH
echo $PATH
Permission denied errors:
Ensure you're running the playbook with sudoCheck file permissions on your playbook: chmod 644 localsetup.ymlRun sudo apt update before running the playbookCheck for PPA conflicts: sudo apt-cache policy dconf restore doesn't seem to work:
Log out and log back in after restoringVerify the backup file format: head my_dconf_backup.confTry restoring specific paths instead of all settingsConclusion
Automating 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.
Additional Resources
Ansible Documentationdconf ManualLinux Mint DocumentationDotfiles ManagementNext Steps
Customize the playbook with your preferred applicationsCreate backups of your current configuration filesExport your current dconf settingsTest your automation on a virtual machineSet up a private Git repository for your configurationsProvide feedback on this episode.