Manual LVM configuration guide for Debian 6

Debian is one of a handful of Linux distributions with support for setting up LVM, the Linux Logical Volume Manager. LVM brings a level of flexibility to disk management on Linux that is not possible with the traditional disk partitioning scheme. If your favorite Linux distribution supports LVM, I’ll always recommend that you use it instead of the traditional disk partitioning scheme. There is no real downside to it.

If you opt for LVM on Debian 6 (Debian 6 review), the installer will allocate all available disk space to the partitions and Logical Volumes, leaving nothing to add other Logical Volumes if you ever need to. This article gives a very detailed step-by-step guide on proper LVM configuration on Debian 6. It is mostly intended for those new to the concept of volume management (on Linux).

Note: This article assumes installation on a computer with a single hard disk. A follow up article will show how to add extra disk(s) to the system, if the original disk becomes full.

Setting up LVM on any Linux distribution involves four steps:

Create a non-LVM partition for /boot.

Initialize the remaining free space of use by LVM. In LVM jargon, this free space is called a Physical Volume (PV).

Create a Volume Group (VG). A VG is a virtual container for one or more PVs. The disk space available on a VG is the sum of the disk space of each member PV. If a VG runs out of disk space, you can attached a new hard disk to the system and add it to the VG.

Carve out Logical Volumes (LV) from the VG. An LV is LVM’s equivalent of a disk partition. Like a VG, you can add or reduce the size of an LV. Lets say, for example, that you have an LV of size 20 GB, mounted at /home, And lets assume that the LV has run out of space, or is about to. You can grow the LV, provided that there is free space on the VG. And you can do this online, that is, while the computer is running, and without having to unmount the volume.

To begin, you just need to download a suitable installation image. Debian 6 installation and disk partitioning guide will give you an idea which one to download. My suggestion is to use a netinst image. Boot your computer using the installation image and let’s get started.

The default installation method on Debian 6 is via an ncurses-based interface. I prefer the graphical interface. It’s a bit easier.

Note: Using the default or choosing the “Graphical install” option on the boot screen will lead to the installation of a GNOME-based system. If you would rather install a system based on KDE. LXDE, or Xfce, choose “Advanced options,” and on the screen that comes after that, chose “Order desktops.”

A bunch of images that are not directly related to disk partitioning have been omitted from this tutorial. So, we cut to the step where disk partitioning starts.

The option to choose at this step is “Manual.” That is the only option that will allow to accomplish our objective, which is install a system using just a fraction of the available disk space. Continue.

Select the disk(s) you want to use. Keep in mind that this tutorial assumes installation on a single disk. Continue.

If the disk has been initialized, you will see something just like the one in the image below. If it has not, you will get another screen requesting permission to initialized it. Select the free space, then Continue.

Select the option as shown to start creating partitions. The goal here is to create a traditional partition for /boot, then create three logical volumes for /, swap, and /home. You can create more partitions, but for a desktop system, these will do. Continue.

By default the /boot partition on Debian 6 is allocated about 250 MB. Most Linux distributions use 500 MB. I think 250 MB will do just fine. Continue.

The default here is Primary. No problem with that. Continue.

Stick with the default. Continue.

Subscribe to LinuxBSDos.com

Subscribe to receive the latest articles in your Inbox

I agree to have my personal information transfered to MailChimp ( more information )

23 Comments

Thank you for the very helpful HowTo. I am going to use it the dual boot Debian on a second HDD with Windows XP Pro.I have tried to install Debian 4 times today, using LVM and letting the installer sort it out with multi-partitions on the 250 GB drive I want to use. Each time it has failed as GRUB does not show the Windows OS and Debian black screens. I have tried putting the boot flag on both OS but no luck. Ishal try aging following your advice but can you please suggest the correct installation of GRUB to complement this HowTO? /boot, /, Windows, somewhere else?

I created a logical volume for “Swap” and I have to mount it and pick a file system. I understand “Swap” does not use a file system. What should I chose for this under “use as:” for file system choice? I’ve been using ext3 for all other logical volumes. Thank you.

