How To Extend LVM ( Logical Volume Manager) Disks on the Fly ( Online )

I wanted to share one of the real life disk operation, I think It will be very useful blog post.


1- After disk is added to the system by System Admin. We need to check it on system via command below

Note : In some cases you need to scan host adapters via command below to not reboot the server

List all host adapters under directory than scan all of them with echo command

ls -l /sys/class/scsi_host/

echo “- – -” > /sys/class/scsi_host/host0/scan

I have many disks in my system so I have just added last two disks to see the differences between disks which is formatted or not.

As you see below red highlighted area means that disk is formatted and its partition is “ /dev/sdi1 “ but recently added disk (/dev/sdj ) which have not that partition yet.

[root@localhost ~]# fdisk –l

Disk /dev/sdi: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xa5d10ee3

Device Boot Start End Blocks Id System

/dev/sdi1 1 2610 20964793+ 83 Linux

Disk /dev/sdj: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000


2- We will create partition with fdisk and then check it is created as mentioned before like dev/sdi1

[root@localhost ~]# fdisk /dev/sdj

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x655b6f2f.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to switch off the mode (command ‘c’) and change display units to sectors (command ‘u’).

Command (m for help): n

Command action

e extended

p primary partition (1-4)


Partition number (1-4): 1

First cylinder (1-1305, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-1305, default 1305):

Using default value 1305

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@localhost ~]# fdisk -l /dev/sdj

Disk /dev/sdj: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x655b6f2f

Device Boot Start End Blocks Id System

/dev/sdj1 1 1305 10482381 83 Linux


3- We need to check file system (type) which is used before and according to this we will format new disk


4- Format it with below command

[root@localhost ~]# mkfs.ext4 /dev/sdj1

mke2fs 1.43-WIP (20-Jun-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

655360 inodes, 2620595 blocks

131029 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2684354560

80 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


5- Create physical volume

[root@localhost ~]# pvcreate /dev/sdj1

dev_is_mpath: failed to get device for 8:145

Physical volume “/dev/sdj1” successfully created


6- Check volume groups.

Note : We will add physical disk “/dev/sdj1” into the volume group “vgu02” in the next step

[root@localhost ~]# vgs

VG #PV #LV #SN Attr VSize VFree

VolGroup 2 2 0 wz–n- 39.50g 0

vgu02 1 1 0 wz–n- 30.00g 0


7- Now we will add newly created physical volume into the volume group that we need to extent. In this case it is vgu02

[root@localhost ~]# vgextend vgu02 /dev/sdj1

Volume group “vgu02” successfully extended


8- We will extend the VolumeGroup now

[root@localhost ~]# lvextend -l +100%FREE /dev/mapper/vgu02-lvu02

Extending logical volume vgu02 to 10.00 GB

Logical volume vgu02 successfully resized


Note : You can see our volume group is extended 10Gb more but this size is usable by O/S yet


9- Now resize the file system and chech it with df –h command and see the new size

[root@localhost ~]# resize2fs /dev/mapper/vgu02-lvu02

resize2fs 1.43-WIP (20-Jun-2013)

Filesystem at /dev/mapper/vgu02-lvu02 is mounted on /u02; on-line resizing required

old_desc_blocks = 2, new_desc_blocks = 3

The filesystem on /dev/mapper/vgu02-lvu02 is now 10482688 blocks long.



Do you want to learn Linux System Administration for Beginners, then read the following articles.

About Cihan Gedik

I am currently working as Senior Oracle Application Database Administrator. I have experienced many EBS database upgrade, migrations, Fresh EBS installations, Solaris to Linux, Windows to Linux replatform migration projects in medium and large companies and also experienced core database migration projects for one of the biggest bank of Katar.With my colleagues we decided to run this platform to share our knowledge


  1. Hello to all, the contents present at this website are genuinely amazing for people knowledge, well, keep up the nice work fellows.

  2. Have you ever thought about publishing an ebook or guest authoring on other websites? I have a blog based on the same topics you discuss and would love to have you share some stories/information. I know my audience would enjoy your work. If you are even remotely interested, feel free to shoot me an e-mail.

  3. Magnificent goods from you, man. I’ve understand your stuff previous to and you’re just extremely magnificent. I really like what you have acquired here, really like what you’re stating and the way in which you say it. You make it enjoyable and you still take care of to keep it wise. I can’t wait to read far more from you. This is actually a terrific site.

  4. Can I simply say what a comfort to find somebody that really knows what they’re talking about over the internet. You actually know how to bring an issue to light and make it important. A lot more people should check this out and understand this side of the story. I can’t believe you’re not more popular because you certainly have the gift.

  5. magnificent issues altogether, you simply received a brand new reader. What could you recommend about your submit that you just made a few days in the past? Any certain?

  6. This post will help the internet users for setting up new web site or even a weblog from start to end.

  7. Very useful article, for disk prices are falling now, there must be many users with similar needs.

    However, I think it will be much easier to operate through the GUI. I happen to have written an article about it. Would you be interested to read it?

  8. Good day! This post couldn’t be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this write-up to him. Pretty sure he will have a good read. Many thanks for sharing!

Leave a Reply

Your email address will not be published. Required fields are marked *