Step 1: Install LVM
First, you need to make sure that LVM is installed on your Ubuntu server. You can do this by running the following command:
sudo apt-get update
sudo apt-get install lvm2
Step 2: Create a Physical Volume
The next step is to create a physical volume on your RAID disk. You can do this with the pvcreate
command:
sudo pvcreate /dev/sdd
Step 3: Create a Volume Group
After creating a physical volume, you need to create a volume group. You can do this with the vgcreate
command. In this example, I'll name the volume group "myvg":
sudo vgcreate myvg /dev/sdd
Step 4: Create a Logical Volume
Next, you need to create a logical volume within your volume group. You can do this with the lvcreate
command. In this example, I'll create a logical volume named "mylv" that uses all available space:
sudo lvcreate -l 100%FREE -n mylv myvg
Step 5: Create an ext4 File System
Now that you have a logical volume, you can create an ext4 file system on it. You can do this with the mkfs.ext4
command:
sudo mkfs.ext4 /dev/myvg/mylv
Step 6: Mount the File System
Finally, you need to mount the file system. First, create a directory where you'll mount the file system:
sudo mkdir /tank
Then, mount the file system to this directory:
sudo mount /dev/myvg/mylv /tank
Step 7: Make the Mount Permanent
To ensure the mount persists across reboots, you'll need to add an entry to the /etc/fstab
file. First, open the file with a text editor such as nano
:
sudo vim /etc/fstab
Then, add the following line at the end of the file:
/dev/myvg/mylv /tank ext4 defaults 0 0
Save and close the file. Now, the file system will be mounted automatically when the system boots.
That's it! You've now set up LVM and installed an ext4 file system on your RAID disk.\
- Create the directories:
sudo mkdir -p /tank/scratch/enis
sudo mkdir -p /tank/scratch/jcdevaney
sudo mkdir /tank/data
- Change the ownership of the directories to the respective users:
sudo chown enis:enis /tank/scratch/enis
sudo chown jcdevaney:jcdevaney /tank/scratch/jcdevaney
- Create a new group called
data
:
sudo groupadd data
- Add the users
enis
andjcdevaney
to thedata
group:
sudo usermod -a -G data enis
sudo usermod -a -G data jcdevaney
- Change the group ownership of the
/tank/data
directory to thedata
group:
sudo chgrp data /tank/data
- Set the permissions for the
/tank/data
directory todrwxrwsr-x
. This will give the owner and group members full access, and others read and execute access. Thes
in the group permissions field sets the setgid bit, which means new files and directories created under/tank/data
will inherit the group ownership:
sudo chmod 2775 /tank/data
- Symlink
/tank/scratch
to/scratch
cd /
sudo mkdir /scratch/
sudo ln -s /tank/scratch /scratch
To extend your LVM volume to use the entire disk space, you need to follow these steps:
(assumes disk is called /dev/sdd
and logical volume is myvg-mylv
)
- Resize the physical volume: First, you need to resize the physical volume on the disk. You can do this using the
pvresize
command. This command will resize the physical volume on/dev/sdd
to use all available space.
sudo pvresize /dev/sdd
- Extend the logical volume: After resizing the physical volume, you can now extend the logical volume. You can do this using the
lvextend
command. This command will extend the logical volumemyvg-mylv
to use all available space in the volume group.
sudo lvextend -l +100%FREE /dev/myvg/mylv
- Resize the filesystem: Finally, you need to resize the filesystem on the logical volume to use the new space. The command to do this depends on the type of filesystem you are using.
For ext4 filesystem, you can use the resize2fs
command:
sudo resize2fs /dev/myvg/mylv
After these steps, your logical volume should now be using the entire disk space. You can verify this by running the lsblk
command again.