
<p>
<br>
</p>
<p>
<a href="https://code.christman.uk/Linux/linux%20-mint-with-custom-lvm-on-luks" rel="noopener noreferrer" target="_blank">
Setting up Linux Mint with Custom LVM and Luks</a>
</p>

<h1 id="linux-mint-with-custom-lvm-on-luks">Linux Mint with Custom LVM on LUKS</h1>
<h2 id="overview">Overview</h2>
<p>The current Linux Mint installer doesn&#39;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&#39;t overwrite my home directory. </p>
<p>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. </p>
<p>I discovered this <a href="https://www.dwarmstrong.org/rearrange-lvm-after-mint-install/">blog</a> 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.</p>
<p><strong>Tested on:</strong> Linux Mint 22 Cinnamon</p>
<h2 id="partition-layout">Partition Layout</h2>
<p>For this guide, I&#39;m working with a 1TB drive that will be split into the following logical volumes:</p>
<ul>
<li><strong>Root</strong> - 100GB (system files and applications)</li>
<li><strong>Swap</strong> - 32GB (for hibernation support)</li>
<li><strong>Home</strong> - 700GB (user files and documents)</li>
<li><strong>Backup</strong> - 100GB (Timeshift snapshots)</li>
<li><strong>Unallocated</strong> - ~68GB (reserved for future expansion)</li>
</ul>
<p>This setup ensures that system snapshots and user data remain separate, making system recovery much easier.</p>
<h2 id="installation-guide">Installation Guide</h2>
<h3 id="step-1-initial-linux-mint-installation">Step 1: Initial Linux Mint Installation</h3>
<p>Start the Linux Mint installation process as normal:</p>
<ol>
<li>Boot from your Linux Mint installation media</li>
<li>Follow the installation wizard (language, keyboard layout, etc.)</li>
<li>When you reach the <strong>Installation type</strong> screen:<ul>
<li>Select <strong>&quot;Erase disk and install Linux Mint&quot;</strong></li>
<li>Click <strong>&quot;Advanced features&quot;</strong></li>
<li>Enable both options:<ul>
<li>✓ <strong>Use LVM with the new Linux Mint installation</strong></li>
<li>✓ <strong>Encrypt the new Linux Mint installation for security</strong></li>
</ul>
</li>
<li>Click <strong>Continue</strong></li>
</ul>
</li>
<li>Enter a strong encryption password when prompted</li>
<li>Complete the rest of the installation (timezone, user account, etc.)</li>
<li>When installation finishes, <strong>do NOT click &quot;Restart Now&quot;</strong> - we&#39;ll repartition first</li>
</ol>
<p><strong>Important:</strong> Do NOT reboot after installation completes. We need to repartition before the first boot.</p>
<h3 id="step-2-access-root-terminal">Step 2: Access Root Terminal</h3>
<p>After installation finishes, open a terminal and switch to root:</p>
<pre><code class="lang-bash"><span class="hljs-attribute">sudo -i</span>
</code></pre>
<p>This gives you administrative privileges needed for disk operations.</p>
<h3 id="step-3-check-current-disk-layout">Step 3: Check Current Disk Layout</h3>
<p>View your current partition structure:</p>
<pre><code class="lang-bash">lsblk <span class="hljs-_">-f</span>
</code></pre>
<p>This displays your filesystem layout. You should see your encrypted volume group (typically <code>vgmint</code>) with a large root partition consuming most of the space.</p>
<h3 id="step-4-resize-root-partition">Step 4: Resize Root Partition</h3>
<p>Shrink the root partition from its default size (nearly full disk) to 100GB:</p>
<pre><code class="lang-bash">lvresize -L <span class="hljs-number">100</span>G <span class="hljs-comment">--resizefs vgmint/root</span>
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li><code>-L 100G</code> sets the logical volume size to exactly 100GB</li>
<li><code>--resizefs</code> automatically resizes the filesystem to match</li>
<li>This frees up ~900GB for our other partitions</li>
</ul>
<h3 id="step-5-resize-swap-partition">Step 5: Resize Swap Partition</h3>
<p>The default swap is usually small (a few GB). We need to increase it to 32GB for hibernation:</p>
<pre><code class="lang-bash">lvresize <span class="hljs-comment">--verbose -L +32G /dev/mapper/vgmint-swap_1</span>
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li><code>-L +32G</code> adds 32GB to the current swap size</li>
<li><code>--verbose</code> shows detailed progress information</li>
<li>This ensures enough swap space for RAM contents during hibernation</li>
</ul>
<p><strong>Note:</strong> For hibernation to work, swap should be at least equal to your RAM size. Adjust accordingly.</p>
<h3 id="step-6-create-home-partition">Step 6: Create Home Partition</h3>
<p>Create a new logical volume for your home directory:</p>
<pre><code class="lang-bash">lvcreate -L <span class="hljs-number">700</span>G vgmint -n <span class="hljs-built_in">home</span>
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li><code>-L 700G</code> creates a 700GB logical volume</li>
<li><code>vgmint</code> is the volume group name</li>
<li><code>-n home</code> names the new volume &quot;home&quot;</li>
</ul>
<h3 id="step-7-create-backup-partition">Step 7: Create Backup Partition</h3>
<p>Create a logical volume for Timeshift backups:</p>
<pre><code class="lang-bash">lvcreate -L <span class="hljs-number">100</span>G vgmint -<span class="hljs-built_in">n</span> backup
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Creates a dedicated 100GB space for system snapshots</li>
<li>Keeps backups separate from user data</li>
<li>Prevents backups from filling up your home partition</li>
</ul>
<h3 id="step-8-format-new-partitions">Step 8: Format New Partitions</h3>
<p>Format both new partitions with the ext4 filesystem:</p>
<pre><code class="lang-bash">mkfs<span class="hljs-selector-class">.ext4</span> /dev/vgmint/backup
mkfs<span class="hljs-selector-class">.ext4</span> /dev/vgmint/home
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Creates ext4 filesystems on both logical volumes</li>
<li>ext4 is the standard Linux filesystem with good performance and reliability</li>
</ul>
<h3 id="step-9-mount-partitions">Step 9: Mount Partitions</h3>
<p>Create mount points and mount your partitions:</p>
<pre><code class="lang-bash">mkdir <span class="hljs-regexp">/mnt/</span>{root,home}
mount <span class="hljs-regexp">/dev/</span>vgmint<span class="hljs-regexp">/root /m</span>nt<span class="hljs-regexp">/root/</span>
mount <span class="hljs-regexp">/dev/</span>vgmint<span class="hljs-regexp">/home /m</span>nt<span class="hljs-regexp">/home/</span>
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Creates temporary directories to access the filesystems</li>
<li>Mounts root and home so we can configure them</li>
</ul>
<h3 id="step-10-move-home-directory-contents">Step 10: Move Home Directory Contents</h3>
<p>Move the existing home directory contents from the root partition to the new home partition:</p>
<pre><code class="lang-bash">mv <span class="hljs-regexp">/mnt/</span>root<span class="hljs-regexp">/home/</span>* <span class="hljs-regexp">/mnt/</span>home<span class="hljs-regexp">/</span>
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Transfers all user files and directories from the old location to the new home partition</li>
<li>Preserves your user account settings and any files created during installation</li>
<li>Without this step, your home directory would be empty on first boot</li>
</ul>
<h3 id="step-11-update-fstab">Step 11: Update fstab</h3>
<p>Add the home partition to the system&#39;s fstab file so it mounts automatically at boot:</p>
<pre><code class="lang-bash">echo <span class="hljs-string">"/dev/mapper/vgmint-home /home           ext4    defaults        0 2"</span> &gt;&gt; <span class="hljs-regexp">/mnt/</span>root<span class="hljs-regexp">/etc/</span>fstab
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Appends a mount entry to <code>/etc/fstab</code></li>
<li>Ensures <code>/home</code> partition mounts automatically at startup</li>
<li>The <code>0 2</code> values enable filesystem checks during boot</li>
</ul>
<h3 id="step-12-clean-up-and-prepare-for-reboot">Step 12: Clean Up and Prepare for Reboot</h3>
<p>Unmount the partitions and deactivate the volume group:</p>
<pre><code class="lang-bash">umount <span class="hljs-regexp">/mnt/</span>root
umount <span class="hljs-regexp">/mnt/</span>home
swapoff -a
lvchange -an vgmint
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Safely unmounts all mounted filesystems</li>
<li>Turns off swap</li>
<li>Deactivates the volume group to prevent conflicts</li>
<li>Ensures everything is properly closed before reboot</li>
</ul>
<h3 id="step-13-reboot">Step 13: Reboot</h3>
<p>Now you can safely reboot into your new system:</p>
<pre><code class="lang-bash"><span class="hljs-attribute">reboot</span>
</code></pre>
<p>Enter your LUKS encryption password at boot, then log in normally.</p>
<h2 id="verification">Verification</h2>
<p>After rebooting, verify your partition setup:</p>
<pre><code class="lang-bash">lsblk -<span class="hljs-built_in">f</span>
df -<span class="hljs-built_in">h</span>
</code></pre>
<p>You should see:</p>
<ul>
<li>Root (<code>/</code>) mounted with ~100GB</li>
<li>Home (<code>/home</code>) mounted with ~700GB</li>
<li>Swap available with 32GB</li>
<li>Backup partition ready for Timeshift configuration</li>
</ul>
<h2 id="setting-up-timeshift">Setting Up Timeshift</h2>
<p>To complete your backup solution:</p>
<ol>
<li>Install Timeshift (if not already installed): <code>sudo apt install timeshift</code></li>
<li>Launch Timeshift and select RSYNC mode</li>
<li>Choose the backup partition as your snapshot location</li>
<li>Configure your backup schedule (daily, weekly, monthly)</li>
<li>Create your first snapshot</li>
</ol>
<h2 id="additional-resources">Additional Resources</h2>
<ul>
<li><a href="https://www.dwarmstrong.org/rearrange-lvm-after-mint-install/">Original blog post on LVM rearrangement</a></li>
<li><a href="./setting-up-hibernation-linux-mint.md">Setting up hibernation on Linux Mint</a></li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>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.</p>

