Open In App

How to Add New Disk in Linux CentOS 7 Without Rebooting

Last Updated : 06 Dec, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

Let’s Say we hosted the DataBase on our Server Initially with 500GB given space and as we know  Database should run 24/7 because the user’s using it. One day it consumes space about 400GB only 100GB left Now we want to Increase the Space at the runtime only and In the case of static partitioning we need to restart the server but If we restart the server then our database goes down. So, here the role of the LVM concept comes into play. If you have noticed normally all the Linux flavor OS (except some lightweight) uses the LVM concept for the root folder also so that we are able to increase storage in online mode only.

Understand the Structure of LVM

Here, from this image, you will understand fastly. 

Now, Logically You Can Think Whenever You Wants to Extend the Size of the LV then You can add more size from the volume group and If the VG space is exhausted then add more HDD/EBS then create the PV of its then add those PV to VG so, that VG expands its size.

Steps to Add new disk space to Linux server using VMWare/VirtualBox

  • Goto -> Settings-> Storage

  • Click to Add Hard disk

  • Find the newly added hard disks. You can able to find the newly inserted disk by these commands.
$fdisk -l (List Partitions/Disks)

$lsblk

How we can increase the size of the Root Folder Without Restarting the Server?

Let’s First See the Detail about the mounted disk to the Root folder (/).

$df -h 

Detail about the ubuntu Logical Volume and Volume Group of it.

$ lvdisplay ubuntu-lv 

$ vgdisplay ubuntu-vg

After you added the Extra storage device to your server, create the PV as we know that VG supports the PV only.

$ pvcreate /dev/sdb1 (I have also done the partitioning of /dev/sdb with the help of $fdisk /dev/sdb.)

creating PV

$ pvdisplay (We are displaying here for the complete PV, So we can see the new PV added or not.)

Now, let’s extend the Volume Group with new PV

$ vgextend ubuntu-vg /dev/sdb1

vgextend output

Our VG Size Expanded or Not?

$ vgdisplay ubuntu-vg

Before Increasing the Size of the Same Logical Volume which is attached to the Root Lets see the details of it.

$ lvdisplay /dev/ubuntu-vg/ubuntu-lv

Extend the size of Logical Volume

$ lvextend --size +253G /dev/ubuntu-vg/ubuntu-lv

$ lvdisplay /dev/ubuntu-vg/ubuntu-lv 

As we can see the size of the LV is Increased but if do $df -h still it will so the previous size because we haven’t resize the format Which we are using i.e (ext4) [Most Important that this Resize Command only support format-type i.e ext4]. Only Half Part is formatted but not the complete part. This Command has a feature to formate it on the fly/online (Which means the read/write on that lv is going on).

$  resize2fs /dev/ubuntu-vg/ubuntu-lv (Expanding Space without Rebooting VM)

$ df -h

df -h output


Similar Reads

Basic CentOS Linux Commands in linux
CentOS is a free and open-source operating system that aims to provide a stable reliable, and community-supported platform for servers and other enterprise applications. In this article, we will be covering CentOS Linux basics commands and functions of CentOS and also we will look into the advanced commands. These CentOS commands allow you to manag
4 min read
CentOS Network Configuration without NetworkManager
As we know, to set up communication between the two systems we have to configure the network which means we have to define system IP, DNS, and gateway the communication can be through either Ethernet, Wi-Fi, or Bluetooth. Therefore a Linux user must know about the Network Configuration of any Linux Operating system so that the user can resolve some
4 min read
How to reset the root password of RedHat/CentOS Linux
RedHat Linux is a worldwide used OS in servers and networking devices. Red Hat lists Adobe, Ampersand and many among the top 500 fortune companies. They list Cisco, Dell, HP, and IBM as partners. Resetting the root password of RHEL is not a difficult task but rather you need to know 4 commands and you are into the root account! Root account in Linu
2 min read
How to Install Cockpit on Linux CentOS 7?
The cockpit is a free, open-source Linux Server Management Tool which provides you the facility to control your server using the mouse on the web-interface. The cockpit can be used to perform any server related task such as start containers, storage administration, and network configuration and much more. It has a very beautiful user interface alon
3 min read
How to Upgrade Linux Kernel on CentOS 7
The kernel is a central component of an operating system that manages the operations of the computer and hardware. It basically manages operations of memory and CPU time. It is a core component of an operating system. Kernel acts as a bridge between applications and data processing performed at the hardware level using inter-process communication a
2 min read
How to Compile Linux Kernel on CentOS 7
The kernel is the core of a computer's operating system that has complete control over the system and provides basic services for all other parts. The default kernel available in any distribution cannot be customized. We cannot enable or disable any feature on it. Running a custom-compiled Linux Kernel becomes very helpful in cases when the hardwar
3 min read
How to Audit Linux Process Using ‘autrace’ on CentOS/RHEL
Autrace is a command line tool that is used for the purpose of auditing processes on Linux. The audit rules which are created by autrace are stored in the /var/www/audit/audit.log file. Before autrace can work perfectly all the previous audit logs must be deleted. The syntax of autrace is given below: Syntax: autrace -r program program-args Note: H
3 min read
Configure CGroups in CentOS Linux
"CGroups" or "Control Groups" is a feature of the Linux kernel that allows us to control and restrict system resources (like CPU, memory, disk I/O, and network) for individual processes or groups of related processes. One of the main objectives is to manage and control the resource allocation of processes, ensuring fair and efficient usage of resou
6 min read
How to Convert a GPT Disk to MBR Disk?
GPT stands for GUID Partition Table it is a standard for the layout of partition tables of a physical computer storage device, such as Solid State drive or hard disk drive, used universally. The GPT drive format allows you to set up drives/disks that are larger than 4 terabytes and allows you to easily set up as many partitions as you want for conf
2 min read
How to Install PHP GD-library on CentOS?
GD is an open-source code library that helps to create and manipulate PNG, JPEG, and GIF images in PHP. GD is commonly used for the development of websites. Image resizing, cropping, drawing, and adding effects to dynamic rendering can easily be done with its help. Picture handling and GD capacities are utilized to make and control picture records
2 min read
Article Tags :