Step-by-Step Instructions for Creating and Mounting an LVM
Create an LVM-based RAID 0 using all available NVMe drives.
Steps to Create and Mount an LVM
Step 1: Update the System
Update the list of packages for your system to ensure you have access to the most current packages:
Step 2: Install the LVM2 Package
Install the lvm2
package, which contains commands such as pvcreate
, vgcreate
, and lvcreate
:
Step 3: Verify that LVM2 has been properly installed
Assure yourself that LVM2
has been correctly installed by checking that the pvcreate
command is present:
Step 4: List Available Disks Identify which disks you want to use in the LVM setup. To list all your disks, you can use the following command:
In this case, we are using the following disks:
/dev/nvme1n1
/dev/nvme2n1
/dev/nvme3n1
/dev/nvme4n1
/dev/nvme5n1
/dev/nvme6n1
Step 5: Initialize Physical Volumes (PV)
Use the pvcreate
command to initialize each of the disks as a physical volume (PV). Run the following commands one by one:
Step 6: Create a Volume Group (VG)
From the physical volumes, we are going to create a volume group. We'll name it as nvme_vg
:
Step 7: Create a Logical Volume (LV)
From the space available in the volume group, create a logical volume. The name for our LV will be nvme_lv
.
Step 8: Format the Logical Volume Format the new logical volume to the ext4 filesystem:
Step 9: Create a Mount Point Create the mount point directory (/mnt/data), in case it does not exist:
Step 10: Mount the Logical Volume Mount the logical volume to the /mnt/data directory:
Step 11: Create a Symbolic Link Create a symbolic link from /mnt/data to /home/ubuntu/data:
Step 12: Make the Mount Persistent Get the UUID of the new logical volume for persistence across reboots:
Now, add the following line to /etc/fstab
, replacing <UUID>
with the actual UUID obtained from the previous command:
Step 13: Verify the Mount
Verify that the mount is set up correctly and will persist after reboot:
Step 14: Validate the Directories
List the contents of both the /mnt/data
and the /home/ubuntu/data
directories just for validation that all is working properly:
Step 15: Reboot - Optional
To make the change survive rebooting you should reboot your system.