<hr>


<p>
<br>
</p>
<p>
<a href="https://code.christman.uk/Linux/auto-setup-linuxmint-after-fresh-install" rel="noopener noreferrer" target="_blank">
Automating Your Linux Mint Setup After a Fresh Install</a>
</p>

<h1 id="automating-your-linux-mint-setup-after-a-fresh-install">Automating Your Linux Mint Setup After a Fresh Install</h1>
<p>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.</p>
<h2 id="why-automate-your-setup-">Why Automate Your Setup?</h2>
<p>Whether you&#39;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:</p>
<ul>
<li><strong>Time Savings:</strong> What normally takes hours can be done in minutes</li>
<li><strong>Consistency:</strong> Identical setup across all your machines</li>
<li><strong>Documentation:</strong> Your setup becomes self-documenting</li>
<li><strong>Recovery:</strong> Quick recovery from system failures</li>
<li><strong>Reproducibility:</strong> Never forget to install that one crucial tool again</li>
</ul>
<h2 id="discovering-your-installed-applications">Discovering Your Installed Applications</h2>
<p>Before creating your automation setup, you need to identify which applications you&#39;ve manually installed since the initial OS installation. This helps you build a complete picture of your custom environment.</p>
<h3 id="finding-apt-and-deb-packages">Finding APT and .deb Packages</h3>
<p>To see all manually installed packages (excluding those that came with the OS):</p>
<pre><code class="lang-bash">comm -<span class="hljs-number">23</span> &lt;(apt-mark showmanual | <span class="hljs-keyword">sort</span> -u) &lt;(gzip -dc <span class="hljs-regexp">/var/</span>log<span class="hljs-regexp">/installer/i</span>nitial-status.gz | sed -n <span class="hljs-string">'s/^Package: //p'</span> | <span class="hljs-keyword">sort</span> -u)
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li><code>apt-mark showmanual</code> lists all manually installed packages</li>
<li><code>/var/log/installer/initial-status.gz</code> contains packages from the initial installation</li>
<li><code>comm -23</code> compares the two lists and shows only packages you installed after setup</li>
<li>This helps you identify exactly what to include in your Ansible playbook</li>
</ul>
<p><strong>Tip:</strong> Save this output to a file for reference:</p>
<pre><code class="lang-bash">comm -<span class="hljs-number">23</span> &lt;(apt-mark showmanual | <span class="hljs-keyword">sort</span> -u) &lt;(gzip -dc <span class="hljs-regexp">/var/</span>log<span class="hljs-regexp">/installer/i</span>nitial-status.gz | sed -n <span class="hljs-string">'s/^Package: //p'</span> | <span class="hljs-keyword">sort</span> -u) &gt; manually-installed-packages.txt
</code></pre>
<h3 id="finding-flatpak-applications">Finding Flatpak Applications</h3>
<p>To list all installed Flatpak applications:</p>
<pre><code class="lang-bash">flatpak <span class="hljs-built_in">list</span> <span class="hljs-comment">--app</span>
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Lists all Flatpak applications installed on your system</li>
<li>The <code>--app</code> flag filters out runtimes and shows only applications</li>
<li>Use this list to populate the Flatpak section of your Ansible playbook</li>
</ul>
<p><strong>Getting more details:</strong></p>
<pre><code class="lang-bash"><span class="hljs-comment"># Show application IDs (needed for Ansible)</span>
flatpak <span class="hljs-built_in">list</span> <span class="hljs-comment">--app --columns=application</span>

