In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to add a hard disk and expand the capacity of LVM under CentOS7, which has a certain reference value, and interested friends can refer to it. I hope you will gain a lot after reading this article.
LVM is the abbreviation of LogicalVolume Manager (logical Volume Management). It is a mechanism for managing disk partitions in Linux environment. LVM virtualizes one or more disk partitions (PV) into a volume group (VG), which is equivalent to a large hard disk, on which we can divide some logical volumes (LV). When the volume group runs out of space, you can add new disk partitions. We can also divide some space from the remaining space of the volume group for logical volumes that do not have enough space.
The LVM model is shown below:
No need to restart and refresh new hard disk files
First, cat commands cat / proc/scsi/scsi to visit Id:?? What's the biggest. Then echo "scsiadd-single-device 0 0? + 1 0" > / proc/scsi/scsi
Cat / proc/scsi/scsi > >
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id:00 Lun: 00
Vendor: NECVMWar Model: VMware IDECDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi0 Channel: 00 Id:01 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
2. After the addition is completed
1. Add a hard disk (8GB) to the system
Use fdisk-l to see that the new disk is / dev/vdb:
1shell# fdisk-l
2. Partition the new disk
Use the fdisk command to partition the new disk, where you create a primary partition / dev/vdb1 with the size 8GB, and finally use the partprobe (or partx-u) command to re-read the partition table:
1shell# fdisk / dev/vdb
2shell# partprobe
During the partition process, pay attention to setting the format to 8e, which is the partition format of LVM.
3. Create a physical volume (PV)
Use the pvcreate command to create a physical volume, and pvdisplay to view the physical volume information:
1shell# pvcreate / dev/vdb1
2shell# pvdisplay
4. Add PV to the volume group (VG)
VG create # vgcreate VG name device name
Use vgdisplay to view the volume group information. The following figure shows that the volume group name is centos and the free size is 0:
1shell# vgdisplay
Use the vgextend command to add / dev/vdb1 to the centos:
1shell# vgextend centos / dev/vdb1
We re-examine the volume group information and find that the free space is 8GB, indicating that / dev/vdb1 has been successfully added:
5. Create a logical volume (LV)
Use the lvcreate command to partition a new logical volume from the volume group, where you create a logical volume partition with the name newlv and size 4GB, and use lvdisplay to view the logical volume information:
1shell# lvcreate-L 4G-n newlv centos (specify to add 4G capacity)
2 lvcreate-l + 100%free-n newlv centos (add maximum available capacity)
Shell# lvdisplay
Let's check the volume group information again. There is no 4GB space left in the volume group:
6. Format logical volumes and mount them
The new logical volume is formatted and can be mounted to the system to store data. Use the xfs file system formatted as CentOS7 with mkfs.xfs:
1shell# mkfs.xfs / dev/centos/newlv
Mount it to the / mnt directory (you can mount it to the directory you need). After mounting it, you can see that the capacity is 4GB:
1shell# mount-t xfs / dev/centos/newlv / mnt/
2shell# df-Th
Set auto mount on boot, edit / etc/fstab file, and add the last line:
1/dev/centos/newlv/mntxfs defaults1 2
7. Logical volume expansion
Use the lvextend command to expand the logical volume. I allocated all the remaining space to newlv and increased it to 8GB, as shown in the following figure:
1shell# lvextend-l + 100%FREE / dev/centos/newlv
Use the xfs_growfs command to resize the xfs format file system online (CentOS6 uses resize2fs):
1shell# xfs_growfs / dev/centos/newlv
Finally, we see that the logical volume partition has been dynamically expanded to 8GB.
Thank you for reading this article carefully. I hope the article "how to add hard disk and expand capacity in LVM under CentOS7" shared by the editor will be helpful to everyone. At the same time, I also hope you can support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
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.