1. 查看当前卷组空间(volume group)使用情况
[[email protected] ~]# vgdisplay
从下面的代码中发现剩余空间为0
--- Volume group --- VG Name rhel System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 7 VG Access read/write VG Status resizable MAX LV 0 Cur LV 4 Open LV 4 Max PV 0 Cur PV 2 Act PV 2 VG Size 25.00 GiB PE Size 4.00 MiB Total PE 6400 Alloc PE / Size 6400 / 25.00 GiB Free PE / Size 0 / 0 VG UUID PQijQV-gDsG-wnQT-rIGE-3rGa-hwpl-oYJ3E9
当卷组中没有足够的空间用于扩展逻辑卷的大小时,就需要增加卷组的容量,而增加卷组容量的唯一办法就是向卷组中添加新的物理卷
2. 向当前组添加新的物理卷(PV(physical voluem))
2.1添加物理分区(Physical Partions)
首先,查看挂载的硬盘
[[email protected] ~]# fdisk -l
从下面的代码知道,当前挂载了一个硬盘,名词为“/dev/sda”
Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors
2.2通过fdisk的n指令增加一个分区
[[email protected] ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): n Partition type: p primary (2 primary, 1 extended, 1 free) l logical (numbered from 5) Select (default p): l Adding logical partition 14 First sector (694638592-976769071, default 694638592): Using default value 694638592 Last sector, +sectors or +size{K,M,G} (694638592-743761304, default 743761304): +3G
Last sector, +sectors or +size{K,M,G} (694638592-743761304, default 743761304): +3GPartition 14 of type Linux and of size 3 GiB is set Command (m for help): w
参考网址:http://blog.chinaunix.net/uid-23929712-id-2650378.html
2.3 立即生效
[[email protected] ~]# partprobe^C
2.4创建物理卷PV(Physical Volumes)
首先用fdisk -l 可以知道新创建的分区名称为:/dev/sda13
之后用pvcreate命令创建物理卷
[[email protected] ~]# pvcreate /dev/sda13
3.利用vgextend命令将新的物理卷(/dev/sda13)加入到卷组(rhel)中
[[email protected] ~]# vgextend rhel /dev/sda13
4.为空间不够的逻辑卷(root)扩容
首先用vgdisplay命令检查当前卷组空间使用情况
Free PE / Size 768/ 3GB
确定当前卷组剩余空间3GB,剩余PE数量为768个。在这里将所有的剩余空间全部增加给逻辑卷rhel
[email protected] ~]# lvextend -l+768 /dev/rhel/root
5.通过xfs_growfs命令修改xfs文件系统的大小
[[email protected] ~]# xfs_growfs /dev/rhel/root
参考网址:http://www.jb51.net/LINUXjishu/242689.html
6.最后查看一下文件系统的当前状态
[[email protected]lhost ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 11G 7.0G 4.1G 64% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 140K 1.9G 1% /dev/shm tmpfs 1.9G 9.0M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mapper/rhel-home 6.0G 2.1G 4.0G 35% /home /dev/mapper/rhel-var 6.0G 825M 5.2G 14% /var /dev/sda11 197M 92M 106M 47% /boot
关于LVM可以参考:http://baike.baidu.com/view/361916.htm
时间: 2024-11-09 01:02:13