Creating a Data Drive
Create a data drive to store MySQL data files.
- If no performance test is required, go to Creating a Data Directory.
- To do a performance test, you need to format an independent drive and mount it to a data directory. For details, see Method 1: Using mkfs to Create a Data Drive, Method 2: Using fdisk to Create a Data Drive, or Method 3: Using LVM to Create a Data Drive.
Method 1: Using mkfs to Create a Data Drive
- View the drive.
1ls /dev/nvme* - Format the drive.
1 2
mkfs.xfs -f /dev/nvme0n1 du -sh /dev/nvme0n1
- Create a data directory.
1mkdir /data - Mount the drive to the data directory.
1 2
mount /dev/nvme0n1 /data/ df -h
Method 2: Using fdisk to Create a Data Drive
- Create a partition, for example, /dev/nvme0n1.
1fdisk /dev/nvme0n1 - Type p (print the partition table) and press Enter to display the current partition.
- Type n (add a new partition) and press Enter.
- Type p (create a primary partition) and press Enter.
- Type 1 (set the partition number to 1) and press Enter.
- Press Enter to retain the default setting for the first partition.
- Press Enter to retain the default setting for the last partition.
- Type p and press Enter, and check that the partition information is correct.

- Type w to save the settings and press Enter.
- Create a file system, for example, xfs.
1 2
ls /dev/nvme* mkfs.xfs -f /dev/nvme0n1p1
- Mount the partition to /data of the OS.
1 2
mkdir /data mount /dev/nvme0n1p1 /data
- Edit /etc/fstab to enable the data drive to be automatically mounted after the OS is restarted.
- Open /etc/fstab.
vim /etc/fstab
- Press i to enter the insert mode and add the line to the end of the file.
/dev/sdb1 is used as an example. Replace it with the actual one.

- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open /etc/fstab.
Method 3: Using LVM to Create a Data Drive
Install the LVM2 package (contained in the image) and create a data drive as follows:
- Install lvm2.
1yum -y install lvm2
- Create a physical volume, for example, sdb.
1pvcreate /dev/sdb - Create a physical volume group, for example, datavg.
1vgcreate datavg /dev/sdb
- Create a logical volume, for example, datalv of 600 GB.
1lvcreate -L 600G -n datalv datavg
- Create a file system.
1mkfs.xfs /dev/datavg/datalv - Create a data directory and mount it.
1 2
mkdir /data mount /dev/datavg/datalv /data
- Edit /etc/fstab to enable the data drive to be automatically mounted after the OS is restarted.
- Open /etc/fstab.
vim /etc/fstab
- Press i to enter the insert mode and add the line to the end of the file.
In the last line, /dev/datavg/datalv is only an example.

- Press Esc, type :wq!, and press Enter to save the file and exit.
- Open /etc/fstab.
Parent topic: Configuring the Installation Environment