In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)05/31 Report--
Today Xiaobian to share with you how to add a new disk in CentOS 7 without restarting the system related knowledge points, detailed content, clear logic, I believe most people still know too much about this knowledge, so share this article for everyone to refer to, I hope you have some harvest after reading this article, let's learn about it together.
1. Expand disk space on the VM client side:
Before adding disk volumes to your linux system, you first need to add a new physical disk, or set up to increase the capacity of a virtual disk in vmware vshere, vmware workstations, and other virtual environment software you use.
2. Check disk space:
Run the following command to check the current disk space size.
# df -h# fdisk -l
As you can see, although we've increased it to 50 gb on the backend, the total disk size at this point is still 10 gb.
3. Scale space without restarting virtual machines
Now run the following command to expand the operating system's physical volume disk space by rescanning the scsi bus and adding scsi devices without restarting the virtual machine.
# ls /sys/class/scsi_host/# echo "- - -" > /sys/class/scsi_host/host0/scan# echo "- - -" > /sys/class/scsi_host/host1/scan# echo "- - -" > /sys/class/scsi_host/host2/scan
Use the following command to check the scsi device name and 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 below, the scsi bus is rescanned and the disk size we set on the VM client is displayed correctly.
4. Create a new disk partition:
Once the expanded disk space is visible in the system, you can run the following command to format your disk to create a new partition. Follow these steps to expand your physical disk volume.
# fdisk /dev/sdawelcome to fdisk (util-linux 2.23.2) press the 'm' key for helpcommand (m for help): mcommand actiona toggle a bootable flagb edit bsd disklabelc toggle the dos compatibility flagd delete a partitiong create a new empty gpt partition tableg create an irix (sgi) partition tablel list known partition typesm print this menun add a new partitiono create a new empty dos partition tablep print the partition tableq quit without saving changess create a new empty sun disklabelt change a partition's system idu change display/entry unitsv verify the partition tablew write table to disk and exitx extra functionality (experts only)command (m for help):
Type 'p' to view the current partition table information, then type 'n' to create a new primary partition, selecting all available sectors. Use the't'command to change the disk type to'linux lvm'and select encoding' 8e 'or leave it unchecked by default, which defaults to type encoding' 83'.
Now type 'w' to save the partition table information and exit the command environment as follows:
command (m for help): wthe partition table has been altered! calling ioctl() to re-read partition table.warning: re-reading the partition table failed with error 16: device or resource busy.the kernel still uses the old table. the new table will be used atthe next reboot or after you run partprobe(8) or kpartx(8)
5. Create a physical volume:
Following the prompts above, run the 'partprob' or 'kpartx' command to validate the partition table, and then create a new physical volume using the following command:
# partprobe# pvresize /dev/sda3
To check the newly created volume, run the following command to see if the new physical volume has been created and is available. Next, we can use this new physical volume to extend the 'centos' volume group as follows:
# pvdisplay# vgextend centos /dev/sda3
6. Expand logical volumes:
Now we expand logical volumes to increase the disk space our system is using the following command.
# lvextend -l +40g /dev/mapper/centos-root
Once you return a successful increase message, you can run the following command to expand your logical volume size.
# xfs_growfs /dev/mapper/centos-root
The size of the '/' partition has been successfully increased. Use the 'df' command to check the size of your disk drive. As shown in the diagram.
7. Expand the root partition by adding new disks without restarting the system:
This is the second method, which uses a very simple command to increase logical volume space on centos 7 systems.
So the first step is to open the settings page of your virtual machine client, click the 'Add' button, and then proceed to the next step.
Select the configuration information required for the new disk, as shown below. Select the size of the new disk and its type.
Then go to the server and repeat the following command to scan your disk devices 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 add it to the volume group, as shown below.
# pvcreate /dev/sdb# vgextend centos /dev/sdb# vgdisplay
Now expand the logical volume based on the space size of this disk and add it to the root partition.
# lvextend -l +20g /dev/mapper/centos-root# xfs_growfs /dev/mapper/centos-root# df -h Above is "How to add new disks in CentOS 7 without restarting the system" All the contents of this article, thank you for reading! I believe everyone has a great harvest after reading this article. Xiaobian will update different knowledge for everyone every day. If you want to learn more knowledge, please pay attention to the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.