Resize CentOS Linux hard drive partition (centos 6.3 调整LVS磁盘大小)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Resize CentOS Linux hard drive partition (centos 6.3 调整LVS磁盘大小)相关的知识,希望对你有一定的参考价值。

查看当前磁盘信息:

[[email protected] ~]# df -h

文件系统          容量  已用  可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
                      154G  7.9G  139G   6% /
tmpfs                 1.9G  100K  1.9G   1% /dev/shm
/dev/sda1             485M   69M  391M  15% /boot
/dev/mapper/VolGroup-lv_home

                      299G  984M  283G   1% /home

将VolGroup-lv_home缩小到20G,并将剩余的空间添加给VolGroup-lv_root

 

先卸载/home:

[[email protected] ~]# umount /home
[[email protected] ~]# e2fsck -f /dev/mapper/VolGroup-lv_home
e2fsck 1.41.12 (17-May-2010)
第一步: 检查inode,块,和大小
第二步: 检查目录结构
第3步: 检查目录连接性
Pass 4: Checking reference counts
第5步: 检查簇概要信息
/dev/mapper/VolGroup-lv_home: 21/19857408 files (0.0% non-contiguous), 1498180/79429632 blocks

注:e2fsck为检查磁盘正确性

 

[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-lv_home 20G

resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/VolGroup-lv_home to 5242880 (4k) blocks.
Begin pass 2 (max = 32778)
正在重定位块            XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 2424)
正在扫描inode表          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 4 (max = 10)
正在更新inode引用       XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/mapper/VolGroup-lv_home is now 5242880 blocks long.

注:resize2fs 为重新设定磁盘大小,只是重新指定一下大小,并不对结果有影响,需要下面lvreduce的配合


[[email protected] ~]# mount /home
[
[[email protected] ~]# lvreduce -L 20G /dev/mapper/VolGroup-lv_home
  WARNING: Reducing active and open logical volume to 20.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 20.00 GiB
  Logical volume lv_home successfully resized

注:lvreduce -L 20G的意思为设置当前文件系统为20G,如果lvreduce -l 20G是指从当前文件系统上减少20G

 

 [[email protected] ~]# df -h
文件系统          容量  已用  可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
                      154G  7.9G  139G   6% /
tmpfs                 1.9G  100K  1.9G   1% /dev/shm
/dev/sda1             485M   69M  391M  15% /boot
/dev/mapper/VolGroup-lv_home
                       20G  962M   18G   6% /home(说明成功了)


[[email protected] ~]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  7
  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       46660 / 182.27 GiB
  Free  PE / Size       72449 / 283.00 GiB
  VG UUID               gPA8XS-ZncK-mGQj-2Vn9-TFTQ-6yOU-6atjE9

注:vgdisplay为显示LVM卷组的元数据信息

  
[[email protected] ~]# lvextend -L +283G /dev/mapper/VolGroup-lv_root
  Extending logical volume lv_root to 439.39 GiB
  Logical volume lv_root successfully resized

注:lvextend -L +283G为在文件系统上增加238G


[[email protected] ~]# resize2fs -p /dev/mapper/VolGroup-lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
old desc_blocks = 10, new_desc_blocks = 28
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 115183616 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-lv_root is now 115183616 blocks long.


检查一下调整的结果:

[[email protected] ~]# df -h
文件系统          容量  已用  可用 已用%% 挂载点
/dev/mapper/VolGroup-lv_root
                      433G  7.9G  403G   2% /
tmpfs                 1.9G  100K  1.9G   1% /dev/shm
/dev/sda1             485M   69M  391M  15% /boot
/dev/mapper/VolGroup-lv_home
                       20G  962M   18G   6% /home


以上是关于Resize CentOS Linux hard drive partition (centos 6.3 调整LVS磁盘大小)的主要内容,如果未能解决你的问题,请参考以下文章

linux基础之系统安装

Codeforces Global Round 7 D2. Prefix-Suffix Palindrome (Hard version) -- manacher

Linux CentOS中,ll 命令显示的结果中,“所有者旁边”的这个数值是啥意思?

resize2fs: Bad magic number in super-block while trying to open /dev/centos/root Couldn't find v

Linux CentOS 复制文件替换文件 cp 复制文件cp 覆盖文件 cp替换文件

linux ulimit soft和hard的区别