<span class="hljs-comment"># Show with origin (where it was installed from)</span>
flatpak <span class="hljs-built_in">list</span> <span class="hljs-comment">--app --columns=application,origin</span>
</code></pre>
<h3 id="creating-your-package-inventory">Creating Your Package Inventory</h3>
<p>Use these commands to build a comprehensive inventory:</p>
<pre><code class="lang-bash"># Create a directory <span class="hljs-keyword">for</span> your automation files
<span class="hljs-keyword">mkdir</span> -p ~/linux-mint-automation

# <span class="hljs-keyword">Save</span> APT packages
comm -23 &lt;(apt-<span class="hljs-keyword">mark</span> showmanual | <span class="hljs-keyword">sort</span> -<span class="hljs-keyword">u</span>) &lt;(gzip -dc /<span class="hljs-keyword">var</span>/<span class="hljs-keyword">log</span>/installer/initial-status.gz | sed -<span class="hljs-keyword">n</span> 's/^Package: <span class="hljs-comment">//p' | sort -u) &gt; ~/linux-mint-automation/apt-packages.txt</span>

# <span class="hljs-keyword">Save</span> Flatpak apps
flatpak <span class="hljs-keyword">list</span> --<span class="hljs-keyword">app</span> --columns=application &gt; ~/linux-mint-automation/flatpak-apps.txt
</code></pre>
<p>Now you have a clear reference of what needs to be included in your automation setup!</p>
<h2 id="overview-of-the-automation-strategy">Overview of the Automation Strategy</h2>
<p>This guide uses a three-part approach:</p>
<ol>
<li><strong>Ansible Playbook</strong> - Automates software installation and system configuration</li>
<li><strong>Configuration Files</strong> - Backs up and restores application settings from <code>.config</code></li>
<li><strong>dconf Backup</strong> - Preserves desktop environment settings (Cinnamon/GNOME)</li>
</ol>
<p>I store all configurations in a private repository to protect any sensitive information while keeping everything version-controlled and easily accessible.</p>
<h2 id="prerequisites">Prerequisites</h2>
<p>Before you begin, make sure you have:</p>
<ul>
<li>A fresh Linux Mint installation</li>
<li>Terminal access</li>
<li>An internet connection</li>
<li>Basic familiarity with the command line</li>
</ul>
<h2 id="step-by-step-setup-process">Step-by-Step Setup Process</h2>
<h3 id="step-1-update-your-system">Step 1: Update Your System</h3>
<p>First things first—let&#39;s make sure your system is up to date:</p>
<pre><code class="lang-bash">sudo apt <span class="hljs-keyword">update</span>
sudo apt <span class="hljs-keyword">upgrade</span> -y
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Updates the package index to get the latest package information</li>
<li>Upgrades all installed packages to their latest versions</li>
<li>The <code>-y</code> flag automatically confirms all prompts</li>
</ul>
<h3 id="step-2-install-ansible">Step 2: Install Ansible</h3>
<p>Ansible is a powerful automation tool that will handle the bulk of our software installation. Add the official Ansible PPA and install it:</p>
<pre><code class="lang-bash">sudo apt-<span class="hljs-built_in">add</span>-repository <span class="hljs-keyword">pp</span><span class="hljs-variable">a:ansible</span>/ansible
sudo apt <span class="hljs-keyword">update</span>
sudo apt install ansible
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Adds the official Ansible Personal Package Archive (PPA)</li>
<li>Refreshes package information to include Ansible packages</li>
<li>Installs the latest version of Ansible</li>
</ul>
<h3 id="step-3-create-your-ansible-playbook">Step 3: Create Your Ansible Playbook</h3>
<p>Create an Ansible playbook that defines your entire system configuration. This YAML file will automate software installation from multiple sources.</p>
<p>Create a file named <code>localsetup.yml</code>:</p>
<pre><code class="lang-yaml">-<span class="ruby"> <span class="hljs-symbol">hosts:</span> localhost
</span>  become: true

  vars:
    # Add any variables here (URLs, versions, etc.)

  tasks:
    # Install prerequisites
    -<span class="ruby"> <span class="hljs-symbol">name:</span> Install prerequisites <span class="hljs-keyword">for</span> Ansible to install .deb via apt <span class="hljs-class"><span class="hljs-keyword">module</span></span>
