There may be situation where required capacity cannot be allocated from single volume group from storage, in such situation storage teams will provide multiple luns with different capacities. In this post we will see how we can create single mountpoint with multiple devices using LVM.

Newly presented disks/lun to server:

/dev/sdb, /dev/sdc with 360 GB each.

– check newly connected devices are visible from OS:

root@racnode1 ~]# fdisk -l

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20482843+ 83 Linux
/dev/sda2 2551 3825 10241437+ 82 Linux swap / Solaris
/dev/sda3 3826 6527 21703815 83 Linux

Disk /dev/sdb: 386.5 GB, 386547056640 bytes
255 heads, 63 sectors/track, 46995 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 386.5 GB, 386547056640 bytes
255 heads, 63 sectors/track, 46995 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table
[root@racnode1 ~]#

– Format the newly added devices:

root@racnode1 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 46995.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-46995, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-46995, default 46995):
Using default value 46995

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@racnode1 ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.

The number of cylinders for this disk is set to 46995.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-46995, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-46995, default 46995):
Using default value 46995

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
[root@racnode1 ~]# fdisk -l

Disk /dev/sda: 53.6 GB, 53687091200 bytes
255 heads, 63 sectors/track, 6527 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20482843+ 83 Linux
/dev/sda2 2551 3825 10241437+ 82 Linux swap / Solaris
/dev/sda3 3826 6527 21703815 83 Linux

Disk /dev/sdb: 386.5 GB, 386547056640 bytes
255 heads, 63 sectors/track, 46995 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 46995 377487306 83 Linux

Disk /dev/sdc: 386.5 GB, 386547056640 bytes
255 heads, 63 sectors/track, 46995 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdc1 1 46995 377487306 83 Linux
[root@racnode1 ~]#

Now we will use LVM to create volume on these two devices:

– Create volume group on /dev/sdb1 and /dev/sdc1

[root@racnode1 ~]# vgcreate vol_group_db /dev/sdb1 /dev/sdc1
No physical volume label read from /dev/sdb1
No physical volume label read from /dev/sdc1
Metadata inconsistency: Not all flags successfully exported.
Metadata inconsistency: Not all flags successfully exported.
Metadata inconsistency: Not all flags successfully exported.
Metadata inconsistency: Not all flags successfully exported.
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
Writing physical volume data to disk "/dev/sdc1"
Physical volume "/dev/sdc1" successfully created
Volume group "vol_group_db" successfully created
[root@racnode1 ~]#

– Check the newly created volume size:

[root@racnode1 ~]# vgdisplay
--- Volume group ---
VG Name vol_group_db
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 719.99 GB
PE Size 4.00 MB
Total PE 184318
Alloc PE / Size 0 / 0
Free PE / Size 184318 / 719.99 GB
VG UUID g0QbuB-jDU0-swL5-X0z9-26rf-V0a9-wF6PnT

[root@racnode1 ~]#

In above step we have created the physical volume, now we will create the logical volume.

– Creation of logical volume:

[root@racnode1 ~]# lvcreate -l 512000 -n logical_vol2_db vol_group_db
Volume group "vol_group_db" has insufficient free space (183818 extents): 512000 required.
[root@racnode1 ~]# lvcreate -l 150000 -n logical_vol2_db vol_group_db
Logical volume "logical_vol2_db" created
[root@racnode1 ~]#

– Check the newly created logical volume:

[root@racnode1 ~]# lvdisplay

--- Logical volume ---
LV Name /dev/vol_group_db/logical_vol2_db
VG Name vol_group_db
LV UUID 5HfKeE-Q2Ge-RRgZ-P59d-PHph-44Cc-PI9pDg
LV Write Access read/write
LV Status available
# open 0
LV Size 585.94 GB
Current LE 150000
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1
[root@racnode1 ~]#

– Now create file system on logical volume:

root@racnode1 ~]# mke4fs /dev/vol_group_db/logical_vol2_db
mke4fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
38404096 inodes, 153600000 blocks
7680000 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
4688 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, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
102400000

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune4fs -c or -i to override.
[root@racnode1 ~]#

– mount the logical volume and check size:

[root@racnode1 ~]# mkdir /data2
[root@racnode1 ~]# mount /dev/vol_group_db/logical_vol2_db /data2
[root@racnode1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 19G 5.0G 13G 28% /
/dev/sda3 21G 173M 19G 1% /u01
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/sr0 57M 57M 0 100% /media/VBOXADDITIONS_5.1.22_115126
/dev/mapper/vol_group_db-logical_vol2_db
577G 198M 548G 1% /data2
[root@racnode1 ~]# 

Once its done add these entries in /etc/fstab file for mountpoint to be persistent across reboots.

Thanks for reading :)