DbAppWeb.com

Menu
  • Home
  • Linux
  • HP-UX
  • macOS
  • Windows
  • Web Servers
  • App Servers
  • Storage

Create PV, VG, LV and format it in Linux when Multipath Enabled

May 25, 2017 DbAppWeb Admin

When we need more space on a server. To get more space we create new virtual LUNs from our storage and present that LUN on the server to get the required space.

After exporting the LUNs to a server we need to create Physical Volume, Volume Group, and Logical Volume and then we format the logical volume using a file system. Linux supports numerous file systems, but common choices for the system disk on a block device include the ext* family (ext2, ext3 and ext4), XFS, JFS, ReiserFS and btrfs. ext4 is the latest file system of ext* family.

After formatting the Logical Volume we can mount this on a directory (mount point) and can use the disk as per our requirements.

Rescan the Disks:

If you added a new disk to the system or exported a virtual volume from your storage then rescan the disks to find the new disk. Here I have added a new virtual volume from my 3PAR storage /dev/mapper/mpathh. Multipath is enabled in this case so you need to scan the disk corresponding to each and every host. Use command ls /sys/class/scsi_host to see the list of hosts.

[root@server ~]# ls /sys/class/scsi_host
host0  host1  host10  host11  host12  host2  host3  host4  host5  host6  host7  host8  host9

[root@server ~]# echo '- - -' > /sys/class/scsi_host/host0/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host1/scan
.
.
.
.
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host12/scan

Now use the command fdisk -l or multipath -ll to find the appropriate disk which you have added. You can identify the disk by the size of the disk or by using the WWN number. fdisk -l will show the multiple disks but you have to use the disk which will be like /dev/mapper/mpathX, in my case it is dev/mapper/mpathh.