</span>      apt:
        name:
          -<span class="ruby"> xz-utils
</span>        state: present

    -<span class="ruby"> <span class="hljs-symbol">name:</span> Ensure wget <span class="hljs-keyword">and</span> gpg are installed
</span>      apt:
        name:
          -<span class="ruby"> wget
</span>          -<span class="ruby"> gpg
</span>        state: present

    # Install applications from .deb packages
    -<span class="ruby"> <span class="hljs-symbol">name:</span> Install Google Chrome
</span>      apt:
        deb: https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

    # Add third-party repositories
    -<span class="ruby"> <span class="hljs-symbol">name:</span> Add signing key <span class="hljs-keyword">for</span> Tailscale
</span>      get_url:
        url: https://pkgs.tailscale.com/stable/ubuntu/jammy.noarmor.gpg
        dest: /usr/share/keyrings/tailscale.gpg
        mode: '0644'

    -<span class="ruby"> <span class="hljs-symbol">name:</span> Add Tailscale repository
</span>      apt_repository:
        repo: "deb [signed-by=/usr/share/keyrings/tailscale.gpg] https://pkgs.tailscale.com/stable/ubuntu jammy main"
        filename: tailscale
        state: present

    -<span class="ruby"> <span class="hljs-symbol">name:</span> Update package cache after adding repositories
