How to Configure LVM During Debian Installation on Debian 12 Bookworm System

Learn how to configure LVM during the installation of Debian 12 Bookworm System.

Logical Volume Manager (LVM) is a flexible and powerful method for managing disk space on Linux systems, including Debian 12 (Bookworm). Instead of using traditional disk partitions, LVM provides a more dynamic way to manage storage, allowing users to resize volumes and add storage without disrupting the system. This guide will walk you through configuring LVM during the installation of Debian 12.

Prerequisites

Before proceeding, ensure you have:

  • A system ready for Debian 12 installation.
  • A bootable Debian 12 installation medium (USB/DVD).
  • Basic knowledge of disk partitioning and Linux command-line tools.

Step-by-Step Guide to Configuring LVM During Debian Installation

1. Boot Into Debian Installer

  1. Insert the Debian 12 installation medium and boot the system.
  2. Choose “Graphical Install” or “Install” from the boot menu.
  3. Select your language, location, and keyboard layout.

2. Configure Network and Set Up User Accounts

  1. Follow the on-screen instructions to configure the network.
  2. Set a hostname and domain name.
  3. Create a root password and a user account.

3. Disk Partitioning and Selecting LVM

  1. When prompted for partitioning, choose “Guided - use entire disk and set up LVM”.
  2. Select the disk you want to use for LVM.
  3. Choose how you want the partitions to be structured:
    • All files in one partition (recommended for beginners).
    • Separate /home, /var, and /tmp partitions (for better organization).
    • Custom setup (manual configuration for advanced users).

4. Configuring Logical Volume Manager (LVM)

Once you select LVM, the Debian installer will create:

  • A Physical Volume (PV) on the selected disk.
  • A Volume Group (VG) containing the PV.
  • Logical Volumes (LVs) for root (/), swap, and optionally /home.

Customizing LVM Setup (Manual Partitioning)

If you prefer a more tailored setup, choose “Manual” instead of guided partitioning.

  1. Select the disk and create a new partition table (GPT or MBR).
  2. Create a small boot partition (e.g., 512MB, ext4, mounted at /boot).
  3. Select the remaining space and mark it as LVM Physical Volume.
  4. Configure the LVM group:
    • Create a Volume Group (VG) and name it (e.g., vg_debian).
    • Inside the VG, create Logical Volumes:
      • lv_root (e.g., 20GB, ext4, mounted at /)
      • lv_swap (equal to RAM size, swap partition)
      • lv_home (remaining space, ext4, mounted at /home)
  5. Save the configuration and continue.

5. Formatting and Mounting Partitions

The installer will prompt you to format the newly created partitions:

  • /bootext4
  • /ext4
  • /homeext4 (optional)
  • swapswap area

Proceed to finalize partitioning and write changes to disk.

6. Install Debian 12

  1. Confirm the disk changes and start the installation.
  2. Allow the installer to copy files and install the base system.
  3. Choose whether to install additional software (e.g., SSH server, desktop environment).
  4. Install the GRUB bootloader when prompted.

7. Finalizing Installation and Rebooting

  1. Complete the installation and remove the installation media.
  2. Reboot the system and log in.

Managing LVM After Installation

Once Debian 12 is installed, you can manage LVM using lvextend, lvreduce, vgextend, and pvcreate commands.

Checking LVM Setup

To check the current LVM configuration, run:

lsblk
sudo pvs
sudo vgs
sudo lvs

Extending a Logical Volume

If you need more space on /home, extend it with:

sudo lvextend -L +10G /dev/vg_debian/lv_home
sudo resize2fs /dev/vg_debian/lv_home

Adding a New Disk to LVM

If you install an additional disk, add it to the LVM setup:

sudo pvcreate /dev/sdb
sudo vgextend vg_debian /dev/sdb

Conclusion

Configuring LVM during Debian 12 installation allows for flexible disk management. Whether using guided or manual partitioning, LVM provides benefits such as easier resizing and efficient space allocation. By following these steps, you can set up and manage LVM effectively in Debian 12.