Live Resize of Logical Volume in RHEL/CentOS
来源:互联网 发布:风云2坐骑进阶数据 编辑:程序博客网 时间:2024/04/29 06:47
以下技术应用于最优质的水果的鲜果篮
The default installation of RHEL 6 and CentOS 6 will create separate LVM volumes for /home. This means much of your disk is allocated to /home when it could be used for something else. Keeping /home on a separate partition is a good idea for multi-user systems, but for machines that act as a service box, it may be wasted disk space. For example, here’s a system that has 50G partitioned for /home when it’s really not needed.
1
$
df
-h
2
Filesystem Size Used Avail Use% Mounted on
3
/dev/mapper/vg_repo-lv_root 148G 113G 29G 80% /
4
tmpfs 499M 0 499M 0% /dev/shm
5
/dev/sda1 485M 156M 304M 34% /boot
6
/dev/mapper/vg_repo-lv_home 47G 181M 45G 1% /home
To remove the logical volume that stores /home and add the free space to the root partition, follow these steps:
Note: Make sure you’re logged into the system at the console as a user whose homedir isn’t in /home. Logging in as root usually works.
1
cd
/
2
cp
-Ra /home /home.bak
# Make a backup of home
3
umount
/home
4
lvm lvremove /dev/vg_<
hostname
>/lv_home
# Remove the logical volume for home
5
lvm lvresize -l+100%FREE /dev/vg_<
hostname
>/lv_root
# Resize the root logical volume so it uses 100% of the now free space
6
resize2fs /dev/vg_<
hostname
>/lv_root
# Resize the filesystem to use the whole logical volume
7
mv
/home.bak /home
# Restore the backup.
More Notes:
- This can be done on a live system as long as /home is not in use when you try to unmount it.
- You can also follow these steps to resize another logical volume if it has another name and isn’t in use.
- This may work with some adjustments on a RHEL/CentOS 5 system, I haven’t tried it though.
请注意,以上操作以后还需要这样的重要一步,否则系统如果重启将无法启动:
编辑/etc/fstab,删除掉/dev/mapper/vg_repo-lv_home对应的那一行。
如果遗漏了这一步,服务器重启后,CentOS将无法启动,会进入到 (Repair Filesystem) 提示符。CentOS会报告挂载 /home 分区错误。
这时在 (Repair Filesystem) 中使用任何lvm管理命令都是无效的。如输入 lvdisplay lvs pvs vgs 等命令,都会显示同一个错误:File-based locking initialisation failed。
为了解决这个问题,先要将原来挂载/home的分区的部分取消。可是在 (Repair Filesystem) 提示符下,对硬盘的管理是只读的,修改 /etc/fstab 将不能保存。
要解决这个问题,需要重新挂载文件系统为可写。在 (Repair Filesystem) 中输入 root 密码之后,输入如下命令:mount -w -o remount /
然后再次编辑 /etc/fstab ,删除掉/dev/mapper/vg_repo-lv_home对应的那一行,重启即可正常进入系统。
- Live Resize of Logical Volume in RHEL/CentOS
- How to Take ‘Snapshot of Logical Volume and Restore’ in LVM
- Installation of NVIDIA Drivers in RHEL/CentOS and Fedora
- Accessing a Fedora/CentOS Logical Volume from Ubuntu
- LVM(Logical Volume Manager)
- LVM---Logical Volume Management
- LVM(Logical Volume Manager)
- Logical Volume Manager
- CentOS调整var/home分配的空间 (Logical Volume), 1and1实体主机必做!
- Linux LVM(Logical Volume Manager)
- Linux LVM(Logical Volume Manager)
- RHCE131 Lecture13 Logical Volume Management
- LVM (Logical Volume Management) 配置
- 理解 LVM (Logical Volume Manager)
- 理解 LVM (Logical Volume Manager)
- NO arrays found in config file or automatically setting up logical volume management
- What is Logical Volume Management and How Do You Enable It in Ubuntu?
- How to Extend/Reduce LVM’s (Logical Volume Management) in Linux
- void main(void)用法
- XP系统,安卓手机搜不到热点,怎么解决
- Keil中常见的几种警告
- JS字符串变成方法名 及 window["s"] 的使用
- TextArea的值中有换行时的问题
- Live Resize of Logical Volume in RHEL/CentOS
- GO demo之简易计算器
- Hibernate实现分页查询的原理分析
- GPS模拟器
- Myeclipse 10 for mac 破解版下载安装及破解方法
- Qt中RadioButton组如何实现?
- C++学习类的深入
- GetStartupInfo
- [2011山东ACM省赛] Sequence (动态规划)