LVM应用之变更/data 的大小

 

今天突然发现/目录的空间不够用了,于是准备使用LVM变更目录空间的大小。由于我已经没有硬盘可以添加,所以只能从现有目录中扣一部分空间给/目录使用。我的方案是:从/data目录中扣1G的空间给/使用

在操作前df-L的情况是这样的

Filesystem                       1K-blocks      Used   Available   Use%   Mounted on
/dev/mapper/VolGroup00-LogVol04                   1015704    956844    6432   100%     /
/dev/mapper/VolGroup00-LogVol02                   2031440   1422732    503852    74%     /usr
/dev/mapper/VolGroup00-LogVol00                   1015704     34144    929132      4%     /home
/dev/sda1                           101086       18119        77748      19%     /boot
tmpfs                                 257668         0      257668     0%     /dev/shm
/dev/mapper/VolGroup00-LogVol03                       2456816     70792   2284468     4%     /data
[root@localhost /]# umount /data

[root@localhost /]# resize2fs /dev/mapper/VolGroup00-LogVol03 2428080  --此为较少1G后LogVol03的Blocks,由于我系统是4K/Block,所以我第一次算错了,出现了以下提示
resize2fs 1.39 (29-May-2006)
The containing partition (or device) is only 884736 (4k) blocks.
You requested a new size of 2428080 blocks.

[root@localhost /]# resize2fs /dev/mapper/VolGroup00-LogVol03 634736
resize2fs 1.39 (29-May-2006)
Please run 'e2fsck -f /dev/mapper/VolGroup00-LogVol03' first.

[root@localhost /]# e2fsck -f /dev/mapper/VolGroup00-LogVol03
e2fsck 1.39 (29-May-2006)
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/VolGroup00-LogVol03: 11/884736 files (9.1% non-contiguous), 45629/884736 blocks
[root@localhost /]# resize2fs /dev/mapper/VolGroup00-LogVol03 634736
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/mapper/VolGroup00-LogVol03 to 634736 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol03 is now 634736 blocks long.

[root@localhost /]# lvreduce -L-1G /dev/mapper/VolGroup00-LogVol03
  /dev/hdc: open failed: Read-only file system
  WARNING: Reducing active logical volume to 2.38 GB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce LogVol03? [y/n]: y
  Reducing logical volume LogVol03 to 2.38 GB
  Logical volume LogVol03 successfully resized
[root@localhost /]# mount /data
好了,到了这一步已经把1G空间从/data目录下扣出来了,下面是把1G空间给/加上去

[root@localhost /]# lvextend -L+1G /dev/mapper/VolGroup00-LogVol04
  /dev/hdc: open failed: Read-only file system
  Extending logical volume LogVol04 to 2.00 GB
  Logical volume LogVol04 successfully resized
[root@localhost /]# resize2fs /dev/mapper/VolGroup00-LogVol04
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol04 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol04 to 524288 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol04 is now 524288 blocks long.
[root@localhost /]# df -l

Filesystem                       1K-blocks      Used   Available   Use%   Mounted on
/dev/mapper/VolGroup00-LogVol04                  2031440    957100      969496    50%     /
/dev/mapper/VolGroup00-LogVol02                 2031440   1422732      503852    74%     /usr
/dev/mapper/VolGroup00-LogVol00                  1015704     34144      929132     4%     /home
/dev/sda1                           101086     18119          77748    19%     /boot
tmpfs                                257668         0        257668     0%     /dev/shm
/dev/mapper/VolGroup00-LogVol03                    2456816     70792     2284468     4%     /data
大功告成!成功把/data目录下的1G空间移到了/目录下

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值