Skip to content

Instantly share code, notes, and snippets.

@matteyeux
Created July 11, 2023 15:13
Show Gist options
  • Save matteyeux/b99f3cd5f7f42256512366c734ae2b9e to your computer and use it in GitHub Desktop.
Save matteyeux/b99f3cd5f7f42256512366c734ae2b9e to your computer and use it in GitHub Desktop.

We will add a 15GB disk for a specific partition : /var/db/elasticsearch

List the disks :

[root@centos8s vagrant]# fdisk -l 
Disk /dev/vda: 128 GiB, 137438953472 bytes, 268435456 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe8eb5d96

Device     Boot   Start       End   Sectors  Size Id Type
/dev/vda1  *       2048   2099199   2097152    1G 83 Linux
/dev/vda2       2099200 268435455 266336256  127G 8e Linux LVM

Disk /dev/vdb: 20 GiB, 21474836480 bytes, 41943040 sectors <- this one
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/cs_centos8s-root: 125 GiB, 134154813440 bytes, 262021120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/cs_centos8s-swap: 2.1 GiB, 2206203904 bytes, 4308992 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Create the Physical volume (PV):

[root@centos8s vagrant]# pvcreate /dev/vdb
  Physical volume "/dev/vdb" successfully created.

Create the Volume Group (VG)

[root@centos8s vagrant]# vgcreate elk /dev/vdb 
  Volume group "elk" successfully created

Create the Logicial Volume (LV)

[root@centos8s vagrant]# lvcreate -L 15G -n elk_data elk
  Logical volume "elk_data" created

Create the filesystem

[root@centos8s vagrant]#  mkfs.ext4 /dev/mapper/elk-elk_data 
mke2fs 1.45.6 (20-Mar-2020)
Discarding device blocks: done                            
Creating filesystem with 3932160 4k blocks and 983040 inodes
Filesystem UUID: 705f81e8-77fd-4858-81ab-44ee9a7baf7b
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208
Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done   

Add this line to /etc/fstab :

/dev/mapper/elk-elk_data /var/db/elasticsearch ext4 defaults 0 0

Run mount -a and flex:

[root@centos8s vagrant]# df -h 
Filesystem                    Size  Used Avail Use% Mounted on
devtmpfs                      7.8G     0  7.8G   0% /dev
tmpfs                         7.8G     0  7.8G   0% /dev/shm
tmpfs                         7.8G   17M  7.8G   1% /run
tmpfs                         7.8G     0  7.8G   0% /sys/fs/cgroup
/dev/mapper/cs_centos8s-root  125G  2.7G  123G   3% /
/dev/vda1                    1014M  205M  810M  21% /boot
tmpfs                         1.6G     0  1.6G   0% /run/user/1000
/dev/mapper/elk-elk_data       15G   24K   14G   1% /var/db/elasticsearch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment