DbAppWeb.com

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

Create a Logical Volume larger than 2TB and format it in Linux/RHEL

August 21, 2017 DbAppWeb Admin

You cannot create a Linux partition larger than 2 TB using the fdisk command. Using fdisk you could not create partitions larger than 2 TB. It is fine for desktop and laptop users, but for servers, you need large partitions like 2TB, 3TB, 4TB etc.

Root Cause

  • The fdisk command only supports the legacy MBR partition table format (also known as msdos partition table)
    • MBR partition tables use data fields that have a maximum of 32-bit sector numbers, and with 512 bytes/sector that means a maximum of 2^(32+9) bytes per disk or partition is supported
    • MBR partition table can not support accessing data on disks past 2.19TB due to the above limitation
    • Note that some older versions of fdisk may permit a larger size to be created but the resulting partition table will be invalid.
  • The parted command can create disk labels using MBR (msdos), GUID Partition Table (GPT), SUN disk labels and many more types.
    • The GPT disk label overcomes many of the limitations of the DOS MBR including restrictions on the size of the disk, the size of any one partition and the overall number of partitions.
    • Note that booting from a GPT labelled volume requires firmware support and this is not commonly available on non-EFI platforms (including x86 and x86_64 architectures).

For more details please see the solution on Red Hat Customer Portal

Create a Logical Volume larger than 2TB and format it in Linux/RHEL

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/mpathj. 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

Now use the below command to scan the newly added LUN for all the hosts:

