centos7虚拟机下扩展根目录(/)空间

1、把新添加磁盘进行分区

[root@zbpt ~]# fdisk /dev/vdb
欢迎使用 fdisk (util-linux 2.23.2)。

更改将停留在内存中,直到您决定将更改写入磁盘。
使用写入命令前请三思。

Device does not contain a recognized partition table
使用磁盘标识符 0xab9f9f97 创建新的 DOS 磁盘标签。

命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
分区号 (1-4,默认 1):1
起始 扇区 (2048-209715199,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-209715199,默认为 209715199):
将使用默认值 209715199
分区 1 已设置为 Linux 类型,大小设为 100 GiB

命令(输入 m 获取帮助):exit
e: unknown command
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition’s system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

命令(输入 m 获取帮助):^C

2、查看分好的区

[root@zbpt ~]# fdisk -l

磁盘 /dev/vda:21.5 GB, 21474836480 字节,41943040 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0x000aadf4

设备 Boot Start End Blocks Id System
/dev/vda1 * 2048 2099199 1048576 83 Linux
/dev/vda2 2099200 41943039 19921920 8e Linux LVM

磁盘 /dev/mapper/nlas-root:18.2 GB, 18249416704 字节,35643392 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

磁盘 /dev/mapper/nlas-swap:2147 MB, 2147483648 字节,4194304 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

磁盘 /dev/vdb:107.4 GB, 107374182400 字节,209715200 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节

3,查看列出已分好的磁盘

[root@zbpt ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
vda 252:0 0 20G 0 disk
├─vda1 252:1 0 1G 0 part /boot
└─vda2 252:2 0 19G 0 part
├─nlas-root 253:0 0 17G 0 lvm /
└─nlas-swap 253:1 0 2G 0 lvm [SWAP]
vdb 252:16 0 100G 0 disk

4,进行逻辑卷处理

[root@zbpt ~]# lvm
lvm> pvcreate /dev/vdb
Physical volume “/dev/vdb” successfully created.
lvm> pvdisplay
— Physical volume —
PV Name /dev/vda2
VG Name nlas
PV Size <19.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4863
Free PE 0
Allocated PE 4863
PV UUID ebYzae-wPt4-afDx-YsJP-A3qs-3CGZ-Mve4nf

“/dev/vdb” is a new physical volume of “100.00 GiB”
— NEW Physical volume —
PV Name /dev/vdb
VG Name
PV Size 100.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID a9tZi8-GLX7-EYWt-GoSL-2dAS-VFwj-EUxt95

lvm> vgs
VG #PV #LV #SN Attr VSize VFree
nlas 1 2 0 wz–n- <19.00g 0
lvm> vgextend nlas /dev/vdb
Volume group “nlas” successfully extended
lvm> lvextend -l +100%FREE /dev/nlas/root
Size of logical volume nlas/root changed from <17.00 GiB (4351 extents) to 116.99 GiB (29950 extents).
Logical volume nlas/root successfully resized.
lvm> quit
Exiting.

5,执行根目录扩展空间命令

[root@zbpt ~]# xfs_growfs /dev/nlas/root
meta-data=/dev/mapper/nlas-root isize=512 agcount=4, agsize=1113856 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=4455424, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
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 4455424 to 30668800

6,查看是否已扩展成功

[root@zbpt ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/nlas-root 117G 4.3G 113G 4% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 0 7.8G 0% /dev/shm
tmpfs 7.8G 314M 7.5G 4% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/vda1 1014M 179M 836M 18% /boot
tmpfs 1.6G 12K 1.6G 1% /run/user/42
tmpfs 1.6G 0 1.6G 0% /run/user/0

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值