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

Solution to the ineffective margin of div nested in HTML

Here's a solution to the problem where margin...

How to create a swap partition file in Linux

Introduction to Swap Swap (i.e. swap partition) i...

How to solve the 10060 unknow error when Navicat remotely connects to MySQL

Preface: Today I want to remotely connect to MySQ...

SQL Server database error 5123 solution

Because I have a database tutorial based on SQL S...

Example of how to change the domestic source in Ubuntu 18.04

Ubuntu's own source is from China, so the dow...

Exploring the Linux Kernel: The Secrets of Kconfig

Get a deep understanding of how the Linux configu...

Summary of naming conventions for HTML and CSS

CSS naming rules header: header Content: content/c...

An article to understand the use of proxies in JavaScript

Table of contents What is an agent Basic knowledg...

Examples of using temporary tables in MySQL

I've been a little busy these two days, and t...

Detailed tutorial for installing MySQL 8.0.11 compressed version under win10

After reinstalling my computer recently, I downlo...

Mysql database recovery actual record by time point

Introduction: MySQL database recovery by time poi...

Complete code for implementing the vue backtop component

Effect: Code: <template> <div class=&quo...

Linux automatically deletes logs and example commands from n days ago

1. Delete file command: find the corresponding di...

Mysql online recovery of undo table space actual combat record

1 Mysql5.6 1.1 Related parameters MySQL 5.6 adds ...