Comments on A Beginner's Guide To LVM

A Beginner's Guide To LVM This guide shows how to work with LVM (Logical Volume Management) on Linux. It also describes how to use LVM together with RAID1 in an extra chapter. As LVM is a rather abstract topic, this article comes with a Debian Etch VMware image that you can download and start, and on that Debian Etch system you can run all the commands I execute here and compare your results with mine. Through this practical approach you should get used to LVM very fast.

48 Comment(s)

Add comment

Please register in our forum first to comment.



First of all i'll shall congratulate you for the great guide.

I'll rather call it a "Introduction Guide" than a "Beginner Guide" , never than less it's very usefull.

Instead of having LVM on top ou those 2 RAID-1 devices and considering the disks capacity, you can use 4 disk RAID-5 system thus have more 25% usable space.

This will make the process more complex but you will be rewarded with more 80GB ;)

This must be done after you replace the first 2 Harddrives.

  • Initilize only one disk, let's say /dev/sdc
    • pvcreate /dev/sdc
  • Add the 80GB disk to the volume
    • vgextend fileserver /dev/sdc
  • pvmove all all volumes from the md[01] devices to the 80GB disk
    • pvmove /dev/md0 /dev/md1
      • note: this is very slow better use -v for periodic update
  • Remove all other devices from the volume
    • vgreduce fileshare /dev/md0 /dev/md1
  • Reboot and replace the disks
  • Initialize the new disks for raid
    • fdisk /dev/sdb
    • fdisk /dev/sdd
    • fdisk /dev/sde 
  • create the raid-5 with one missing device
    • mdadm --create /dev/md0 -a -l 5 -n 4 /dev/sdb1 /dev/sdd1 /dev/sde1 missing
  • Add the new md0 device to the Volume
    • pvcreate /dev/md0 && vgextend fileserver /dev/md0
  • Move the data from the 80GB disk
    • pvmove /dev/sdc
  • (wait)
  • Remove the 80GB disk from the volume group
    • vgreduce fileshare /dev/sdc
  • Initialize the disk for RAID
    • fdisk /dev/sdc and change the type to fd (Linux raid autodetect)
  • Add the disk to the RAID md0
    • mdadm --manage /dev/md0 -add /dev/sdc1
  • Wait for full sync
    • cat /proc/mdstat
  • And you are now with a 240GB RAID-5 volume
    • df -h

A 4 disk RAID-5 is not as performant as the RAID-1 but that's the trade off .


José Borges Ferreira 

By: lingeswaran

Step by Step Tutorial available in UnixArena. 



Be aware that when you initialize a device into a Volume or into a md RAID some unique IDs are assign and written into the first sector of that device. When you do some testing on some virtual enviorment such as VMWare you may ran into this problem. So as a part of the initilization process you better do a

#dd if=/dev/zero of=/dev/diskname bs=1k count=1
#blockdev --rereadpt /dev/sdc

before everything else.


José Borges Ferreira 


Source /dev/sda, destination /dev/sdb

 sfdisk -d /dev/sda|sfdisk /dev/sdb


I'm very sorry if I overlooked a note or a posting on this, but how do I set the CLI keyboard layout to qwerty (us 101/104) on Debian Etch.

I immediately ran into problems, it seems your vmware image was made using a german keyboard layout (?)



By: admin


apt-get install console-data console-tools debconf
dpkg-reconfigure console-data

or connect ot the virtual machine with an SSH client such as PuTTY. In PuTTY you use your client machine's keymap.

By: tonyg

I just wanted to say THANK YOU for this resource.  I've been referring back to this article for the past 2 years now, it's saved my butt, and my data, a few times now.  Thanks!!!

By: Sun_Blood

Just one word. GREAT!

This was a perfect start for me to learn on hot to use LVM. Now I'll setup my new NAS =)

By: Anonymous

Out of the 6 drives on the image - drives 3 and 4 appear to be corrupt on my VM VirtualBox Manager.

By: Mark

What a great introduction to LVM!  Thank you so much for taking the trouble to put all this together.

By: Ramesh

Thank you very much for the Excellent article. I appreciate your effort. 

By: Anonymous

Thank you for this guide.  I just ran into lvm at work and this is extremely helpful.
I am trying out the vm you provided for practice.  Login info in howtoforge is incorrect.

the user is: root
password : howtoforge



By: Anonymous

I wanted to say thank you for the great and useful guide. On the internet we should find articles like this. Well done!!!

By: pointer2null

I've just had a quick read of the tutorial and will run through it soon.

