Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1981605
  • 博文数量: 424
  • 博客积分: 1291
  • 博客等级: 中尉
  • 技术积分: 2682
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-13 01:34
个人简介

linux oracle 网络安全 编程

文章分类

全部博文(424)

文章存档

2016年(22)

2015年(53)

2014年(57)

2013年(242)

2012年(50)

分类: LINUX

2014-06-10 15:04:50

根文件系统快用完了,给你一块新硬盘,怎样实现根文件系统扩容?这是面试中经常会出现的一个问题。接下来,我们就在虚拟机里面做一下这个试验。

1、试验环境

物理机:Windows XP
虚拟机:VMware 7
虚拟系统:RHEL 4

2、当前的磁盘使用情况

三块SCSI虚拟硬盘,每个8G,总共24G。一个卷组VolGroup00,分成两个逻辑卷,LogVol00作为根文件系统,LogVol01作为swap。

[root@Shell_HAT]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       20G   17G  1.9G  91% /
/dev/sda1              99M  9.0M   85M  10% /boot
none                  506M     0  506M   0% /dev/shm


[root@Shell_HAT]# ls -l /dev/sd*
brw-rw----  1 root disk 8,  0 Mar 11  2012 /dev/sda
brw-rw----  1 root disk 8,  1 Mar 11  2012 /dev/sda1
brw-rw----  1 root disk 8,  2 Mar 11  2012 /dev/sda2
brw-rw----  1 root disk 8, 16 Mar 11  2012 /dev/sdb
brw-rw----  1 root disk 8, 17 Mar 11  2012 /dev/sdb1
brw-rw----  1 root disk 8, 32 Mar 11  2012 /dev/sdc
brw-rw----  1 root disk 8, 33 Mar 11  2012 /dev/sdc1


[root@Shell_HAT]# fdisk -l

Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        1044     8281507   8e  Linux LVM

Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1044     8385898   8e  Linux LVM

Disk /dev/sdc: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1        1044     8385898   8e  Linux LVM


[root@Shell_HAT]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  17
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               23.81 GB
  PE Size               32.00 MB
  Total PE              762
  Alloc PE / Size       760 / 23.75 GB
  Free  PE / Size       2 / 64.00 MB
  VG UUID               djJXj5-3rkx-PEpi-2OJn-ZofS-VaF6-KUo9UR


[root@Shell_HAT]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                kOehzE-SEAQ-tm3L-jIkG-gbZv-YWC5-apQWWf
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                19.81 GB
  Current LE             634
  Segments               4
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                vI2EKQ-5tne-heGk-bbkL-9K6g-23fs-b9e3Y4
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.94 GB
  Current LE             126
  Segments               2
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:1


[root@Shell_HAT]# cat /etc/fstab
# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0


3、在VMware里面新增一块SCSI虚拟硬盘

确认虚拟系统RHEL4处于关机状态,用VMware打开Red Hat Enterprise Linux 4.vmx,点击Edit virtual machine setings,点击Add按钮,选中Hard Disk,点击Next按钮,选中Create a new virtual disk,点击Next按钮,选中SCSI,点击Next按钮,设置Maximum disk size为8,点击Next按钮,点击Finish按钮,点击OK按钮,启动虚拟系统RHEL4。

4、根文件系统扩容

用一句话来总结:创建物理卷 >>> 卷组扩容 >>> 逻辑卷扩容 >>> 文件系统扩容

(1)创建物理卷

[root@Shell_HAT]# pvcreate /dev/sdd
  Physical volume "/dev/sdd" successfully created

(2)查看创建好的物理卷

[root@Shell_HAT]# pvdisplay /dev/sdd
  --- NEW Physical volume ---
  PV Name               /dev/sdd
  VG Name
  PV Size               8.00 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               5ne1Nx-bsCO-9Vxh-6Pmc-rBnf-dsZo-WjQDYS


(3)卷组扩容

[root@Shell_HAT]# vgextend VolGroup00 /dev/sdd
  Volume group "VolGroup00" successfully extended

(4)查看扩容之后的卷组信息

[root@Shell_HAT]# vgdisplay
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        4
  Metadata Sequence No  18
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                4
  Act PV                4
  VG Size               31.78 GB
  PE Size               32.00 MB
  Total PE              1017
  Alloc PE / Size       760 / 23.75 GB
  Free  PE / Size       257 / 8.03 GB
  VG UUID               djJXj5-3rkx-PEpi-2OJn-ZofS-VaF6-KUo9UR


(5)逻辑卷扩容

[root@Shell_HAT]# lvextend -L+8G /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 27.81 GB
  Logical volume LogVol00 successfully resized


(6)查看扩容之后的逻辑卷

[root@Shell_HAT]# lvdisplay /dev/VolGroup00/LogVol00
  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                kOehzE-SEAQ-tm3L-jIkG-gbZv-YWC5-apQWWf
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                27.81 GB
  Current LE             890
  Segments               5
  Allocation             inherit
  Read ahead sectors     0
  Block device           253:0


(7)文件系统在线扩容

[root@Shell_HAT]# ext2online /dev/VolGroup00/LogVol00
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b

(8)大功告成

[root@Shell_HAT]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       28G   17G  9.4G  65% /
/dev/sda1              99M  9.0M   85M  10% /boot
none                  506M     0  506M   0% /dev/shm

阅读(1188) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~