</span>      ansible.builtin.apt:
        update_cache: yes

    # Install standard packages from Ubuntu/Mint repositories
    -<span class="ruby"> <span class="hljs-symbol">name:</span> Install essential applications
</span>      apt:
        pkg:
          -<span class="ruby"> tailscale
</span>          -<span class="ruby"> git
</span>          -<span class="ruby"> diodon          <span class="hljs-comment"># Clipboard manager</span>
</span>          -<span class="ruby"> pavucontrol     <span class="hljs-comment"># PulseAudio volume control</span>
</span>          -<span class="ruby"> guake           <span class="hljs-comment"># Drop-down terminal</span>
</span>          -<span class="ruby"> vim
</span>          -<span class="ruby"> curl
</span>          -<span class="ruby"> htop
</span>        state: present

    # Install Flatpak applications
    -<span class="ruby"> <span class="hljs-symbol">name:</span> Install Flatpak applications
</span>      community.general.flatpak:
        name:
          -<span class="ruby"> org.gimp.GIMP
</span>          -<span class="ruby"> org.inkscape.Inkscape
</span>        state: present
</code></pre>
<p><strong>Understanding the playbook structure:</strong></p>
<ul>
<li><strong>hosts: localhost</strong> - Runs on your local machine</li>
<li><strong>become: true</strong> - Executes tasks with sudo privileges</li>
<li><strong>tasks</strong> - List of operations to perform</li>
<li><strong>apt module</strong> - Installs packages from repositories or .deb files</li>
<li><strong>apt_repository</strong> - Adds third-party repositories</li>
<li><strong>flatpak module</strong> - Installs Flatpak applications</li>
</ul>
<p><strong>Customization tips:</strong></p>
<ul>
<li>Add more packages to the <code>pkg</code> list under &quot;Install essential applications&quot;</li>
<li>Include additional <code>.deb</code> packages using the <code>deb:</code> parameter</li>
<li>Add more third-party repositories following the Tailscale example</li>
<li>Extend with Flatpak apps, snap packages, or pip packages as needed</li>
</ul>
<h3 id="step-4-run-the-ansible-playbook">Step 4: Run the Ansible Playbook</h3>
<p>Navigate to the directory containing your <code>localsetup.yml</code> file and execute the playbook:</p>
<pre><code class="lang-bash">sudo ansible-playbook localsetup<span class="hljs-selector-class">.yml</span> --connection=local
</code></pre>
<p><strong>What this does:</strong></p>
<ul>
<li>Executes all tasks defined in your playbook</li>
<li>Installs all specified software automatically</li>
<li>Configures repositories and signing keys</li>
<li>Runs with local connection (no SSH required)</li>
</ul>
<p><strong>Note:</strong> This may take several minutes to complete, depending on your internet connection and the number of packages being installed. You&#39;ll see progress output for each task.</p>
<h3 id="step-5-restore-configuration-files">Step 5: Restore Configuration Files</h3>
<p>Application settings are typically stored in the <code>~/.config</code> directory. If you have a backup of your configuration files, restore them:</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Clone your private configuration repository</span>
git clone https:<span class="hljs-regexp">//gi</span>thub.com<span class="hljs-regexp">/yourusername/y</span>our-config-repo.git
cd your-config-repo

