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

Detailed explanation of nginx anti-hotlink and anti-crawler configuration

Create a new configuration file (for example, go ...

How to use ElementUI pagination component Pagination in Vue

The use of ElementUI paging component Pagination ...

Detailed tutorial on configuring nginx for https encrypted access

environment: 1 CentOS Linux release 7.5.1804 (Cor...

Detailed explanation of MySQL high availability architecture

Table of contents introduction MySQL High Availab...

Detailed explanation of the use of DockerHub image repository

Previously, the images we used were all pulled fr...

jQuery implements font size adjustment case

This article shares the specific code of jQuery t...

Use Navicate to connect to MySQL on Alibaba Cloud Server

1. First enter the server's mysql to modify p...

Introduction to container of() function in Linux kernel programming

Preface In Linux kernel programming, you will oft...

Tips for importing csv, excel or sql files into MySQL

1. Import csv file Use the following command: 1.m...

JS achieves five-star praise effect

Use JS to implement object-oriented methods to ac...

Detailed troubleshooting of docker.service startup errors

Execute the following command to report an error ...

Specific use of Linux man command

01. Command Overview Linux provides a rich help m...

How to introduce scss into react project

First download the dependencies yarn add sass-loa...