Professional Documents
Culture Documents
In this example we create disks for a RHEL 7 Database server which is installed on an
IBM Power 8 Server. To provision disks on a Linux server, you obviously need to create
volumes on your storage device first. Because we are provisioning disks on an
RHEL7 server with an IBM Virtual IO Server the disks are multipath from within RHEL.
Used commands:
- fdisk
-mpathconf
- multipath
- kpartx
- pvs, vgs, lvs
- lvcreate
- mks.xfs
- blkid
Created disks:
- 1 disk 100GB for the database
- 2 disks 100GB for the transaction logs
Easiest way to make the disks available in the OS is to reboot the Linux server.
You can also use below command to refresh the SCSI host adapters if you cannot
reboot your server (in this example for host0 and host1)
When the disks are present and shown in fdisk -l, you can create the partitions with
fdisk.
fdisk /dev/sdx
Make sure to create a new (n) primary partition and change the partition's system id (t)
to Linux LVM (8e). In this case the newly created disks are recognized as sdb, sdc and
sdd.
fdisk /dev/sdb
fdisk /dev/sdc
fdisk /dev/sdd
To show all disks and corresponding multipath, issue the multipath command with the -l
parameter.
multipath -l
To create multipath devicemappings, use the kpartx command. this will create
devicemappings from the previously created partition tables.
kpartx -a -v /dev/mapper/mpathb
kpartx -a -v /dev/mapper/mpathc
kpartx -a -v /dev/mapper/mpathd
To refresh the multipath configuration, issue the multipath command with the -r
parameter.
multipath -r
Next you will be able to create the physical volumes for the multipath devices
withthe pvcreate command.
pvcreate /dev/mapper/mpathb1
pvcreate /dev/mapper/mpathc1
pvcreate /dev/mapper/mpathd1
To show the newly created physical volumes use the pvs command.
[root@vmlnx001 ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/mapper/mpatha3 rhel lvm2 a-- 18.99g 0
/dev/mapper/mpathb1 vgdb lvm2 a-- 100.00g 0
/dev/mapper/mpathc1 vglog lvm2 a-- 100.00g 0
/dev/mapper/mpathd1 vglog lvm2 a-- 100.00g 0
To create volume groups from the previously created physical volumes, use the
vgcreate command. For the database volume group I use 1 disk and for the Log volume
group 2.
vgcreate vgdb /dev/mapper/mpathb1
vgcreate vglog /dev/mapper/mpathc1 /dev/mapper/mpathd1
You can also create multiple logical volumes by specifying the size, replace 100%FREE
for 50G to create a 50GB logical volume.
lvcreate -l 50G -n lvlog vglog
You can also use a lower percentage like 50%vg instead of the sizein GB.
lvcreate -l 50%VG -n lvlog vglog
To check which logical volume exists in a volumegroup, use the command lvs.
[root@vmlnx001 ~]# lvs vglog
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
lvlog vglog -wi-a----- 199.99g
After creating physical volumes, adding them to a volume group and creating logical
volumes in this volumegroup, you need to create a filesystem on this logical volume.
This could take a while depending on the size of this logical volume.
mkfs.xfs /dev/vgdb/lvdb
mkfs.xfs /dev/vglog/lvlog
If the logical volume has a filesystem, you want it to be present in the server, mounted
on a directory (mount point).
With the command blkid you can find the UUID for the filesystems.
blkid
/dev/mapper/vgdb-lvdb: UUID="e016679a-2872-4012-8848-507f5b0e5fee"
TYPE="xfs"
/dev/mapper/vglog-lvlog: UUID="03948c72-18f5-4b1c-9c9d-a4c3837de358"
TYPE="xfs"
Once the mountpoints are created, you can add the entries in the fstab file.
mkdir db
mkdir log
#
# /etc/fstab
# Created by anaconda on Mon Oct 16 13:04:28 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/rhel-root / xfs defaults 0 0
UUID=69e21ae4-1b06-47b1-8be8-133d3d9bf4ee /boot xfs defaults 0 0
/dev/mapper/rhel-swap swap swap defaults 0 0
UUID=e016679a-2872-4012-8848-507f5b0e5fee /db xfs defaults 0 0
UUID=03948c72-18f5-4b1c-9c9d-a4c3837de358 /log xfs defaults 0 0
In this article, I will take you through the steps by which we can add the new raw
hard disk to an existing Linux server such as RHEL/CentOS or Debian/Ubuntu.
Important: Please note that the purpose of this article is to show only how to
create a new partition and doesn’t include partition extension or any other
switches.
I am using fdisk utility to do this configuration.
I have added a hard disk of 20GB capacity to be mounted as a /data partition.
fdisk is a command line utility to view and manage hard disks and partitions on
Linux systems.
# fdisk -l
Important: Please note that the purpose of this article is to show only how to
create a new partition and doesn’t include partition extension or any other
switches.
I am using fdisk utility to do this configuration.
I have added a hard disk of 20GB capacity to be mounted as a /data partition.
fdisk is a command line utility to view and manage hard disks and partitions on
Linux systems.
# fdisk -l
# mkfs.ext4 /dev/xvdc1
Format New Partition
Once formatting has been completed, now mount the partition as shown below.
Conclusion