Once you have added a new disk to your system, make sure it can be seen using the lsblk command. You should see something similar to the following. You can see a new disk identified as sdb.
[root@UTLXDEV5866 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
├─sda1 8:1 0 1G 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 98G 0 part
├─vg_root-rootvol 253:0 0 10G 0 lvm /
├─vg_root-swapvol 253:1 0 6G 0 lvm [SWAP]
├─vg_root-varvol 253:2 0 20G 0 lvm /var
├─vg_root-optvol 253:3 0 6G 0 lvm /opt
├─vg_root-homevol 253:4 0 6G 0 lvm /home
└─vg_root-tmpvol 253:5 0 6G 0 lvm /tmp
sdb 8:16 0 80G 0 disk
sr0 11:0 1 1024M 0 rom
Use the fdisk command to partition your new disk. In this case, we will be creating a new primary partition as the first and only one (1), using the default sector/size entries and then writing our change to complete the process.
[root@UTLXDEV5866 ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.32.1). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table. Created a new DOS disklabel with disk identifier 0x3f70dd32. Command (m for help): n Partition type p primary (0 primary, 0 extended, 4 free) e extended (container for logical partitions) Select (default p): Using default response p. Partition number (1-4, default 1): First sector (2048-167772159, default 2048): Last sector, +sectors or +size{K,M,G,T,P} (2048-167772159, default 167772159): w Last sector, +sectors or +size{K,M,G,T,P} (2048-167772159, default 167772159): Created a new partition 1 of type 'Linux' and of size 80 GiB. Command (m for help): w The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
If you run the lsblk command again, you will see the sdb disk with an sdb1 partition.
[root@UTLXDEV5866 ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 100G 0 disk ├─sda1 8:1 0 1G 0 part /boot/efi ├─sda2 8:2 0 1G 0 part /boot └─sda3 8:3 0 98G 0 part ├─vg_root-rootvol 253:0 0 10G 0 lvm / ├─vg_root-swapvol 253:1 0 6G 0 lvm [SWAP] ├─vg_root-varvol 253:2 0 20G 0 lvm /var ├─vg_root-optvol 253:3 0 6G 0 lvm /opt ├─vg_root-homevol 253:4 0 6G 0 lvm /home └─vg_root-tmpvol 253:5 0 6G 0 lvm /tmp sdb 8:16 0 80G 0 disk └─sdb1 8:17 0 80G 0 part sr0 11:0 1 1024M 0 rom
Create Physical Volume (PV) with pvcreate.
[root@UTLXDEV5866 ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created.
Create Volume Group (VG) with vgcreate. We will name this volume group appvg0.
[root@UTLXDEV5866 ~]# vgcreate appvg0 /dev/sdb1 Volume group "appvg0" successfully created
We can now see that the volume group has been created with the vgdisplay command.
[root@UTLXDEV5866 ~]# vgdisplay --- Volume group --- VG Name appvg0 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 <80.00 GiB PE Size 4.00 MiB Total PE 20479 Alloc PE / Size 0 / 0 Free PE / Size 20479 / <80.00 GiB VG UUID IHAxjd-ila8-JxwZ-HVYa-isqn-ctXW-P4X7Wz
Now to create the actual LVM or Logical Volume Management group with lvcreate. We will call our LVM appvol0.
[root@UTLXDEV5866 ~]# lvcreate -n appvol0 --size 79G appvg0 Logical volume "appvol0" created.
We can view this new LVM with the lvdisplay command.
[root@UTLXDEV5866 ~]# lvdisplay --- Logical volume --- LV Path /dev/appvg0/appvol0 LV Name appvol0 VG Name appvg0 LV UUID IJyV69-SInf-NmHM-c1eb-C3x8-zQ3l-Oe1uAW LV Write Access read/write LV Creation host, time UTLXDEV5866, 2023-04-07 12:15:31 -0600 LV Status available # open 0 LV Size 79.00 GiB Current LE 20224 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:6
We will format our new volume using the xfs file system using mkfs.
[root@UTLXDEV5866 ~]# mkfs.xfs /dev/appvg0/appvol0 meta-data=/dev/appvg0/appvol0 isize=512 agcount=4, agsize=5177344 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=1, sparse=1, rmapbt=0 = reflink=1 bigtime=0 inobtcount=0 data = bsize=4096 blocks=20709376, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0, ftype=1 log =internal log bsize=4096 blocks=10112, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
We need to mount our new volume to a mount point we create. First we will create the mount point as /app. Then we will mount the volume to the mount point.
[root@UTLXDEV5866 /]# mkdir /app [root@UTLXDEV5866 /]# mount /dev/appvg0/appvol0 /app
To make our mount survive a reboot, we need to edit the /etc/fstab file adding our parameters for the /app mount point.
Filesystem Size Used Avail Use% Mounted on devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 196K 1.9G 1% /dev/shm tmpfs 1.9G 8.7M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mapper/vg_root-rootvol 10G 2.5G 7.6G 25% / /dev/mapper/vg_root-varvol 20G 1.4G 19G 7% /var /dev/mapper/vg_root-tmpvol 6.0G 79M 6.0G 2% /tmp /dev/sda2 1014M 274M 741M 28% /boot /dev/mapper/vg_root-optvol 6.0G 426M 5.6G 7% /opt /dev/mapper/vg_root-homevol 6.0G 76M 6.0G 2% /home /dev/sda1 1022M 5.8M 1017M 1% /boot/efi /dev/mapper/appvg0-appvol0 79G 597M 79G 1% /app