转自:http://blog.csdn.net/andy_yf/article/details/7831482
一、目的
在使用CentOS6.3版本Linux系统的时候,发现根目录(/)的空间不是很充足,而其他目录空间有很大的空闲,所以本文主要是针对现在已有的空间进行调整。首先,先来查看一下系统的空间分配情况:
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
- /dev/mapper/vg_centos-lv_home
- 404G 670M 382G 1% /home
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
- /dev/mapper/vg_centos-lv_home
- 404G 670M 382G 1% /home
下面的详细步骤部分将从vg_centos-lv_home分区下取出100G的空间添加到/vg_centos-lv_root分区上去。
二、详细步骤
1、卸载vg_centos-lv_home分区
- [root@CentOS-78 /]# umount /home
- [root@CentOS-78 /]# umount /home
此时在用df命令查看将会发现/home目录已经看不见了,如下所示:
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
2、从新设定vg_home-lv_home的大小
- [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G
- resize2fs 1.41.12 (17-May-2010)
- Please run 'e2fsck -f /dev/mapper/vg_centos-lv_home' first.
- [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G
- resize2fs 1.41.12 (17-May-2010)
- Please run 'e2fsck -f /dev/mapper/vg_centos-lv_home' first.
这一步设定vg_home-lv_home大小没有成功,系统提示我们先运行下面的命令,操作如下:
- [root@CentOS-78 /]# e2fsck -f /dev/mapper/vg_centos-lv_home
- e2fsck 1.41.12 (17-May-2010)
- Pass 1: Checking inodes, blocks, and sizes
- Pass 2: Checking directory structure
- Pass 3: Checking directory connectivity
- Pass 4: Checking reference counts
- Pass 5: Checking group summary information
- /dev/mapper/vg_centos-lv_home: 1386/26836992 files (0.9% non-contiguous), 1855856/107344896 blocks
- [root@CentOS-78 /]# e2fsck -f /dev/mapper/vg_centos-lv_home
- e2fsck 1.41.12 (17-May-2010)
- Pass 1: Checking inodes, blocks, and sizes
- Pass 2: Checking directory structure
- Pass 3: Checking directory connectivity
- Pass 4: Checking reference counts
- Pass 5: Checking group summary information
- /dev/mapper/vg_centos-lv_home: 1386/26836992 files (0.9% non-contiguous), 1855856/107344896 blocks
从新设定vg_home-lv_home的大小:
- [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G
- resize2fs 1.41.12 (17-May-2010)
- Resizing the filesystem on /dev/mapper/vg_centos-lv_home to 73924608 (4k) blocks.
- Begin pass 2 (max = 43)
- Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- Begin pass 3 (max = 3276)
- Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- Begin pass 4 (max = 266)
- Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- The filesystem on /dev/mapper/vg_centos-lv_home is now 73924608 blocks long.
- [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_home 282G
- resize2fs 1.41.12 (17-May-2010)
- Resizing the filesystem on /dev/mapper/vg_centos-lv_home to 73924608 (4k) blocks.
- Begin pass 2 (max = 43)
- Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- Begin pass 3 (max = 3276)
- Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- Begin pass 4 (max = 266)
- Updating inode references XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
- The filesystem on /dev/mapper/vg_centos-lv_home is now 73924608 blocks long.
检查是否成功:
- [root@CentOS-78 /]# mount /home
- [root@CentOS-78 /]#
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
- /dev/mapper/vg_centos-lv_home
- 278G 663M 263G 1% /home
- [root@CentOS-78 /]#
- [root@CentOS-78 /]# mount /home
- [root@CentOS-78 /]#
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 50G 14G 34G 30% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
- /dev/mapper/vg_centos-lv_home
- 278G 663M 263G 1% /home
- [root@CentOS-78 /]#
3、将lv_home逻辑分区减小到指定大小
- [root@CentOS-78 /]# lvreduce -L 282G /dev/mapper/vg_centos-lv_home
- WARNING: Reducing active and open logical volume to 282.00 GiB
- THIS MAY DESTROY YOUR DATA (filesystem etc.)
- Do you really want to reduce lv_home? [y/n]: y
- Reducing logical volume lv_home to 282.00 GiB
- Logical volume lv_home successfully resized
- [root@CentOS-78 /]#
- [root@CentOS-78 /]# lvreduce -L 282G /dev/mapper/vg_centos-lv_home
- WARNING: Reducing active and open logical volume to 282.00 GiB
- THIS MAY DESTROY YOUR DATA (filesystem etc.)
- Do you really want to reduce lv_home? [y/n]: y
- Reducing logical volume lv_home to 282.00 GiB
- Logical volume lv_home successfully resized
- [root@CentOS-78 /]#
我认为这个命令是将已经减少的100G空间拿到系统公共的区域,可以被其他分区加载和利用。
查询卷组的信息:
- [root@CentOS-78 /]# vgdisplay
- --- Volume group ---
- VG Name vg_centos
- System ID
- Format lvm2
- Metadata Areas 1
- Metadata Sequence No 5
- 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 465.27 GiB
- PE Size 4.00 MiB
- Total PE 119109
- Alloc PE / Size 86472 / 337.78 GiB
- Free PE / Size 32637 / 127.49 GiB
- VG UUID 1k4ooN-RFV9-uyf1-uMYf-aERG-YaGs-ZNoSD6
- [root@CentOS-78 /]# vgdisplay
- --- Volume group ---
- VG Name vg_centos
- System ID
- Format lvm2
- Metadata Areas 1
- Metadata Sequence No 5
- 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 465.27 GiB
- PE Size 4.00 MiB
- Total PE 119109
- Alloc PE / Size 86472 / 337.78 GiB
- Free PE / Size 32637 / 127.49 GiB
- VG UUID 1k4ooN-RFV9-uyf1-uMYf-aERG-YaGs-ZNoSD6
Free PE / Size指定的应该是现在可在分配的空间。
4、增加vg_centos-lv_root分区的大小
将可用的空间添加到vg_centos-lv_root分区上面:
- [root@CentOS-78 /]# lvextend -L +127.40G /dev/mapper/vg_centos-lv_root
- Rounding up size to full physical extent 127.40 GiB
- Extending logical volume lv_root to 177.40 GiB
- Logical volume lv_root successfully resized
- [root@CentOS-78 /]#
- [root@CentOS-78 /]# lvextend -L +127.40G /dev/mapper/vg_centos-lv_root
- Rounding up size to full physical extent 127.40 GiB
- Extending logical volume lv_root to 177.40 GiB
- Logical volume lv_root successfully resized
- [root@CentOS-78 /]#
从新设定该分区的大小:
- [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_root
- resize2fs 1.41.12 (17-May-2010)
- Filesystem at /dev/mapper/vg_centos-lv_root is mounted on /; on-line resizing required
- old desc_blocks = 4, new_desc_blocks = 12
- Performing an on-line resize of /dev/mapper/vg_centos-lv_root to 46504960 (4k) blocks.
- The filesystem on /dev/mapper/vg_centos-lv_root is now 46504960 blocks long.
- [root@CentOS-78 /]# resize2fs -p /dev/mapper/vg_centos-lv_root
- resize2fs 1.41.12 (17-May-2010)
- Filesystem at /dev/mapper/vg_centos-lv_root is mounted on /; on-line resizing required
- old desc_blocks = 4, new_desc_blocks = 12
- Performing an on-line resize of /dev/mapper/vg_centos-lv_root to 46504960 (4k) blocks.
- The filesystem on /dev/mapper/vg_centos-lv_root is now 46504960 blocks long.
5、再次查看分区大小
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 175G 14G 153G 9% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
- /dev/mapper/vg_centos-lv_home
- 278G 663M 263G 1% /home
- [root@CentOS-78 /]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_centos-lv_root
- 175G 14G 153G 9% /
- tmpfs 1.9G 0 1.9G 0% /dev/shm
- /dev/sda1 485M 37M 423M 8% /boot
- /dev/mapper/vg_centos-lv_home
- 278G 663M 263G 1% /home
我们发现vg_centos-lv_root分区的空间已经增加了125G,之所以比lv_home减少的空间要多25G主要是由于我们把系统所有的可用的空间都加在了lv_root分区。
三、所遇到的问题
1、在卸载/home目录的时候失败
可先执行如下fuser命令,然后再umount即可:
- [root@CentOS-78 /]# fuser -m /home
- [root@CentOS-78 /]#
- [root@CentOS-78 /]# fuser -m /home
- [root@CentOS-78 /]#
2、设定完lv_home的大小,再次mount该分区时,发现用df命令无法看到给分区,此时只要在mount一次即可
3、在设定lv_root的大小时,不要把Free PE / Size的空间全部都用上,这很可能会出现Free PE空间不足的现象,建议保留一点Free PE的空间。
==================================================================
参考:
http://hi.baidu.com/%B7%E7%B6%C0/blog/item/c4aa9a81b204dbc89023d956.html
http://qianxunniao.iteye.com/blog/1393726
相关推荐
### Centos6.5镜像文件下载与安装详解 #### 一、CentOS 6.5简介 CentOS是Community ENTerprise Operating System的缩写,是一个基于Linux内核的操作系统,它主要提供了企业级的计算环境。CentOS 6.5作为CentOS 6...
CentOs6.5镜像源
CentOS 6.5 的 软件源很多官方已经停止维护,该文件包内配置好的yum源是可以正常使用的。将原/etc/yum.repos.d/目录下原来的 .repo 备份, 然后把本文件包内的repo文件复制过去, yum clean all 后,再 yum ...
centos 6.5 telnet 客户端 安装文件 rpm包 centos 6.5 telnet 服务端 安装文件 rpm包 http://vault.centos.org/6.5/os/x86_64/Packages/ 从官网下载亲测可以用
CentOS6.5的64位镜像文件iso。CentOS是基于linux内核而扩展的操作系统。
"VMware创建安装CentOS6.5(配截图)" VMware 是一款功能强大且流行的虚拟机软件,用户可以在 VMware 中创建多个虚拟机,每个虚拟机都可以独立运行不同的操作系统。CentOS6.5 是一个基于 Linux 的开源操作系统,...
centos 6.5下的文件上传下载服务安装和配置 centos 6.5下的文件上传下载服务是指在centos 6.5操作系统中安装和配置文件上传下载服务,以解决上传和下载文件的问题。这个服务可以让用户轻松地上传和下载文件,而不...
CentOS 6.5 安装教程详解 CentOS 6.5 是一个稳定、功能强大且广泛应用的 Linux 发行版,本文将详细介绍 CentOS 6.5 的安装步骤,包括虚拟机的安装、CentOS 镜像文件的下载和使用、连接工具的配置等内容。 一、...
在Linux系统中,CentOS 6.5是一个广泛使用的版本,而MySQL 5.6则是一个流行的开源数据库管理系统。本文将详细介绍如何在CentOS 6.5上进行MySQL 5.6的一键安装过程,包括必要的环境准备、安装步骤、配置优化以及安全...
本文将详细讲解如何在CentOS 6.5系统上升级OpenSSH。 首先,升级OpenSSH通常涉及升级其依赖的库,特别是openssl。openssl是提供加密功能的核心库,新的版本通常会包含更强的加密算法和修复的安全漏洞。在升级...
### CentOS 6.5 for Oracle 的安装与配置详解 #### 一、概述 本文将详细介绍如何在服务器上安装并配置CentOS 6.5系统,特别是针对Oracle数据库环境的优化和配置方法。CentOS 6.5是一款稳定且广泛使用的Linux发行版...
在本教程中,我们将详细讲解如何在WM(可能是指WMware)虚拟机环境下安装CentOS 6.5操作系统。这是一份由个人安装经验整理出的教程,适用于想要在虚拟环境中搭建CentOS 6.5开发或测试环境的用户。 首先,创建虚拟机...
Centos6.5升级openssh-9.1p1包括32位和9.3版本的63位的全部rpm包,附带telnet客户端的rpm包 32位: openssh-9.1p1-1.el6.i386.rpm openssh-clients-9.1p1-1.el6.i386.rpm openssh-server-9.1p1-1.el6.i386.rpm ...
在CentOS6.5系统下安装CDH5.8.2,首先需要准备三台虚拟机,分别安装CentOS6.5系统。然后,需要修改主机名分别为hadoop01/hadoop02/hadoop03。修改主机名的方法有两种:一种是使用setup命令,另一种是修改vim /etc/...
VMware安装CentOS6.5的详细教程涵盖了从下载CentOS6.5系统文件到配置虚拟机设置,再到操作系统安装过程中的每一步骤。首先,我们需要了解Linux操作系统和CentOS6.5的基本概念。Linux是一个开源的操作系统内核,而...
资源名称:CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南内容简介: CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南主要讲述的是CentOS 6.5 x64下安装19实体节点Hadoop 2.2.0集群配置指南;...
centos6.5 64位 gcc离线安装包,内含所有离线安装gcc所有rpm包。可依次安装,也可一起安装。内有安装说明。 cloog-ppl-0.15.7-1.2.el6.x86_64.rpm cpp-4.4.7-4.el6.x86_64.rpm gcc-4.4.7-4.el6.x86_64.rpm gcc-c++-...
标题中的"CentOS 6.5镜像下载地址,OpenStack专用,qcow2格式"指的是一款专为OpenStack设计的CentOS 6.5操作系统镜像文件,该文件采用了qcow2作为磁盘映像格式。qcow2是一种高效的虚拟磁盘格式,它在OpenStack这样的...
"U盘安装CentOS 6.5" U盘安装CentOS 6.5是相对于光盘安装的一种更快速、更方便的安装方式。使用U盘安装CentOS 6.5可以跳过刻盘的步骤,速度也更快,而且没有硬件限制(新机器USB口都有,光驱不一定有)。 U盘安装...