简要说明哈情况:默认分的磁盘空间不够需要扩容,呵呵!查找资料实践后记录哈步骤。
- 查看现有磁盘空间占用情况
[root@x cc]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 18G 5.7G 12G 33% / devtmpfs 898M 0 898M 0% /dev tmpfs 913M 53M 861M 6% /dev/shm tmpfs 913M 8.9M 904M 1% /run tmpfs 913M 0 913M 0% /sys/fs/cgroup /dev/sda1 497M 211M 286M 43% /boot tmpfs 183M 12K 183M 1% /run/user/1000
-
对新增的硬盘空间新增分区(具体显示根据系统环境确定)
[root@x cc]# fdisk /dev/sda 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 命令(输入 m 获取帮助):n #新增分区 ......p Partition number (1-4): 3 #新增分区号(1,2已经使用) First cylinder (41943040-62914559, default 41943040): #默认回车 ...... Last cylinder or +size or +sizeM or +sizeK(41943040-62914559, default 62914559): #默认回车 命令(输入 m 获取帮助):t #修改分区类型 Partition number (1-4): 3 #修改分区类型对应的分区号 Hex code (type L to list codes): 8e #8e是lvm磁盘类型 ...... 命令(输入 m 获取帮助):p #查看打印分区表 命令(输入 m 获取帮助):w #保存退出 ...... [root@x cc]# reboot #重启系统
-
查看硬盘情况
[root@x cc]# fdisk -l ...... 设备 Boot Start End Blocks Id System /dev/sda1 * 2048 1026047 512000 83 Linux /dev/sda2 1026048 41943039 20458496 8e Linux LVM /dev/sda3 41943040 62914559 10485760 8e Linux LVM ......
-
查看当前分区类型
[root@x cc]# df -T /dev/sda1 文件系统 类型 1K-块 已用 可用 已用% 挂载点 /dev/sda1 xfs ...... #CentOS7的默认文件系统类型是xfs
-
新磁盘创建文件系统
[root@x cc]# mkfs.xfs /dev/sda3 #xfs如上文件系统类型 meta-data=/dev/sda3 isize=256 agcount=4, agsize=655360 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=2621440, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal log bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0
-
创建PV(PV【物理卷】是VG【卷组】的组成部分,LV【逻辑卷】就是从VG中划分出来的卷,深究的建议查哈资料)
[root@x cc]# pvcreate /dev/sda3 WARNING: xfs signature detected on /dev/sda3 at offset 0. Wipe it? [y/n]: y Wiping xfs signature on /dev/sda3. Physical volume "/dev/sda3" successfully created [root@x cc]# vgdisplay #查看vg状态
-
创建的PV加入VG
[root@x cc]# vgextend centos /dev/sda3 #centos为查看vg状态得到名称VG name Volume group "centos" successfully extended
-
查看LV状态
[root@x cc]# lvdisplay ...... --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID ............. LV Write Access read/write LV Creation host, time x, 2016-06-16 09:19:45 +0800 LV Status available # open 1 LV Size 17.47 GiB Current LE 4472 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 [root@x cc]# pvdisplay #查看pv状态 --- Physical volume --- PV Name /dev/sda3 VG Name centos PV Size 10.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 2559 Free PE 2559 Allocated PE 0 PV UUID ...................
-
逻辑卷扩容
[root@x cc]# lvextend -l +2559 /dev/centos/root Size of logical volume centos/root changed from 17.47 GiB (4472 extents) to 27.46 GiB (7031 extents). Logical volume root successfully resized. #2559为上面pvdisplay查看到的free的PE数量
-
resize2fs调整大小
[root@x cc]# resize2fs /dev/mapper/centos-root #/dev/mapper/centos-root为“/”挂载点的名字,df -h命令中查看。 resize2fs 1.42.9 (28-Dec-2013) resize2fs: Bad magic number in super-block 当尝试打开 /dev/mapper/centos-root 时找不到有效的文件系统超级块. ------------------------------------------------------------- #这里有个错误(主要因为xfs文件系统:扩展一个现存的XFS文件系统,使用命令行工具xfs_grows)提示解决如下 [root@x cc]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- 27.46g swap centos -wi-ao---- 2.00g [root@x cc]# df -lh 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 18G 5.7G 12G 33% / devtmpfs 898M 0 898M 0% /dev tmpfs 913M 71M 843M 8% /dev/shm tmpfs 913M 8.9M 904M 1% /run tmpfs 913M 0 913M 0% /sys/fs/cgroup /dev/sda1 497M 211M 286M 43% /boot tmpfs 183M 12K 183M 1% /run/user/1000 [root@x cc]# xfs_growfs /dev/mapper/centos-root meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=1144832 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 data = bsize=4096 blocks=4579328, imaxpct=25 = sunit=0 swidth=0 blks naming =version 2 bsize=4096 ascii-ci=0 ftype=0 log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1 realtime =none extsz=4096 blocks=0, rtextents=0 data blocks changed from 4579328 to 7199744 [root@x cc]# df -lh 文件系统 容量 已用 可用 已用% 挂载点 /dev/mapper/centos-root 28G 5.7G 22G 21% / devtmpfs 898M 0 898M 0% /dev tmpfs 913M 71M 843M 8% /dev/shm tmpfs 913M 8.9M 904M 1% /run tmpfs 913M 0 913M 0% /sys/fs/cgroup /dev/sda1 497M 211M 286M 43% /boot tmpfs 183M 12K 183M 1% /run/user/1000 #显示扩展已完成
PS:具体步骤如上了,已实践测试!