A file system is in charge of arranging and handling data on storage devices like hard drives and solid-state drives (SSDs).
Check whether disk is HDD or HDD
$lsblk -o name, rota | tail
$cat /sys/block/sda/queue/rotational
Most of the time we use either ext4 or xfs filesystem however as per the requirement you could create different filesystem.
To see the the filesystem type run the following command:
Most of the time we use either ext4 or xfs filesystem, To create a disk filesystem run the following command.
$ sudo mkfs -t xfs /dev/sda
To see the mount point use lsblk command:
How to create LVM on AWS?
LVM is useful when you don't want your system to go in maintainence windows and dynamically you want to extend the filesystem size irrespective for disks.
To install LVM on EC2, run the following command:
Let's say the device you attached to EC2 are /dev/sda, /dev/sdb and /dev/sdc
Use pvcreate command that initialize the disk or essentially partitions so that it can be used by LVM
To see the created physical volume you could run the following command:
Now create the LVM volume group:
$sudo vgcreate xyz /dev/sda /dev/sdb /dev/sdc
Now create logical volumes
$sudo lvcreate --name data --size 5GB xyz
$sudo lvcreate --name backup --size 15GB xyz
$mkfs.ext4 /dev/xyz/backup
$sudo mkdir /backup
$sudo mount /dev/xyz/data /data
$sudo mount /dev/xyz/backup /backup
How to increase the root volume of EC2 instance
Just restart the instance or running the following command if you don't want to stop the instance:
$sudo growpart /dev/xvda 1
$sudo xfs_growfs -d /
Add New EBS volume to EC2 instance:
$df -hT
$mkdir /data
$sudo mkfs -t xfs -f /dev/xvdb
$sudo mount /dev/xvdb /data
Create partition:
$sudo fdisk /dev/xvdb
p
1
+1G
n
p
2
+1G
n
p
3
w
q
# Verify partitions
$lsblk
# Format the partitions with ext4 filesystem
$sudo mkfs.ext4 /dev/xvdb1
$sudo mkfs.ext4 /dev/xvdb2
$sudo mkfs.ext4 /dev/xvdb3
# Create mount points
$sudo mkdir -p /mnt/partition1 /mnt/partition2 /mnt/partition3
# Mount the partitions
$sudo mount /dev/xvdb1 /mnt/partition1
$sudo mount /dev/xvdb2 /mnt/partition2
$sudo mount /dev/xvdb3 /mnt/partition3
References:
- https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.htmlhttps://repost.aws/knowledge-center/create-lv-on-ebs-partition
0 Comments