Linux系统硬盘扩容
参考教程:https://www.jb51.net/article/144291.htm
1、查看硬盘已经用了99%
$ df -h #查看硬盘已经使用了99% 文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 2.0G 0 2.0G 0% /dev tmpfs 2.0G 12K 2.0G 1% /dev/shm tmpfs 2.0G 11M 2.0G 1% /run tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/mapper/centos-root 47G 47G 687M 99% / ##### 已经使用了99% /dev/sda1 1014M 223M 792M 22% /boot
2、添加一块硬盘
$ fdisk -l 磁盘 /dev/sda:53.7 GB, 53687091200 字节,104857600 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x000c1008 设备 Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 104857599 51379200 8e Linux LVM 磁盘 /dev/sdb:53.7 GB, 53687091200 字节,104857600 个扇区 ####虚拟机的一块硬盘sdb Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘 /dev/mapper/centos-root:50.5 GB, 50461671424 字节,98557952 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节
3、为新硬盘创建分区
fdisk /dev/sdb # 依次输入 n #新加分区 p #选择主分区 1 #输入的分区号 #默认 回车2次 w #保存 fdisk -l #然后查看 磁盘 /dev/sdb:53.7 GB, 53687091200 字节,104857600 个扇区 Units = 扇区 of 1 * 512 = 512 bytes 扇区大小(逻辑/物理):512 字节 / 512 字节 I/O 大小(最小/最佳):512 字节 / 512 字节 磁盘标签类型:dos 磁盘标识符:0x4471fda0 设备 Boot Start End Blocks Id System /dev/sdb1 2048 104857599 52427776 83 Linux ####新加的sdb1
4、然后重启Linux系统,创建物理卷,并把硬盘加到根分区
$ pvcreate /dev/sdb1 #创建物理卷 #提示如下 Physical volume "/dev/sdb1" successfully created. $ pvdisplay #查看新建的物理卷大小 #显示如下 --- Physical volume --- PV Name /dev/sda2 VG Name centos PV Size <49.00 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12543 Free PE 0 Allocated PE 12543 PV UUID lAdKvz-0Hje-Sh68-P2a0-4sPd-08id-hFWSZ4 "/dev/sdb1" is a new physical volume of "<50.00 GiB" #50G --- NEW Physical volume --- PV Name /dev/sdb1 VG Name PV Size <50.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID ZU3GHf-rrcb-0O79-qWvK-M2y1-CS1s-kSTTqA $ vgextend centos /dev/sdb1 #将物理卷添加到centos卷组 #显示如下 Volume group "centos" successfully extended $ vgdisplay #然后查看卷组信息 # 显示如下 --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 98.99 GiB PE Size 4.00 MiB Total PE 25342 Alloc PE / Size 12543 / <49.00 GiB Free PE / Size 12799 / <50.00 GiB VG UUID 6rufcq-tnjL-Vsti-Apdx-0AVA-UpFh-aQieyJ $ lvresize -L +49.00G /dev/mapper/centos-root #增加centos大小 #显示如下 Size of logical volume centos/root changed from <47.00 GiB (12031 extents) to <96.00 GiB (24575 extents). Logical volume centos/root successfully resized. $ xfs_growfs /dev/mapper/centos-root #重新识别centos 大小 #显示如下 meta-data=/dev/mapper/centos-root isize=512 agcount=4, agsize=3079936 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0 data = bsize=4096 blocks=12319744, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=1 log =internal bsize=4096 blocks=6015, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 12319744 to 25164800 $ df -h #以上就添加完成,最后查看下硬盘大小 文件系统 容量 已用 可用 已用% 挂载点 devtmpfs 2.0G 0 2.0G 0% /dev tmpfs 2.0G 12K 2.0G 1% /dev/shm tmpfs 2.0G 11M 2.0G 1% /run tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup /dev/mapper/centos-root 96G 47G 50G 49% / #######已经编写96G了 /dev/sda1 1014M 223M 792M 22% /boot
相关推荐
jiangtie 2020-05-11
onlykg 2020-05-04
xiyoukeke 2020-07-19
tianhuak 2020-11-24
86276537 2020-11-19
大牛牛 2020-10-30
flycappuccino 2020-09-27
卢从利 2020-10-10
无忧老猪 2020-10-09
学峰的学习笔记 2020-10-05
85216033 2020-09-16
兄dei努力赚钱吧 2020-09-06
89334799 2020-08-12
ruanhongbiao 2020-08-16
邓博学习笔记 2020-08-03
ningningmingming 2020-07-28
zhongzhiwei 2020-07-27
Jiajinjin 2020-07-27