SINGLE POST

Article & News.

Disk Management and Mount Point Creation for Database and OS Separation

If you’re managing a server with multiple hard disks and looking to separate your OS and database files for improved performance and organization, this guide will walk you through a step-by-step solution. In this example, we’ll allocate the entire 8TB space of one disk solely for database files, while keeping OS files on another disk.

Problem

You have two hard disks and want to dedicate one disk for OS files and another disk exclusively for database files.

Solution

In this guide, we’ll go through creating partitions, setting up logical volumes, and configuring mount points to achieve this separation.

Disk Setup and Partition Creation

  1. Identify the Disk
    First, ensure your disk is detected by the OS:

# fdisk -l
# ls /dev/sd*

 

2 .Partition Creation
Let’s assume your database disk is /dev/sdd with 8TB capacity.

  • Log in as the root user and create a single partition that uses the full 8TB.

# parted /dev/sdd
# mklabel gpt
# mkpart primary 0% 100%
# quit

Step 2: Create Physical Volume

To set up logical volumes, you need to first create a physical volume on the newly created partition.

# pvcreate -ff /dev/sdc1

Step 3: Volume Group Creation

Next, create a volume group (VG) to manage the storage space on this disk.

# vgcreate -s 16M vgdata /dev/sdc1
# vgdisplay

Step 4: Logical Volume Creation

Now, we’ll create multiple logical volumes (LVs) for the database using the volume group vgdata. Adjust the size and names as needed.

# lvcreate -L 1024G -n lvu01 vgdata
# lvcreate -L 1024G -n lvu02 vgdata
# lvcreate -L 1024G -n lvu03 vgdata
# lvcreate -L 1024G -n lvu04 vgdata
# lvcreate -L 1024G -n lvu05 vgdata
# lvcreate -L 1024G -n lvu06 vgdata

To delete a logical volume if needed:

# lvremove /dev/vgdata/lvu01

Step 5: Format Logical Volumes

After creating the logical volumes, format them with the XFS file system.

# mkfs -t xfs /dev/mapper/vgdata-lvu01
# mkfs -t xfs /dev/mapper/vgdata-lvu02
# mkfs -t xfs /dev/mapper/vgdata-lvu03
# mkfs -t xfs /dev/mapper/vgdata-lvu04
# mkfs -t xfs /dev/mapper/vgdata-lvu05
# mkfs -t xfs /dev/mapper/vgdata-lvu06

Step 6: Directory Creation

Create mount point directories for each logical volume.

# mkdir /u01
# mkdir /u02
# mkdir /u03
# mkdir /u04
# mkdir /u05
# mkdir /u06

 

Step 7: Mount the Logical Volumes

Mount each logical volume to its corresponding directory.

# mount -t xfs /dev/mapper/vgdata-lvu01 /u01
# mount -t xfs /dev/mapper/vgdata-lvu02 /u02
# mount -t xfs /dev/mapper/vgdata-lvu03 /u03
# mount -t xfs /dev/mapper/vgdata-lvu04 /u04
# mount -t xfs /dev/mapper/vgdata-lvu05 /u05
# mount -t xfs /dev/mapper/vgdata-lvu06 /u06

 

Step 8: Update /etc/fstab for Persistent Mounting

To ensure these volumes are automatically mounted on reboot, add entries in /etc/fstab.

  1. Use the df -h command to get the paths.
  2. Open the fstab file in a text editor

# vi /etc/fstab

 

Add the following lines:

 

/dev/mapper/vgdata-lvu01 /u01 xfs defaults 0 0
/dev/mapper/vgdata-lvu02 /u02 xfs defaults 0 0
/dev/mapper/vgdata-lvu03 /u03 xfs defaults 0 0
/dev/mapper/vgdata-lvu04 /u04 xfs defaults 0 0
/dev/mapper/vgdata-lvu05 /u05 xfs defaults 0 0
/dev/mapper/vgdata-lvu06 /u06 xfs defaults 0 0

 

 

Conclusion

By following these steps, you have successfully created a dedicated setup for managing OS and database files on separate disks. This separation improves data management, enhances performance, and simplifies backup and recovery tasks.

 

 

 

Share this article :
Facebook
Twitter
LinkedIn

Leave a Reply

Your email address will not be published. Required fields are marked *