> I created a logical volume for “Swap” and I
> have to mount it and pick a file system. I
> understand “Swap” does not use a file system.
> What should I chose for this under
> “use as:” for file system choice?
> I’ve been using ext3 for all other logical
> volumes. Thank you.

My apologies. I just noticed that one of my choices is: ‘Swap area’. Is this the correct choice?

Is it okay to click on ‘label’ and name the partition ‘boot’? I see you left this as ‘none’ (default).

Also I noticed in the very beginning of the install under ‘help’ that it said:

-begin-
In order to start your new system, a so called boot-loader is used. It can be installed either in the master boot record of the first hard disk, or in a partition. When the boot-loader is installed in a partition, you must set the boot-loader flag for it. Such a partition will be marked with ‘B’ in the main partion menu.
-end-

Do I need to ‘set’ the boot-loader flag? When they mention the word ‘set’, I assume they mean turn the flag ‘on’ in the partition menu for /boot? I see the default is ‘off’.

I am ready to complete your tutorial and click to “Finish partitioning and write changes to disk.”

If you can please answer the question above in regards to the boot-loader flag being set to ‘on’ or ‘off’ I’d appreciate it. I clicked set boot-loader flag to ‘on’. I hope that was the right choice. Thank you.

I’m currently installing Debian Squeeze (netinst file 191MB) and I’m utilizing your excellent tutorial for setting up the first partition called /boot.

On page 2, you begin by saying:

-begin-
“On this screen, select a suitable file system type. Keep in mind that the default is ext2. I have chosen ext3, a journaling file system, just to show that it does not matter. There is a small overhead associated with using a journaling file system, but it is nothing to fret about”.
-end-

I noticed you suggest ext3 file system for the first partition (/boot) as well as ext3 for the remainder of the tutorial, however you recommend ext4 on your ‘Ubuntu’ tutorial installs. Why please?

Debian lists ext2, ext3, ext4 and a whole host of other file systems as a choice for /boot.

I googled, “ext3 or ext4 for Debian Squeeze” and I felt as if I was asking, “What is the best Linux Disto?” 🙂 The answers were subjective and different but the majority suggested ext4 for everything (including /boot).

Ok thank you. I did however decide to stay with your initial recommendation and chose ‘ext3’ for the install.

Debian wiki page said ‘ext4’ is still under testing and unstable in ‘Squeeze’. There is no date on the wiki page link (below), thus I have no idea when it was last updated. As a result, I can only “play it safe” and stay with ‘ext3’.

However I’ve been reading a lot about the different directory options such as (/boot,/,/home,/var,/user,/srv,/opt,/usr/local etc.) that are available. As you know there are many options and it can be a very subjective subject.

Can you please recommend a ‘smart’ partitioning scheme? This is my first GNU/Linux install. I am very familiar with windows as I have partitioned drives numerous times in that OS environment.

I don’t want to get lost in a complicated debian partition scheme during this first
go-around. But on the flip-side, I don’t want to set-up a directory tree/partition that is so simple that it gives me little control.

I am glad to see this introduction to LVM in the Debian install context.

I am really a beginner at LVM, but my limited experience has taught me to think ahead about how the LV’s will be used, and what name will be descriptive. This same idea applies to the VG name also.

For me, I found that creating the PV’s, VG’s and LV’s in advance of the install was more straightforward than performing those steps in the install. This gave me time to think about naming conventions. And, the command line interface to LVM is pretty easy, but requires some practise.

Primarily, I learned you should plan your PV’s VG’s and LV’s to accomodate multiple Linux installs.

For instance, your LV’s could be:
Squeeze-root (instead of just root)
Squeeze-home (instead of just home)
swap (since swap can be common across installs)

That way, you can keep your LV’s straight between installs.

An idea for your next iteration, is touching on how renaming the LV’s affects the Linux installs depending on those LV’s.

You are right, but the naming convention depends on the environment. If there is going to be just one Linux installation, then the names used here will do just fine. The names you suggested will work perfectly in a multi-Linux installation.