免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 922 | 回复: 0
打印 上一主题 下一主题

rhel5 LVM应用之如何缩小LVM [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-03-24 20:42 |只看该作者 |倒序浏览
rhel5 LVM应用之如何缩小LVM

先创建两个LVM:
[root@server4 ~]# lvcreate -L 150M tools -n lv1
  Rounding up size to full physical extent 152.00 MB
  Logical volume "lv1" created
[root@server4 ~]# lvcreate -L 200M tools -n lv2
  Logical volume "lv2" created
[root@server4 ~]# lvs
  LV    VG    Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  lv1   tools -wi-a- 152.00M                                      
  lv2   tools -wi-a- 200.00M                                      
  tools tools -wi-ao 600.00M      
[root@server4 ~]# mkfs.ext3 /dev/mapper/tools-lv2
[root@server4 ~]# mkfs.ext3 /dev/mapper/tools-lv2
[root@server4 ~]# mkdir /lv1;mkdir /lv2
[root@server4 ~]# mount /dev/mapper/tools-lv1 /lv1/
[root@server4 ~]# mount /dev/mapper/tools-lv2 /lv2/
[root@server4 ~]# df
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3    8.7G  3.1G  5.1G  38% /
/dev/sda1     ext3     99M   12M   83M  12% /boot
tmpfs        tmpfs     97M     0   97M   0% /dev/shm
/dev/md0      ext3    3.8G   72M  3.6G   2% /home
/dev/mapper/tools-tools
              ext3    582M   11M  548M   2% /tools
/dev/hdc   iso9660    2.9G  2.9G     0 100% /media/cdrom
/dev/mapper/tools-lv1
              ext3    148M  5.6M  135M   4% /lv1
/dev/mapper/tools-lv2
              ext3    194M  5.6M  179M   4% /lv2
lv2的大小为200M,lv1的大小是150M,下来把lv2的大小缩小为100M,如下所示:
[root@server4 /]# cp /etc/resolv.conf /lv2/
[root@server4 /]# cp /etc/pam.d/* /lv2/
[root@server4 /]# ls /lv2
atd               gdm                  kshell             pup            sshd                          system-config-lvm
authconfig        gdm-autologin        login              reboot         su                            system-config-netboot
authconfig-gtk    gdmsetup             lost+found         remote         sudo                          system-config-network
authconfig-tui    gnome-screensaver    neat               resolv.conf    sudo-i                        system-config-network-cmd
chfn              gnome-system-log     newrole            rhn_register   su-l                          system-config-printer
chsh              gssftp               other              run_init       system-auth                   system-config-rootpassword
config-util       halt                 passwd             runuser        system-auth-ac                system-config-securitylevel
cpufreq-selector  kbdrate              pirut              runuser-l      system-cdinstall-helper       system-config-selinux
crond             kcheckpass           pm-hibernate       sabayon        system-config-authentication  system-config-services
cups              kdm                  pm-powersave       screen         system-config-date            system-config-soundcard
cvs               kdm-np               pm-suspend         serviceconf    system-config-display         system-config-time
dateconfig        klaptop_acpi_helper  pm-suspend-hybrid  setup          system-config-kdump           system-config-users
eject             kppp                 poweroff           smtp           system-config-keyboard        system-install-packages
ekshell           kscreensaver         ppp                smtp.sendmail  system-config-language
[root@server4 /]# umount /lv2
[root@server4 /]# lvresize -L 200M /dev/tools/lv2
  New size (50 extents) matches existing size (50 extents)
  Run `lvresize --help' for more information.
[root@server4 /]# e2fsck -f /dev/tools/lv2
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/tools/lv2: 93/51200 files (2.2% non-contiguous), 12212/204800 blocks
[root@server4 /]# resize2fs /dev/tools/lv2 100M
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/tools/lv2 to 102400 (1k) blocks.
The filesystem on /dev/tools/lv2 is now 102400 blocks long.
[root@server4 /]# lvresize -L 100M /dev/tools/lv2
  /dev/cdrom: open failed: Read-only file system
  WARNING: Reducing active logical volume to 100.00 MB
  THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv2? [y/n]: y
  Reducing logical volume lv2 to 100.00 MB
  Logical volume lv2 successfully resized
[root@server4 /]# e2fsck -f /dev/tools/lv2
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/tools/lv2: 93/26624 files (2.2% non-contiguous), 9116/102400 blocks
[root@server4 /]# mount /dev/tools/lv2 /lv2/
[root@server4 /]# df
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3    8.7G  3.1G  5.1G  38% /
/dev/sda1     ext3     99M   12M   83M  12% /boot
tmpfs        tmpfs     97M     0   97M   0% /dev/shm
/dev/md0      ext3    3.8G   72M  3.6G   2% /home
/dev/mapper/tools-tools
              ext3    582M   11M  548M   2% /tools
/dev/hdc   iso9660    2.9G  2.9G     0 100% /media/cdrom
/dev/mapper/tools-lv1
              ext3    148M  5.6M  135M   4% /lv1
/dev/mapper/tools-lv2
              ext3     97M  5.7M   87M   7% /lv2
[root@server4 /]# ls lv2/
atd               gdm                  kshell             pup            sshd                          system-config-lvm
authconfig        gdm-autologin        login              reboot         su                            system-config-netboot
authconfig-gtk    gdmsetup             lost+found         remote         sudo                          system-config-network
authconfig-tui    gnome-screensaver    neat               resolv.conf    sudo-i                        system-config-network-cmd
chfn              gnome-system-log     newrole            rhn_register   su-l                          system-config-printer
chsh              gssftp               other              run_init       system-auth                   system-config-rootpassword
config-util       halt                 passwd             runuser        system-auth-ac                system-config-securitylevel
cpufreq-selector  kbdrate              pirut              runuser-l      system-cdinstall-helper       system-config-selinux
crond             kcheckpass           pm-hibernate       sabayon        system-config-authentication  system-config-services
cups              kdm                  pm-powersave       screen         system-config-date            system-config-soundcard
cvs               kdm-np               pm-suspend         serviceconf    system-config-display         system-config-time
dateconfig        klaptop_acpi_helper  pm-suspend-hybrid  setup          system-config-kdump           system-config-users
eject             kppp                 poweroff           smtp           system-config-keyboard        system-install-packages
ekshell           kscreensaver         ppp                smtp.sendmail  system-config-language
之前复制的数据都还存在的,这就OK了!


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/36549/showart_1878358.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP