hpr4524 :: Living the Tux Life Episode 3 - Automating the Install
How i automate my mint os install

Hosted by Al on Thursday, 2025-12-04 is flagged as Clean and is released under a CC-BY-SA license.
linux.
(Be the first).
Listen in ogg,
opus,
or mp3 format. Play now:
Duration: 00:06:16
Download the transcription and
subtitles.
general.
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 media
- Follow the installation wizard (language, keyboard layout, etc.)
- When you reach the Installation type screen:
- Select "Erase disk and install Linux Mint"
- Click "Advanced features"
- Enable both options:
- ✓ Use LVM with the new Linux Mint installation
- ✓ Encrypt the new Linux Mint installation for security
- Click Continue
- Enter a strong encryption password when prompted
- Complete the rest of the installation (timezone, user account, etc.)
- When installation finishes, do NOT click "Restart Now" - we'll repartition first
Important: 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
What this does:
-L 100Gsets the logical volume size to exactly 100GB--resizefsautomatically resizes the filesystem to match- This frees up ~900GB for our other partitions
Step 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
What this does:
-L +32Gadds 32GB to the current swap size--verboseshows detailed progress information- This ensures enough swap space for RAM contents during hibernation
Note: 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
What this does:
-L 700Gcreates a 700GB logical volumevgmintis the volume group name-n homenames the new volume "home"
Step 7: Create Backup Partition
Create a logical volume for Timeshift backups:
lvcreate -L 100G vgmint -n backup
What this does:
- Creates a dedicated 100GB space for system snapshots
- Keeps backups separate from user data
- Prevents backups from filling up your home partition
Step 8: Format New Partitions
Format both new partitions with the ext4 filesystem:
mkfs.ext4 /dev/vgmint/backup
mkfs.ext4 /dev/vgmint/home
What this does:
- Creates ext4 filesystems on both logical volumes
- ext4 is the standard Linux filesystem with good performance and reliability
Step 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/
What this does:
- Creates temporary directories to access the filesystems
- Mounts root and home so we can configure them
Step 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/
What this does:
- Transfers all user files and directories from the old location to the new home partition
- Preserves your user account settings and any files created during installation
- Without this step, your home directory would be empty on first boot
Step 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
What this does:
- Appends a mount entry to
/etc/fstab - Ensures
/homepartition mounts automatically at startup - The
0 2values enable filesystem checks during boot
Step 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
What this does:
- Safely unmounts all mounted filesystems
- Turns off swap
- Deactivates the volume group to prevent conflicts
- Ensures everything is properly closed before reboot
Step 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
You should see:
- Root (
/) mounted with ~100GB - Home (
/home) mounted with ~700GB - Swap available with 32GB
- Backup partition ready for Timeshift configuration
Setting Up Timeshift
To complete your backup solution:
- Install Timeshift (if not already installed):
sudo apt install timeshift - Launch Timeshift and select RSYNC mode
- Choose the backup partition as your snapshot location
- Configure your backup schedule (daily, weekly, monthly)
- Create your first snapshot
Additional Resources
Conclusion
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 minutes
- Consistency: Identical setup across all your machines
- Documentation: Your setup becomes self-documenting
- Recovery: Quick recovery from system failures
- Reproducibility: Never forget to install that one crucial tool again
Discovering 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)
What this does:
apt-mark showmanuallists all manually installed packages/var/log/installer/initial-status.gzcontains packages from the initial installationcomm -23compares the two lists and shows only packages you installed after setup- This helps you identify exactly what to include in your Ansible playbook
Tip: 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
What this does:
- Lists all Flatpak applications installed on your system
- The
--appflag filters out runtimes and shows only applications - Use this list to populate the Flatpak section of your Ansible playbook
Getting 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
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 configuration
- Configuration Files - Backs up and restores application settings from
.config - dconf 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 installation
- Terminal access
- An internet connection
- Basic familiarity with the command line
Step-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
What this does:
- Updates the package index to get the latest package information
- Upgrades all installed packages to their latest versions
- The
-yflag automatically confirms all prompts
Step 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
What this does:
- Adds the official Ansible Personal Package Archive (PPA)
- Refreshes package information to include Ansible packages
- Installs the latest version of Ansible
Step 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 machine
- become: true - Executes tasks with sudo privileges
- tasks - List of operations to perform
- apt module - Installs packages from repositories or .deb files
- apt_repository - Adds third-party repositories
- flatpak module - Installs Flatpak applications
Customization tips:
- Add more packages to the
pkglist under "Install essential applications" - Include additional
.debpackages using thedeb:parameter - Add more third-party repositories following the Tailscale example
- Extend with Flatpak apps, snap packages, or pip packages as needed
Step 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
What this does:
- Executes all tasks defined in your playbook
- Installs all specified software automatically
- Configures repositories and signing keys
- Runs 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/
What this restores:
- Application preferences and settings
- Custom keyboard shortcuts
- Editor configurations (VS Code, Vim, etc.)
- Terminal emulator settings
- Any other application-specific configurations
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~/.bashrcor~/.zshrc- Shell configuration~/.gitconfig- Git configuration
Step 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
What this restores:
- Desktop themes and appearance
- Panel configuration and applets
- Keyboard shortcuts
- Window manager preferences
- Display settings
- Power management settings
- All other desktop environment preferences
Note: 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 repository
- Regular Updates: Update your backup after making configuration changes
- Test on VMs: Test your automation on a virtual machine before using on production
- Document Changes: Add comments to your playbook explaining custom configurations
Securing Sensitive Information
- Use Ansible Vault to encrypt sensitive data in your playbooks
- Never commit SSH private keys or passwords to repositories
- Use environment variables for sensitive configuration values
- Keep your configuration repository private
Extending 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: 'your.email@example.com' }
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
sudo - Check file permissions on your playbook:
chmod 644 localsetup.yml
Package conflicts:
- Run
sudo apt updatebefore running the playbook - Check for PPA conflicts:
sudo apt-cache policy <package-name>
dconf restore doesn't seem to work:
- Log out and log back in after restoring
- Verify the backup file format:
head my_dconf_backup.conf - Try restoring specific paths instead of all settings
Conclusion
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
Next Steps
- Customize the playbook with your preferred applications
- Create backups of your current configuration files
- Export your current dconf settings
- Test your automation on a virtual machine
- Set up a private Git repository for your configurations