ubuntu – increase the size of a linux lvm

create LVM partition in new hardisk

sudo fdisk /dev/sdb
'n' create new partition
'p' primary partition
'1' partition number
[enter] for first cylinder
[enter] for last cylinder(max size)
't' type for paritition
'L' for list all
'8e' for linux.lvm
'w' for write partition

increasing the logical volume
# create a physical volume for later use by the LVM.

$ sudo pvcreate /dev/sdb1

# shown the name and the current size of it

$ sudo vgdisplay

# pvscan scan all disks for physical volumes

$ sudo pvscan

# increase the logical volume with the lvextend command
# my name volume is “ubuntu-vg”

$ sudo vgextend ubuntu-vg /dev/sdb1

# pvscan scan all disks for physical volumes

$ sudo pvscan

#c onfirm the name of the logical volume using lvdisplay.

$ sudo lvdisplay
--- Logical volume ---
LV Path                /dev/ubuntu-vg/root
LV Name                root
VG Name                ubuntu-vg

# The logical volume is then extended using the lvextend command
# We are extending the original logical volume of

#/dev/ubuntu-vg/root over the newer /dev/sdb1

$ sudo lvextend /dev/ubuntu-vg/root /dev/sdb1
Size of logical volume ubuntu-vg/root changed from 4.83 GiB (1236 extents) to 24.82 GiB (6355 extents).
Logical volume root successfully resized

#show vgdisplay

$ sudo vgdisplay
--- Volume group ---
VG Name               ubuntu-vg
VG Size               29.75 GiB

# However if you run a “df” command to see available disk space it will not have changed
# yet as there is one final step, we need to resize the file system using the
# resize2fs command in order to make use of this space.

$ sudo resize2fs /dev/ubuntu-vg/root
resize2fs 1.42.12 (29-Aug-2014)
Filesystem at /dev/ubuntu-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/ubuntu-vg/root is now 6507520 (4k) blocks long.

#show size with df

$ df -h

# Alternatively if you’re running the XFS file system (default as of RedHat/CentOS 7)
# you can grow the file system with “xfs_growfs /dev/ubuntu-vs/root”.



Published by


just to remember what i had known :)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s