Add new disks to CentOS 7 without rebooting the system

Source: Internet
Author: User

for most system administrators, expanding the disk space of a Linux server is one of the daily tasks, especially for VMware-series virtual machines.
    • Expand the space without restarting the virtual machine:

Now run the following command by rescanning the SCSI (Note: Small computer system Interface small Computer system interface) bus and adding SCSI devices, the system can expand the physical volume of the operating system disk space, and do not need to restart the virtual machine.

# ls/sys/class/scsi_host/# Echo "---" >/sys/class/scsi_host/host0/scan# echo "---" >/sys/class/scsi_host/host 1/scan# echo "---" >/sys/class/scsi_host/host2/scan

Use the following command to check the SCSI device name and then rescan the SCSI bus.

# ls/sys/class/scsi_device/# echo 1 >/sys/class/scsi_device/0\:0\:0\:0/device/rescan# echo 1 >/sys/class/scsi_ Device/2\:0\:0\:0/device/rescan

As shown, the SCSI bus is re-scanned, and then the size of the disk that we set on the virtual machine client is displayed normally.

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m00/8b/4e/wkiol1hjzxhrp388aabsijx8vgi213.png "height=" 209 "/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/8b/52/wkiom1hjzxkhp0dsaaahviiznnc714.png "height="/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/8b/4e/wkiol1hjzxkt2qiqaaaklcyfe78539.png "height="/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m02/8b/52/wkiom1hjzxltw6e_aaaep8yu7ym857.png "height=" 98 "/>

=========================================================

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m02/8b/4e/wkiol1hjzxttypmraacdwapyxew578.png "height=" 469 "/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/8b/52/wkiom1hjzxwalcteaaa7pbomvn0623.png "height="/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/8b/4e/wkiol1hjzxbjox30aaasm8bqmvw629.png "height="/>

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/8b/52/wkiom1hjzxjhikgoaadeetokyrg975.png "height=" 571 "/>

=========================================================

    • To expand the root partition without restarting the system by adding a new disk:

This is the second way to increase the amount of logical volume on a CentOS 7 system.
Go to the server and repeat the following command to scan your disk device to make the new disk visible in the system.

# echo "--" >/sys/class/scsi_host/host0/scan# echo "---" >/sys/class/scsi_host/host1/scan# echo "--" > /sys/class/scsi_host/host2/scan

List the name of your SCSI device:

# ls/sys/class/scsi_device/# echo 1 >/sys/class/scsi_device/1\:0\:0\:0/device/rescan# echo 1 >/sys/class/scsi_ device/2\:0\:0\:0/device/rescan# echo 1 >/sys/class/scsi_device/3\:0\:0\:0/device/rescan# fdisk-l

Once the new disk is visible, you can run the following command to create a new physical volume and then add it to the volume group.

# pvcreate/dev/sdb# Vgextend centos/dev/sdb# Vgdisplay

Now expand the logical volume based on the space size of the disk, and then add it to the root partition.

# lvextend-l +10g/dev/mapper/centos-root# xfs_growfs/dev/mapper/centos-root# df–h
Entries "http://chinahao.blog.51cto.com/"
=========================================================
Expansion:

Why is it under the/sys directory:

This directory is in fact very similar to/proc, is also a virtual file system, mainly records the core and system hardware information more relevant information.

Includes the core modules currently loaded and the core detected hardware device information and so on. This directory also does not account for hard disk capacity!

the /sys/ Directory:

The /sys/ directory utilizes the new sysfs virtual file system specific to the kernel. With the increased support for hot plug hardware devices in the kernel, the /sys/ directory contains information similar /proc/to the held by, but displays a hierarchical view of the device information specific to hot plug devices.

SCSI disk scanning mechanism. VMware virtual machines Add SCSI hard drives, the system does not restart recognition can use the command #echo '---' >/sys/class/scsi_host/hostn/scan (n depending on the actual situation).

650) this.width=650; "src=" Http://s5.51cto.com/wyfs02/M00/85/1D/wKioL1eaCDPhimYIAAUiBNir7lA527.png "alt=" Wkiol1eacdphimyiaauibnir7la527.png "/>


This article is from the "Chinahao" blog, make sure to keep this source http://chinahao.blog.51cto.com/5507815/1880943

Add new disks to CentOS 7 without rebooting the system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.