One thing I do notice is you give very clear instructions on how to execute each stage, but no explanation of why it is being done( and to a smaller degree, or what is accomplished in each step).


Still, it's a valuable resource. :)

By: Anonymous

Try to use EasyRSH in Google  Play - it's quick reference guide for Solaris, HPUX, Redhat OSs

By: albert gharbi

Thank a lots. very excellent.that was very usefull and practical.

By: Rich

Excellent tuorial.  There seems to be so little 'easy' documentation out there for managing disks and LVs in Linux. This tutorial is perfect for those that want to get started and understand the process rather than copy/paste snippets from other forums.  Great job!

By: John Snow

Thank you very much, as a newer admin to the unix world I was struggling with this concept, but this made it extremely clear.

By: zensan

Creating one Volume Group over 4 physical devices is SOOO WROONG! Admin who do this on server without RAID Array for those physical devices should've been thrown into abyss where as an punishment would be fixing byte by byte such volumes for eternity.

However this tutorial is useful example for creating LVM, the basic concept in chapter 2 should have been removed in favor of concept from chapter 7 (or simply put warning there "do not do this except for training!"). I bet most of newbie admins creating layout from chapter 2 will not change this later (until will be too late and massive data loss happened).


Very helpful. Thanks

By: Keith

The command sequence

     mv /etc/fstab /etc/fstab_orig

     cat /dev/null > /etc/fstab

     vi /etc/fstab

can be shortened to 

     cp /etc/fstab /etc/fstab_orig

     vi /etc/fstab

Doing so also has the benefit that you only need to append the /etc/fstab with

     /dev/fileserver/share   /var/share     ext3       rw,noatime    0 0

     /dev/fileserver/backup    /var/backup      xfs        rw,noatime    0 0

     /dev/fileserver/media    /var/media      reiserfs   rw,noatime    0 0

By: Keith

Both lvreduce and lvextend have the  -r, --resizefs option [Resize underlying filesystem together with the logical volume using fsadm(8)].  

     lvextend -L50G /dev/fileserver/share

     e2fsck -f /dev/fileserver/share

     resize2fs /dev/fileserver/share

can be shortened with the just:

     lvextend -r -L50G /dev/fileserver/share

By: Nathan

Thank you so much for this tutorial. I have spent the last 3 days pulling my hair out trying to get lvm to work properly and learn it in general. I followed probably 20 howto's and posted in 3 forums before I found this guide. This was written EXACTLY the way I learn best. doing it repetitively and systematically. I wish I would have found this sooner. I was beyond frustrated. Thank you again!

By: ThaSwede

Thank you Falko for a great guide that helped me after 3 days of complete and utter frustration wrapping my head around this simple set of tasks. I just wasnt getting it until I found this guide. Now Im a LVM ninja lol not really but I was able to setup my dev system using your instructions after almost giving up from previous howto's.  Your style of instruction apparently works for me specifically. Appreciate the time and effort you put into it!


By: john

Her Im sorry that Windows are the winner bye miles. Follow many guides but all end with only root can write to a LVM-disk. I cant be root in GU and dont share.

By: Ad

Great guide, thank you :)

By: Martin

Thanks, this was one hell of a tutorial. I just have one question: is there any downside to having multiple RAIDs using the same devices? Any performance penalty or space waste? It's probably OK for two but what if I had more, like 10 or 20?

By: Karthik

Well explained and very easy to understand.

By: Hans Linkels

Thanks for this great tutorial. I have tried most steps on a LVM created for this purpose.

Showing how to change things and then how to reverse those changes is excellent. The reader understands what can be reversed and what not.

Also the step by step explanation in the correct sequence is very easy to follow. It is much better than just a description what what can be done.

By: Prad

Excellent tutorial, thank you !!

By: sudhams reddy

It helped a lot in troubleshooting and as well as o learn the basic to high level of LVM partiontion... Keep doing that!!!!

By: apr

thank you

By: Apona K.

Very nice guide! But it lacks any mentioning of encryption. Encryption should be everywhere by default by now... What about LUKS / dm-crypt? :)

By: David

Great howto!

One recipee I would like to add (because it took me a while figuring this out myself) is how to enlarge your volumes after increasing the size of a virtual additional disk in VMWare (.e.g. in a use case where this disk is used for data and the data is growing). In the situation below the physical volume is on the first partition of the disk labeled as sdb, so adapt for your specific situation:

- Backup your data- Increase size of disk in VMWare- Restart your VM  - unmount the volume on the changed disk if necessary- sudo parted /dev/sdb resizepart 1 100%- sudo pvresize /dev/sdb1- sudo lvextend -l +100%FREE /dev/fileserver/share- sudo e2fsck -f /dev/fileserver/share- sudo resize2fs /dev/fileserver/share- remount /dev/fileserver/share - check increased size with df -h

Have fun,



By: Ertugrul Dur

You are literally the best man! I truly appreciate the work! No one or no other book has clarified and solidified the LVM concept better than you. I am in the process of buying a new server and want to set up RAID with LVM and will definitely use your guide for assistance. Incredible Work! I would really love for you to continue writing tutorials on other subjects in such clarity and detail! Thank you so much! If you had a book, I would be your first customer!

By: jeff knapp

The etch download doesn't work

By: Gurusamy

Thank you very much for this though tutorial. Helped alot!

By: James Coleman

 Useful guide on shrinking logical volume. Thanks!

Just a note on english verb shrink - it is irregular - so past tense is "We shrank" or "We have shrunk".

By: Hans Linkels

Thank you for this article. It should serve as an example for many others. 95% of all articles, blogs and HowTo's present a simple step-by-step guide about how to get to a solution. Most of them are even copies of other ones, containing exactly the same information.

What most of those articles lack is an explanation of how and why, and most important, how to recover from a mistake or an error. If everything goes well, you don't need that many documentation anyway.

By describing in this article how LVM is built-up step by step (not a step-by-step guide!), tearing down steps and than rebuilding them this gives a perfect insight about what can be done in every step of LVM building.

I have this article as eternal bookmark in my browser and I use it over and over again.

By: linuxito

 how to know the equivalen 40gb = 10485760

By: Peter

I have very important question, since no one has asked that: do all the partitions have to be completely empty? Or let me rephrase that: can do everything written in the article not worrying about what on the physical volumes? I'm just a little bit worried wouldn't I kill my system and destroy all the files by messing them as you described. 

By: Vince

Excellent documentation, not even needing this right now but was an enjoyable and followable read.

By: Flesz

image download link is broken

By: Ron van Dijk

Thank you and I like the style. Except explenation how also some exercisies. Good stuff

By: Rob Basham

When I make the directory as you say it seems to just go under root.  See the squence below:

[root@siwr10tpmxb705 /]# mkdir /c_data /c_hints /c_commit[root@siwr10tpmxb705 /]# mount /dev/vg_c_data/lv_c_data /c_data[root@siwr10tpmxb705 /]# mount /dev/vg_c_hints/lv_c_hints /c_hints[root@siwr10tpmxb705 /]# mount /dev/vg_c_commit/lv_c_commmit /c_commitmount: special device /dev/vg_c_commit/lv_c_commmit does not exist[root@siwr10tpmxb705 /]# mount /dev/vg_c_commit/lv_c_commit /c_commit[root@siwr10tpmxb705 /]# df -hFilesystem      Size  Used Avail Use% Mounted on/dev/sda3       919G  2.7G  916G   1% /devtmpfs         32G     0   32G   0% /devtmpfs            32G     0   32G   0% /dev/shmtmpfs            32G   11M   32G   1% /runtmpfs            32G     0   32G   0% /sys/fs/cgroup/dev/sda1       250M  157M   93M  63% /boottmpfs           6.3G     0  6.3G   0% /run/user/0[root@siwr10tpmxb705 /]# mkdir /cassandra/datamkdir: cannot create directory ‘/cassandra/data’: No such file or directory[root@siwr10tpmxb705 /]# lsbin   c_commit  c_hints  dev    disk2  disk4  disk6  home  lib64  mnt  proc  run   srv  tmp  varboot  c_data    c_log    disk1  disk3  disk5  etc    lib   media  opt  root  sbin  sys  usr


By: tommylovell

It's a Very well written article, and very useful.  LVM is a fabulous piece of technology. Too bad it is not embraced by more people (Debian and Raspbian in particular).  But it is Logical Volume Manager in Linux, not Logical Volume Management. (Logical volume management is a concept implemented in many operating systems; Logical Volume Manager is the logical volume management implementation in Linux - originally written by Heinz Mauelshagen of Sistina, subsequently purchased by Red Hat and made available under a GPLv2 license. Thank you, Red Hat.) I don't know how old this article is, but I'd encourage people to use LVM in any non-embedded system.  I am trying to come to speed (again) with snapshots, and with thin provisioning. Great features. 

By: Michael Cooper

Hello Falko,

     Excellent 9 page article my friend, I was struggling with LVM and the understanding of it but now i understand it perfectly. Great job my friend.



By: Sacheen

Superb article