All posts tagged lvm

Copied from


md: multiple devices
command description


show status of all raids


detailed status of raid md0


new raid /dev/md0 with 2 disks, raid level 1 on /dev/sda1 and /dev/sda2


remove /dev/sda1 from /dev/md0


add /dev/sda1 to /dev/md0


use 3 disks in raid /dev/md0 (e.g. add an additional disk, so a damaged drive can be removed later-on)


Assemble /dev/md0 (e.g. when running live system)


Update list of arrays in /etc/mdadm/mdadm.conf ; you should remove old list by hand first!


What is this disk / partition?


Set minimum raid rebuilding speed to 10000 kiB/s (default 1000)


Copy partition table from sdX to sdY (MBR only)


Copy partition table from sdX to sdY (GPT)

To boot a machine even with a degraded array, modify /etc/initramfs-tools/conf.d/mdadm and run update-initramfs -c -kall (Use with caution!)


pv: physical device (e.g. /dev/md0 or /dev/sda1)
vg: volume group (consists of 1 or more pvs, contains lvs); has a name (e.g. lvm)
lv: logical volume (has a name which defines its path, e.g. /dev/lvm/root which equals dev/mapper/lvm-root)
command description


initializes /dev/md0 as phys device for a volume group


create volume group lvm with phys device /dev/md0


create logical volume root, sized 30G in volume group lvm; format with ext4


extend /dev/lvm/root to 60G; also resize file system to new size


show short info about pv, vg and lv


show long info

scan disks for physical volumes (e.g. when running live system)


add phys device /dev/md1 to volume group lvm (need pvcreate first!)


move all logical volumes from /dev/md0 and remove phys device from volume group

create bios grub partition


Logical Volume Manager (LVM)

taken from

This is a quick and dirty cheat sheet on LVM using Linux, I have highlighted many of the common attributes for each command however this is not an extensive list, make sure you look up the command.

With the pvs, vgs and lvs commands, the number of verboses added the more verbose information for example pvs -vvvvv

[table id=3 /]

Our standard build = 30GB.  How do you expand the file system without losing data and/or the VM.

Our test

30GB standard VM

Need to increase /motr to 100GB

Before you start, verify that the new space can be seen.  Here is the un-modified fdisk.

Either reboot, or just enter this in.  This will rescan the disk to find the new space.

echo 1 > /sys/block/sda/device/rescan



#1  Start by creating a new primary with your new disk space, this also can be an extended

p = print

n = create new partition

w = write

t = type (8e = LVM)

Here’s the original without the new partition.


Add a new partition with the new space, we will create this on /dev/sda3.  n = create new partition, p = print, t = disk type

Now that it’s created we need to specify the partition type and switch that to Linux LVM.  Type = 8e for Linux LVM


Looks good.   Now we need to write this partition to disk using the w



run partprobe -s

which will re-scan the new partition table.  A reboot will do the samething, but why reboot?


Increase the physical layer


Increase the “system” volume. System = the volume name


Increase the Logical Volume


Finally increase the file system.

Note:  I had issues trying to use resize2fs on a physical host, as I was attempting to expand file system by adding a new disk to the system.  So try this as last step if that fails..

resize_reiserfs: On-line resizing finished successfully.


That’s it.