<span class="hljs-comment"># Copy configuration files to your home directory</span>
cp -r .config<span class="hljs-regexp">/* ~/</span>.config<span class="hljs-regexp">/</span>
</code></pre>
<p><strong>What this restores:</strong></p>
<ul>
<li>Application preferences and settings</li>
<li>Custom keyboard shortcuts</li>
<li>Editor configurations (VS Code, Vim, etc.)</li>
<li>Terminal emulator settings</li>
<li>Any other application-specific configurations</li>
</ul>
<p><strong>Tip:</strong> Press <code>Ctrl + H</code> in your file manager to show hidden files and folders (those starting with <code>.</code>).</p>
<p><strong>Important configurations to backup:</strong></p>
<ul>
<li><code>~/.config/</code> - Most modern application settings</li>
<li><code>~/.bashrc</code> or <code>~/.zshrc</code> - Shell configuration</li>
<li><code>~/.gitconfig</code> - Git configuration</li>
</ul>
<h3 id="step-6-import-desktop-environment-settings">Step 6: Import Desktop Environment Settings</h3>
<p>Restore your Cinnamon/GNOME desktop environment settings using dconf. This includes themes, panels, applets, and all desktop preferences.</p>
<h4 id="creating-a-dconf-backup-do-this-on-your-working-system-first-">Creating a dconf Backup (do this on your working system first):</h4>
<pre><code class="lang-bash"><span class="hljs-comment"># Export all settings</span>
dconf <span class="hljs-keyword">dump</span> / &gt; my_dconf_backup.conf

<span class="hljs-comment"># Or export specific paths</span>
dconf <span class="hljs-keyword">dump</span> /org/cinnamon/ &gt; cinnamon_settings.conf
</code></pre>
<h4 id="restoring-dconf-settings-">Restoring dconf Settings:</h4>
<pre><code class="lang-bash"><span class="hljs-comment"># Navigate to your dconf backup location</span>
cd /path/<span class="hljs-built_in">to</span>/your/backups/dconf

<span class="hljs-comment"># Restore all settings</span>
dconf <span class="hljs-built_in">load</span> / &lt; my_dconf_backup.conf
</code></pre>
<p><strong>What this restores:</strong></p>
<ul>
<li>Desktop themes and appearance</li>
<li>Panel configuration and applets</li>
<li>Keyboard shortcuts</li>
<li>Window manager preferences</li>
<li>Display settings</li>
<li>Power management settings</li>
<li>All other desktop environment preferences</li>
</ul>
<p><strong>Note:</strong> You may need to log out and log back in for all changes to take effect.</p>
<h2 id="advanced-tips-and-best-practices">Advanced Tips and Best Practices</h2>
<h3 id="maintaining-your-automation-setup">Maintaining Your Automation Setup</h3>
<ol>
<li><strong>Version Control:</strong> Keep your playbook and configs in a Git repository</li>
<li><strong>Regular Updates:</strong> Update your backup after making configuration changes</li>
<li><strong>Test on VMs:</strong> Test your automation on a virtual machine before using on production</li>
<li><strong>Document Changes:</strong> Add comments to your playbook explaining custom configurations</li>
</ol>
<h3 id="securing-sensitive-information">Securing Sensitive Information</h3>
<ul>
<li>Use Ansible Vault to encrypt sensitive data in your playbooks</li>
<li>Never commit SSH private keys or passwords to repositories</li>
<li>Use environment variables for sensitive configuration values</li>
<li>Keep your configuration repository private</li>
</ul>
<h3 id="extending-your-automation">Extending Your Automation</h3>
<p>You can extend this setup to include:</p>
<pre><code class="lang-yaml"># Install development tools
-<span class="ruby"> <span class="hljs-symbol">name:</span> Install development tools
</span>  apt:
    pkg:
      -<span class="ruby"> build-essential
</span>      -<span class="ruby"> docker.io
</span>      -<span class="ruby"> python3-pip
</span>      -<span class="ruby"> nodejs
</span>      -<span class="ruby"> npm
</span>
# Install VS Code
-<span class="ruby"> <span class="hljs-symbol">name:</span> Add VS Code repository key
</span>  apt_key:
    url: "https://packages.microsoft.com/keys/microsoft.asc"
    state: present

-<span class="ruby"> <span class="hljs-symbol">name:</span> Add VS Code repository
</span>  apt_repository:
    repo: "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
    filename: vscode
    state: present

-<span class="ruby"> <span class="hljs-symbol">name:</span> Install VS Code
</span>  apt:
    name: code
    state: present

# Configure git
-<span class="ruby"> <span class="hljs-symbol">name:</span> Configure git user
</span>  community.general.git_config:
    name: "{{ item.name }}"
    value: "{{ item.value }}"
    scope: global
  loop:
    -<span class="ruby"> { <span class="hljs-symbol">name:</span> <span class="hljs-string">'user.name'</span>, <span class="hljs-symbol">value:</span> <span class="hljs-string">'Your Name'</span> }
</span>    -<span class="ruby"> { <span class="hljs-symbol">name:</span> <span class="hljs-string">'user.email'</span>, <span class="hljs-symbol">value:</span> <span class="hljs-string">'your.email@example.com'</span> }</span>
</code></pre>
<h2 id="troubleshooting">Troubleshooting</h2>
<h3 id="common-issues">Common Issues</h3>
<p><strong>Ansible not found after installation:</strong></p>
<pre><code class="lang-bash"># <span class="hljs-built_in">Verify</span> installation
ansible --version

# <span class="hljs-keyword">If</span> <span class="hljs-keyword">not</span> found, check <span class="hljs-built_in">PATH</span>
<span class="hljs-built_in">echo</span> $<span class="hljs-built_in">PATH</span>
</code></pre>
<p><strong>Permission denied errors:</strong></p>
<ul>
<li>Ensure you&#39;re running the playbook with <code>sudo</code></li>
<li>Check file permissions on your playbook: <code>chmod 644 localsetup.yml</code></li>
</ul>
<p><strong>Package conflicts:</strong></p>
<ul>
<li>Run <code>sudo apt update</code> before running the playbook</li>
<li>Check for PPA conflicts: <code>sudo apt-cache policy &lt;package-name&gt;</code></li>
</ul>
<p><strong>dconf restore doesn&#39;t seem to work:</strong></p>
<ul>
<li>Log out and log back in after restoring</li>
<li>Verify the backup file format: <code>head my_dconf_backup.conf</code></li>
<li>Try restoring specific paths instead of all settings</li>
</ul>
<h2 id="conclusion">Conclusion</h2>
<p>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.</p>
<p>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.</p>
<h2 id="additional-resources">Additional Resources</h2>
<ul>
<li><a href="https://docs.ansible.com/">Ansible Documentation</a></li>
<li><a href="https://wiki.gnome.org/Projects/dconf">dconf Manual</a></li>
<li><a href="https://linuxmint.com/documentation.php">Linux Mint Documentation</a></li>
<li><a href="https://dotfiles.github.io/">Dotfiles Management</a></li>
</ul>
<h2 id="next-steps">Next Steps</h2>
<ul>
<li>Customize the playbook with your preferred applications</li>
<li>Create backups of your current configuration files</li>
<li>Export your current dconf settings</li>
<li>Test your automation on a virtual machine</li>
<li>Set up a private Git repository for your configurations</li>
</ul>




