How to expand the disk space of Linux server

How to expand the disk space of Linux server

Preface

Today I found that es logs were not recorded. After checking filebeat, elasticsearch, and logstash, I found that the es indexes had become read-only. After manually modifying the index mode, it became read-only again after a few minutes.

After further reading, I found out that the reason is that once any index of one or more shards is allocated on a node that stores more than 95% of the disk, the index will be forced into read-only mode. So the only option is to expand the disk space. The following briefly describes the steps for disk expansion.

step

The disk already had two partitions, but the allocated space was not large.

fdisk -l to check the disk mount status

Add a disk and mount the new disk sdc through the management terminal;

Add sdc disk partition

Use fdisk /dev/sdc to create a new partition;

[root@localhost indices]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x5799aeba.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: The size of this disk is 2.2 TB (2199023255552 bytes).
DOS partition table format can not be used on drives for volumes
larger than (2199023255040 bytes) for 512-byte sectors. Use parted(1) and GUID 
partition table format (GPT).


WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): n #new new partition Command action
   e extended
   p primary partition (1-4)
p #Select the primary sector Partition number (1-4): 1 #Starting sector First cylinder (1-267349, default 1): #Press Enter here to take the default value 1
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-267349, default 267349): #Since es requires a large amount of storage space, I have added 2T of space. Normally, the sector size can be modified as required. Using default value 267349

Command (m for help): w #Save and exit The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Then create a physical volume using the pvcreate /dev/sdc1 command. Note: Many articles here require you to restart the system, but you don’t actually need to restart the system here. You can do it directly without affecting the normal operation of the server.

[root@localhost indices]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created

Use vgscan to view the physical volume group name;

[root@localhost indices]# vgscan
  Reading all physical volumes. This may take a while...
  Found volume group "VolGroup" using metadata type lvm2
  #The physical volume group name here is VolGroup

Load the newly added physical sectors into the volume group, here use vgextend VolGroup /dev/sdc1;

[root@localhost indices]# vgextend VolGroup /dev/sdc1
  Volume group "VolGroup" successfully extended

Increase the size of the volume group. Here, use lvextend -L +2048G /dev/mapper/VolGroup-lv_root.

[root@localhost indices]# lvextend -L +2048G /dev/mapper/VolGroup-lv_root
  Size of logical volume VolGroup/lv_root changed from 135.47 GiB (34681 extents) to 2.13 TiB (558848 extents).
  Logical volume lv_root successfully resized.

Use df -h to check the space expansion status and find that the space has not been expanded. This is because the file system has not been synchronized.

[root@localhost indices]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      134G 119G 8.4G 94% /
tmpfs 32G 72K 32G 1% /dev/shm
/dev/sda1 477M 41M 411M 10% /boot

Synchronize the file system. Use xfs_growfs or resize2fs to synchronize the file system. Do the following:

[root@localhost indices]# resize2fs -f /dev/mapper/VolGroup-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old_desc_blocks = 9, new_desc_blocks = 137
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 572260352 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 572260352 blocks long.

Then use df -h to view the space expansion status

[root@localhost indices]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
                      2.1T 125G 1.9T 7% /
tmpfs 32G 72K 32G 1% /dev/shm
/dev/sda1 477M 41M 411M 10% /boot

Since the file system formats of the default root file systems of CentOS6 and CentOS7 are different, it is necessary to determine whether it is xfs. If it is xfs, xfs_growfs should be used instead of resize2fs.

This is the end of this article about how to expand the disk space of a Linux server. For more information about how to expand the disk space of a Linux server, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Detailed steps to expand LVM disk in Linux
  • How to mount a disk in Linux
  • Detailed examples of Linux disk device and LVM management commands
  • How to mount a new disk on a Linux cloud server

<<:  Summary of commonly used CSS encapsulation methods

>>:  Two methods to stretch the background image of a web page

Recommend

JS implements random roll call system

Use JS to implement a random roll call system for...

Tutorial on installing MySQL on Alibaba Cloud Centos 7.5

It seems that the mysql-sever file for installing...

Steps to configure nginx ssl to implement https access (suitable for novices)

Preface After deploying the server, I visited my ...

How to access MySql through IP address

1. Log in to mysql: mysql -u root -h 127.0.0.1 -p...

Detailed explanation of the MySQL MVCC mechanism principle

Table of contents What is MVCC Mysql lock and tra...

Design theory: people-oriented green design

Reflections on the two viewpoints of “people-orie...

Introduction to vim plugin installation under Linux system

Table of contents Install vim plugin manager Add ...

Detailed explanation of commonly used CSS styles (layout)

Compatible with new CSS3 properties In CSS3, we c...

Installation and use of Ubuntu 18.04 Server version (picture and text)

1 System Installation Steps OS Version:1804 Image...

vue-cli4.5.x quickly builds a project

1. Install vue-cli npm i @vue/cli -g 2. Create a ...

Analysis of the principle of Rabbitmq heartbea heartbeat detection mechanism

Preface When using RabbitMQ, if there is no traff...

Creating Responsive Emails with Vue.js and MJML

MJML is a modern email tool that enables develope...

Let you understand the deep copy of js

Table of contents js deep copy Data storage metho...

vite2.x implements on-demand loading of ant-design-vue@next components

1. Use version vite:2.0 ant-design-vue: 2.0.0-rc....

How to redirect PC address to mobile address in Vue

Requirements: The PC side and the mobile side are...