CentOS 6.2下删除逻辑卷和增加根目录空间
来源:互联网 发布:动漫飞机杯推荐 知乎 编辑:程序博客网 时间:2024/05/05 11:24
转自:http://kicklinux.com/lvm-manage-create-extend/
CentOS使用逻辑卷对磁盘空间进行管理,大大方便管理人员对空间的调整。很多童鞋安装系统时,分区使用默认设置,CentOS自动分配的home空间很大。因为我们生产环境中基本不使用home空间,所以决定把home挂载到lv_root逻辑卷上,把腾出的空间增加给lv_root逻辑卷。
查看系统目录的挂载情况:
[root@message1 /]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_message1-lv_root 50G 2.3G 45G 5% /tmpfs 1003M 0 1003M 0% /dev/shm/dev/cciss/c0d0p1 485M 32M 428M 7% /boot/dev/mapper/vg_message1-lv_home 14G 163M 13G 2% /home[root@message1 /]# pvdisplay --- Physical volume --- PV Name /dev/cciss/c0d0p2 VG Name vg_message1 PV Size 67.84 GiB / not usable 4.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 17367 Free PE 0 Allocated PE 17367 PV UUID yKXnTp-6cWG-1MCG-FpHc-6QCX-nK1H-otKaMf[root@message1 /]# vgdisplay --- Volume group --- VG Name vg_message1 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 67.84 GiB PE Size 4.00 MiB Total PE 17367 Alloc PE / Size 17367 / 67.84 GiB Free PE / Size 0 / 0 VG UUID pDMn2R-tV0b-AL0Y-BRgV-focH-hpym-yoakDa[root@message1 /]# lvdisplay --- Logical volume --- LV Name /dev/vg_message1/lv_root VG Name vg_message1 LV UUID SAOoO3-Fwtk-wPYg-yi2X-6SXu-qgVZ-lVDz75 LV Write Access read/write LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/vg_message1/lv_home VG Name vg_message1 LV UUID xcjRkh-gSR3-ykfu-LRtV-RA47-3c7q-ZsqqBf LV Write Access read/write LV Status available # open 1 LV Size 13.90 GiB Current LE 3559 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2 --- Logical volume --- LV Name /dev/vg_message1/lv_swap VG Name vg_message1 LV UUID bJcLZE-uG1l-KNpU-OgNH-VceH-ib4d-gGOuKO LV Write Access read/write LV Status available # open 1 LV Size 3.94 GiB Current LE 1008 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
确认home目录下没有数据后,将home目录卸载,这时home目录将使用lv_root逻辑卷进行存储。
[root@message1 /]# umount /home[root@message1 /]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_message1-lv_root 50G 2.3G 45G 5% /tmpfs 1003M 0 1003M 0% /dev/shm/dev/cciss/c0d0p1 485M 32M 428M 7% /boot
这时就可以删除lv_home
[root@message1 /]# lvremove /dev/vg_message1/lv_homeDo you really want to remove active logical volume lv_home? [y/n]: y Logical volume "lv_home" successfully removed
查看逻辑卷信息,发现lv_home已经删除
[root@message1 /]# lvdisplay --- Logical volume --- LV Name /dev/vg_message1/lv_root VG Name vg_message1 LV UUID SAOoO3-Fwtk-wPYg-yi2X-6SXu-qgVZ-lVDz75 LV Write Access read/write LV Status available # open 1 LV Size 50.00 GiB Current LE 12800 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/vg_message1/lv_swap VG Name vg_message1 LV UUID bJcLZE-uG1l-KNpU-OgNH-VceH-ib4d-gGOuKO LV Write Access read/write LV Status available # open 1 LV Size 3.94 GiB Current LE 1008 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
发现逻辑卷组已经有13.9G的空间空闲
[root@message1 /]# vgdisplay --- Volume group --- VG Name vg_message1 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 5 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 67.84 GiB PE Size 4.00 MiB Total PE 17367 Alloc PE / Size 13808 / 53.94 GiB Free PE / Size 3559 / 13.90 GiB VG UUID pDMn2R-tV0b-AL0Y-BRgV-focH-hpym-yoakDa
将所有空闲空间增加给逻辑卷lv_root
[root@message1 ~]# lvextend -L +13.9G /dev/vg_message1/lv_root Rounding up size to full physical extent 13.90 GiB Extending logical volume lv_root to 63.90 GiB Logical volume lv_root successfully resized
查看当前系统逻辑卷信息,发现lv_root的空间大小发生变化
[root@message1 ~]# lvdisplay --- Logical volume --- LV Name /dev/vg_message1/lv_root VG Name vg_message1 LV UUID SAOoO3-Fwtk-wPYg-yi2X-6SXu-qgVZ-lVDz75 LV Write Access read/write LV Status available # open 1 LV Size 63.90 GiB Current LE 16359 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Name /dev/vg_message1/lv_swap VG Name vg_message1 LV UUID bJcLZE-uG1l-KNpU-OgNH-VceH-ib4d-gGOuKO LV Write Access read/write LV Status available # open 1 LV Size 3.94 GiB Current LE 1008 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1
此时查看文件系统的根目录空间并没有发生变化
[root@message1 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_message1-lv_root 50G 2.3G 45G 5% /tmpfs 1003M 0 1003M 0% /dev/shm/dev/cciss/c0d0p1 485M 32M 428M 7% /boot
调整文件系统空间
[root@message1 ~]# resize2fs -p /dev/vg_message1/lv_root resize2fs 1.41.12 (17-May-2010)Filesystem at /dev/vg_message1/lv_root is mounted on /; on-line resizing requiredold desc_blocks = 4, new_desc_blocks = 4Performing an on-line resize of /dev/vg_message1/lv_root to 16751616 (4k) blocks.The filesystem on /dev/vg_message1/lv_root is now 16751616 blocks long.
查看文件系统空间大小,发现根目录由50G增加到63G,到此文件系统空间调整完成。
[root@message1 ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/vg_message1-lv_root 63G 2.3G 58G 4% /tmpfs 1003M 0 1003M 0% /dev/shm/dev/cciss/c0d0p1 485M 32M 428M 7% /boot
修改操作系统挂载目录的配置文件/etc/fstab,注释掉home挂载,注意一定要操作这一步哦,不然下次重启系统就无法启动啦。
[root@message1 ~]# more /etc/fstab ## /etc/fstab# Created by anaconda on Tue Jul 10 19:51:36 2012## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#/dev/mapper/vg_message1-lv_root / ext4 defaults 1 1UUID=cfe0f4a9-5a71-4089-8258-e1c0105de411 /boot ext4 defaults 1 2#/dev/mapper/vg_message1-lv_home /home ext4 defaults 1 2/dev/mapper/vg_message1-lv_swap swap swap defaults 0 0tmpfs /dev/shm tmpfs defaults 0 0devpts /dev/pts devpts gid=5,mode=620 0 0sysfs /sys sysfs defaults 0 0proc /proc proc defaults 0 0
看了以后是不是觉得逻辑卷管理简单而且方便啊!
- CentOS 6.2下删除逻辑卷和增加根目录空间
- CentOS5.2环境下增加根目录空间
- centos 下增加swap空间大小(续and 删除)
- vmware下centos 6.2 虚拟机扩展逻辑卷
- ubuntu VirtualBox 增加根目录空间
- Linux下的逻辑卷和grub
- Linux下建立和管理逻辑卷
- 逻辑卷增加大小步骤
- centos 下增加swap空间大小
- CentOS 6.3下配置LVM(逻辑卷管理)
- CentOS 6.3下配置LVM(逻辑卷管理)
- CentOS 6.3以上下配置LVM(逻辑卷管理)
- CentOS下LVM的使用:逻辑卷的压缩、创建
- CentOS 6.3下配置LVM(逻辑卷管理)
- CentOS 6.3下配置LVM(逻辑卷管理)
- CentOS 6.3下配置LVM(逻辑卷管理)
- CentOS 6下配置LVM(逻辑卷管理)
- 【Linux】将Oracle安装目录从根目录下迁移到逻辑卷
- 是我不懂珍惜。现在不属于我了。
- VC++实现枚举进程与模块
- GConf 错误:联系配置服务器失败;某些可能原因是需要为 ORBit 启用 TCP/IP 联网
- Android emulator安装使用记录
- struts2的增删改查
- CentOS 6.2下删除逻辑卷和增加根目录空间
- CSemaphore,CMutex,CCriticalSection,和CEvent的使用心得
- 从创业失败中学到的七条教训
- Linux中 .bashrc和profile的区别
- selenium RC 使用过程中碰到的小问题
- poj2253 解题报告
- 面试题整理-重建二叉树
- VC++实现注册表监控
- 链表排序