在安装系统的时候使用默认的分区安装的,结果发现swap区有点大,想缩小一下
[root@oracle11g-std mapper]# uname -a
Linux oracle11g-std 2.6.32-71.el6.x86_64 #1 SMP Wed Sep 1 01:33:01 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux
[root@oracle11g-std mapper]# lvdisplay
--- Logical volume ---
LV Name /dev/vg_oracle11gstd/lv_root
VG Name vg_oracle11gstd
LV UUID ICHlPw-t84Z-5CKo-dZmC-s9zV-65tB-Fowgyt
LV Write Access read/write
LV Status available
# open 1
LV Size 17.98 GiB
Current LE 4602
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/vg_oracle11gstd/lv_swap
VG Name vg_oracle11gstd
LV UUID iVSDgb-BQc0-cZHP-1xCt-KZ91-vcdM-uW0y8g
LV Write Access read/write
LV Status available
# open 1
LV Size 1.53 GiB
Current LE 392
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@oracle11g-std mapper]# lvreduce -L 500M -f -r /dev/vg_oracle11gstd/lv_swap
fsck from util-linux-ng 2.17.2
fsck: fsck.swap: not found
fsck: Error 2 while executing fsck.swap for /dev/mapper/vg_oracle11gstd-lv_swap
fsadm: Filesystem "swap" on device "/dev/dm-1" is not supported by this tool
fsadm failed: 1
[root@oracle11g-std mapper]# more /etc/fstab
#
# /etc/fstab
# Created by anaconda on Wed Apr 25 00:36:24 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_oracle11gstd-lv_root / ext4 defaults 1 1
UUID=fe90813a-a61f-4208-b6a8-c3d178229ded /boot ext4 defaults 1 2
/dev/mapper/vg_oracle11gstd-lv_swap swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
[root@oracle11g-std mapper]# ll -l /dev/mapper/vg_oracle11gstd-lv_swap swap
ls: 无法访问swap: 没有那个文件或目录
lrwxrwxrwx. 1 root root 7 5月 10 19:13 /dev/mapper/vg_oracle11gstd-lv_swap -> ../dm-1
[root@oracle11g-std mapper]#
直接使用lvreduce报错!
原始缩小相应的lv的时候需要umount
umount
lvresize
mkswap ------如果要新创建的话使用该命令
mount -a
参见
http://blog.csdn.net/onlymilan/article/details/4941189
以下是实际的操作:
umount -a----,也 可以umount /dev/mapper/vg_oracle11gstd-lv
lvresize -L 500M /dev/mapper/vg_oracle11gstd-lv
mount -a
然后将减少的这块空间分给lv_root
扩容的时候不需要umount
lvresize -L 19g /dev/mapper/vg_oracle11gstd-lv——root
然后进行
[root@oracle11g-std ~]# resize2fs /dev/vg_oracle11gstd/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_oracle11gstd/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/vg_oracle11gstd/lv_root to 4980736 (4k) blocks.
The filesystem on /dev/vg_oracle11gstd/lv_root is now 4980736 blocks long.
如果不适用resize2fs那么会造成
df -lh的结果与lvdisplay结果不一致的现象
[root@oracle11g-std ~]# df -lh
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/vg_oracle11gstd-lv_root
18G 13G 4.4G 75% /
tmpfs 387M 88K 387M 1% /dev/shm
/dev/sda1 485M 30M 430M 7% /boot
[root@oracle11g-std ~]# lvdisplay
--- Logical volume ---
LV Name /dev/vg_oracle11gstd/lv_root
VG Name vg_oracle11gstd
LV UUID ICHlPw-t84Z-5CKo-dZmC-s9zV-65tB-Fowgyt
LV Write Access read/write
LV Status available
# open 1
LV Size 19.00 GiB
Current LE 4864
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
如何扩展/缩小lv大小
最新推荐文章于 2024-05-12 04:07:45 发布