[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/host2/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host3/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host4/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host5/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host6/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host7/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host8/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host9/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host10/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host11/scan
[root@server ~]# echo '- - -' > /sys/class/scsi_host/host12/scan

Now use the command I -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/mpathj.

[root@server ~]# fdisk -l

Disk /dev/mapper/mpathi: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 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: 0xaedc5bdb

             Device Boot      Start         End      Blocks   Id  System
/dev/mapper/mpathip1               3      133674  1073720340   83  Linux
Partition 1 does not start on physical sector boundary.

Disk /dev/mapper/mpathj: 3298.5 GB, 3298534883328 bytes
255 heads, 63 sectors/track, 401024 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
[root@server ~]# multipath -ll
mpathj (360002ac00000000001003c5500010b4b) dm-17 3PARdata,VV
size=3.0T features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 1:0:2:7 sdae 65:224 active ready running
  |- 2:0:2:7 sdag 66:0   active ready running
  |- 1:0:0:7 sdad 65:208 active ready running
  `- 2:0:0:7 sdaf 65:240 active ready running
mpathi (360002ac00000000000006f2900010b4b) dm-6 3PARdata,VV
size=1.0T features='0' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=1 status=active
  |- 1:0:0:6 sdh  8:112  active ready running
  |- 2:0:0:6 sdv  65:80  active ready running
  |- 1:0:2:6 sdo  8:224  active ready running
  `- 2:0:2:6 sdac 65:192 active ready running

Partition of the Newly Added Disk:

  • Use the parted tool to access the partition table of the device:
    [root@server ~]# parted /dev/mapper/mpathj
    GNU Parted 2.1
    Using /dev/mapper/mpathj
    Welcome to GNU Parted! Type 'help' to view a list of commands.
  • Once at the parted prompt, create a GPT label on the disk (Note: This will remove any existing partition table and partitions on the device):
    (parted) mklabel gpt
    Warning: The existing disk label on /dev/sdj will be destroyed and all data on this disk will be lost. Do you want to continue?
    Yes/No? Yes                                                                                                         
    (parted)
  • The default unit will be GB you can change it to TB if required, I have not changed the default unit to TB. Here default unit is GB
    (parted) unit TB
  • Use the print command to show the size of the disk as reported by parted.  We need this later:
    (parted) print
    Model: Linux device-mapper (multipath) (dm)
    Disk /dev/mapper/mpathj: 3299GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start  End  Size  File system  Name  Flags
  • Create a primary partition on the device.  In this example, the partition will encompass the entire disk (using the size from the step above):
    (parted) mkpart primary 0 3299GB
  • Unlike fdisk, you do not have to write out the partition table changes with parted.  Display your new partition and quit.
    (parted) print
    Model: Linux device-mapper (multipath) (dm)
    Disk /dev/mapper/mpathj: 3299GB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    
    Number  Start   End     Size    File system  Name     Flags
     1      0.02GB  3299GB  3299GB               primary
    
    (parted) quit
    Information: You may need to update /etc/fstab.

Again run the command fdisk -l to see and verify the partition which you have created in the above steps.

[root@server ~]# fdisk -l

Disk /dev/mapper/mpathi: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 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: 0xaedc5bdb

             Device Boot      Start         End      Blocks   Id  System
/dev/mapper/mpathip1               3      133674  1073720340   83  Linux
Partition 1 does not start on physical sector boundary.

Disk /dev/mapper/mpathj: 3298.5 GB, 3298534883328 bytes
255 heads, 63 sectors/track, 401024 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

             Device Boot      Start         End      Blocks   Id  System
/dev/mapper/mpathjp1               1      267350  2147483647+  ee  GPT
Partition 1 does not start on physical sector boundary.

As you can see above /dev/mapper/mpathjp1 is the newly created partition and from here we will perform the action on this newly created partition.

Note: If you do not need to create the PV, VG and LV then you can format this partition /dev/mapper/mpathjp1 using the command mkfs and mount it to any mount point.

Create Physical Volume:

Create the Physical Volume using the command pvcreate.

[root@server ~]# pvcreate /dev/mapper/mpathjp1
  Physical volume "/dev/mapper/mpathjp1" successfully created

Create Volume Group:

Create the Volume Group using the command vgcreate.

[root@server ~]# vgcreate vgsupload /dev/mapper/mpathjp1
  Volume group "vgsupload" successfully created

See the Details of the Volume Group:

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

[root@server ~]# vgdisplay -v vgsupload
    Using volume group(s) on command line.
  --- Volume group ---
  VG Name               vgsupload
  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               3.00 TiB
  PE Size               4.00 MiB
  Total PE              786420
  Alloc PE / Size       0 / 0
  Free  PE / Size       786420 / 3.00 TiB
  VG UUID               TzD23O-gYN3-e2Il-CI2H-uC1k-AhZQ-hoCg7R

  --- Physical volumes ---
  PV Name               /dev/mapper/mpathjp1
  PV UUID               edsRG8-5K9L-TIie-Do6N-Q5Vf-4pb6-Idp2Su
  PV Status             allocatable
  Total PE / Free PE    786420 / 786420

Create Logical Volume:

Now create the Logical Volume using the command lvcreate.

[root@server ~]# lvcreate -l 786420 -n lvsupload vgsupload
  Logical volume "lvsupload" created.

 

[root@server ~]# vgdisplay -v vgsupload
    Using volume group(s) on command line.
  --- Volume group ---
  VG Name               vgsupload
  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               3.00 TiB
  PE Size               4.00 MiB
  Total PE              786420
  Alloc PE / Size       786420 / 3.00 TiB
  Free  PE / Size       0 / 0
  VG UUID               TzD23O-gYN3-e2Il-CI2H-uC1k-AhZQ-hoCg7R

  --- Logical volume ---
  LV Path                /dev/vgsupload/lvsupload
  LV Name                lvsupload
  VG Name                vgsupload
  LV UUID                wiecWJ-Sg2W-SNUJ-ucIz-54AI-CEIY-hM3aL4
  LV Write Access        read/write
  LV Creation host, time server, 2017-07-31 12:05:14 +0530
  LV Status              available
  # open                 0
  LV Size                3.00 TiB
  Current LE             786420
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:19

  --- Physical volumes ---
  PV Name               /dev/mapper/mpathjp1
  PV UUID               edsRG8-5K9L-TIie-Do6N-Q5Vf-4pb6-Idp2Su
  PV Status             allocatable
  Total PE / Free PE    786420 / 0

Format the Volume:

Format the volume in ext4 file format

[root@server ~]# mkfs.ext4 /dev/vgsupload/lvsupload
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
201326592 inodes, 805294080 blocks
40264704 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
24576 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, 214990848, 512000000, 550731776, 644972544

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

This filesystem will be automatically checked every 24 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 /supload

[root@server ~]# mount /dev/vgsupload/lvsupload /supload

[root@server ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda10             40G  8.6G   29G  23% /
tmpfs                  48G  153M   48G   1% /dev/shm
/dev/mapper/vgsupload-lvsupload
                      3.0T   72M  2.9T   1% /supload

 

Note: Above process was performed on RHEL 6.8

Share this:

  • Click to share on Twitter (Opens in new window)
  • Click to share on Facebook (Opens in new window)
  • Click to share on LinkedIn (Opens in new window)
  • Click to share on Telegram (Opens in new window)
  • Click to share on WhatsApp (Opens in new window)
Prev Article
Next Article
Tags:3PAR File System 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