[root@Server ~]# fdisk -l
Disk /dev/sdv: 2147 MB, 2147483648 bytes
67 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 4154 * 512 = 2126848 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 16777216 bytes
Disk identifier: 0x00000000
Disk /dev/sdw: 2147 MB, 2147483648 bytes
67 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 4154 * 512 = 2126848 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 16777216 bytes
Disk identifier: 0x00000000
Disk /dev/mapper/mpathh: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 16777216 bytes
Disk identifier: 0x00000000
Disk /dev/sdx: 2147 MB, 2147483648 bytes
67 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 4154 * 512 = 2126848 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 16777216 bytes
Disk identifier: 0x00000000
Disk /dev/sdy: 2147 MB, 2147483648 bytes
67 heads, 62 sectors/track, 1009 cylinders
Units = cylinders of 4154 * 512 = 2126848 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 16777216 bytes
Disk identifier: 0x00000000
[root@Server ~]# multipath -ll
mpathh (360002ac000000000000065c000010b4b) dm-10 3PARdata,VV
size=2.0G features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 1:0:1:5 sdw 65:96  active ready running
  |- 2:0:1:5 sdy 65:128 active ready running
  |- 1:0:0:5 sdv 65:80  active ready running
  `- 2:0:0:5 sdx 65:112 active ready running

Partition of the Newly Added Disk:

Use the fdisk command to create the new partition on the newly added disk.

[root@Server ~]# fdisk /dev/mapper/mpathh
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xf3ced09e.
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)
p
Partition number (1-4): 1
First cylinder (1-261, default 3):
Using default value 3
Last cylinder, +cylinders or +size{K,M,G} (3-261, default 261):
Using default value 261

Command (m for help): p

Disk /dev/mapper/mpathh: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 16384 bytes / 16777216 bytes
Disk identifier: 0xf3ced09e

             Device Boot      Start         End      Blocks   Id  System
/dev/mapper/mpathhp1               3         261     2080417+  83  Linux
Partition 1 does not start on physical sector boundary.

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

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

Create Physical Volume:

Create the Physical Volume using the command pvcreate.

[root@Server ~]# pvcreate /dev/mapper/mpathhp1
  Physical volume "/dev/mapper/mpathhp1" successfully created

Create Volume Group:

Create the Volume Group using the command vgcreate.

[root@Server ~]# vgcreate rcptest /dev/mapper/mpathhp1
  Volume group "rcptest" successfully created

See the Details of the Volume Group:

See the details of the Volume Group using the command vgdisplay.

[root@Server ~]# vgdisplay -v rcptest
    Using volume group(s) on command line.
  --- Volume group ---
  VG Name               rcptest
  System ID
  Format                lvm2
  Metadata Areas        1
  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                1
  Act PV                1
  VG Size               1.96 GiB
  PE Size               4.00 MiB
  Total PE              503
  Alloc PE / Size       0 / 0
  Free  PE / Size       503 / 1.96 GiB
  VG UUID               LLiW6z-9rhi-1cPj-LA0v-eW9C-HTMA-7TDdYS

  --- Physical volumes ---
  PV Name               /dev/mapper/mpathhp1
  PV UUID               AXBOp6-nhRs-cijS-oA3g-n3fV-5c1K-rH8V0h
  PV Status             allocatable
  Total PE / Free PE    503 / 503

Create Logical Volume:

Now create the Logical Volume using the command lvcreate.

[root@Server ~]# lvcreate -l 503 -n lvrcptest rcptest
  Logical volume "lvrcptest" created.
[root@Server ~]# vgdisplay -v rcptest
    Using volume group(s) on command line.
  --- Volume group ---
  VG Name               rcptest
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.96 GiB
  PE Size               4.00 MiB
  Total PE              503
  Alloc PE / Size       503 / 1.96 GiB
  Free  PE / Size       0 / 0
  VG UUID               LLiW6z-9rhi-1cPj-LA0v-eW9C-HTMA-7TDdYS

  --- Logical volume ---
  LV Path                /dev/rcptest/lvrcptest
  LV Name                lvrcptest
  VG Name                rcptest
  LV UUID                VcJcMw-akzU-PZEI-v8bn-TU63-BjOV-Cdn9Wc
  LV Write Access        read/write
  LV Creation host, time Server, 2017-05-11 17:03:04 +0530
  LV Status              available
  # open                 0
  LV Size                1.96 GiB
  Current LE             503
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:12

  --- Physical volumes ---
  PV Name               /dev/mapper/mpathhp1
  PV UUID               AXBOp6-nhRs-cijS-oA3g-n3fV-5c1K-rH8V0h
  PV Status             allocatable
  Total PE / Free PE    503 / 0

Format the Volume:

Format the volume in ext4 file format

[root@Server ~]# mkfs.ext4 /dev/rcptest/lvrcptest
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=4 blocks, Stripe width=4096 blocks
128768 inodes, 515072 blocks
25753 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=528482304
16 block groups
32768 blocks per group, 32768 fragments per group
8048 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (8192 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 tune2fs -c or -i to override.

Create a mount point and mount:

Create a mount point directory and mount the formatted volume to this directory.

[root@Server ~]# mkdir /rcptest

[root@Server ~]# mount /dev/rcptest/lvrcptest /rcptest

[root@Server ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/rcptest-lvrcptest
                      2.0G   86M  1.9G   2% /rcptest

Note: Above process was performed on RHEL 6.8.

Prev Article
Next Article
Tags:3PAR HP 3PAR HP-UX Linux Storage System Sys Admin
  • Popular
  • Recent

Categories

  • Android (2)
  • Blogger (16)
  • Domain and Hosting (1)
  • Hardware Issues (7)
  • HP-UX (55)
  • HPE Data Protector (9)
  • IBM Lotus Notes (2)
  • IBM WebSphere Application Server (16)
  • Internet Tips & Tricks (15)
  • iOS (8)
  • JBoss/WildFly Application Server (2)
  • Linux (76)
  • macOS (15)
  • Microsoft Windows (31)
  • News and Updates (11)
  • Oracle Database (5)
  • SSL/TLS (1)
  • Storage Servers (23)
  • Tools/Softwares (1)
  • VMware ESXi (17)
  • Web Servers (14)
  • WordPress (5)

Archives

DbAppWeb.com

Solution of Database, Application and Web Server Problems

About DbAppWeb.com

One Stop Solution for Database Server, Application Server and Web Server Problems.

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

DbAppWeb on Social Media

Copyright © 2025 DbAppWeb.com
Terms and Conditions   Theme by MyThemeShop.com