您好,登录后才能下订单哦!
这篇文章主要为大家展示了“CentOS 5中LVM如何在线扩容根分区”,内容简而易懂,条理清晰,希望能够帮助大家解决疑惑,下面让小编带领大家一起研究并学习一下“CentOS 5中LVM如何在线扩容根分区”这篇文章吧。
说明:
Linux 2.6以上内核支持ext3的在线扩容
第一种情况:直接添加一个新硬盘
# df -h 看看现在硬盘的情况
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
6.7G 5.2G 1.3G 81% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 633M 0 633M 0% /dev/shm
# fdisk -l 可以看到新添加的硬盘/dev/sdb
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn't contain a valid partition table
# lvm
lvm>vgdisplay 可以先看卷组是否还有剩余空间可以扩展,有的话直接扩展,没有或不够的话把新的硬盘添加进去
--- Volume group ---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 7.88 GB
PE Size 32.00 MB
Total PE 252
Alloc PE / Size 252 / 7.88 GB
Free PE / Size 0 / 0
VG UUID 0U8dPB-UTJZ-Mdv5-eZJM-Xj7f-gR1M-63BcCh
lvm>pvcreate /dev/sdb 使用新的整个硬盘创建一个lvm物理卷
lvm>vgextend /dev/VolGroup00 /dev/sdb 把新的物理卷添加到卷组中
lvm>vgdisplay 可以看到已分配空间和剩余未分配空间 All PE / Size 和 Free PE / Size
--- Volume group ---
VG Name VolGroup00
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 15.84 GB
PE Size 32.00 MB
Total PE 507
Alloc PE / Size 252 / 7.88 GB
Free PE / Size 255 / 7.97 GB
VG UUID 0U8dPB-UTJZ-Mdv5-eZJM-Xj7f-gR1M-63BcCh
lvm>lvextend -L +7.9G /dev/VolGroup00/LogVol00 扩展逻辑卷大小
lvm>vgdisplay
lvm>pvdisplay
lvm>lvdisplay 可以看到已经添加了
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol00
VG Name VolGroup00
LV UUID QtNkTM-TeSo-WnZD-fSUr-6k1F-5aLX-zAIfSQ
LV Write Access read/write
LV Status available
# open 1
LV Size 14.78 GB
Current LE 473
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup00/LogVol01
VG Name VolGroup00
LV UUID bhTEBX-t8XK-zGku-NCzx-eolz-Anvj-jUMUER
LV Write Access read/write
LV Status available
# open 1
LV Size 1.00 GB
Current LE 32
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
lvm>quit
# resize2fs -p /dev/VolGroup00/LogVol00 修改文件系统大小以实现扩充空间
# df -h
第二种情况:只添加一个新分区
# df -h 可以看到新添加的硬盘/dev/sdb1
# lvm
lvm>pvcreate /dev/sdb1 使用新的硬盘创建一个lvm物理卷
lvm>vgextend /dev/VolGroup00 /dev/sdb1
lvm>vgdisplay 可以看到已分配空间和剩余未分配空间 All PE / Size 和 Free PE / Size
lvm>lvextend -L +5G /dev/VolGroup00/LogVol00
lvm>vgdisplay
lvm>pvdisplay
lvm>lvdisplay
lvm>quit
# resize2fs -p /dev/VolGroup00/LogVol00 扩展
# df -h
以上是“CentOS 5中LVM如何在线扩容根分区”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。