感谢支持
我们一直在努力

在Linux使用ext2resize在线扩展文件系统

一个做Oracle的工程师,笔记本上居然没有一套Oracle环境,说起来还真搞笑。今天要帮老婆倒腾一些数据,没办法,只好先装一套Oracle。在笔记本上已经有一个linux的虚拟机,本来是装DB2的,懒得再重装OS了,打算就在里面装Oracle。


整个系统就一个文件系统,再装完11g软件后,准备建库时发现没有空间了,数据库就装在根目录下,于是打算给根卷划一些空间,然后在线扩展文件系统。


这次准备用ext2resize工具在线扩展文件系统。


环境: 
[root@ www.linuxidc.com ~]# uname -a
Linux cheneydb2 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux


[root@ www.linuxidc.com ~]# cat /etc/RedHat-release
Red Hat Enterprise Linux Server release 5.5 (Tikanga)


工具下载路径:
ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/openSUSE/repositories/home:/janptitan/SLE_10/x86_64/ext2resize-1.1.19-3.1.x86_64.rpm


划盘:
[root@ www.linuxidc.com ~]# fdisk -l


Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 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        1958    15623212+  8e  Linux LVM


Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


磁盘分区:


[root@ www.linuxidc.com ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won’t be recoverable.


Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)


Command (m for help): h
h: unknown command
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition’s system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)


Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-652, default 652):
Using default value 652


Command (m for help): w
The partition table has been altered!


Calling ioctl() to re-read partition table.
Syncing disks.


[root@ www.linuxidc.com ~]# fdisk -l


Disk /dev/sda: 16.1 GB, 16106127360 bytes
255 heads, 63 sectors/track, 1958 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        1958    15623212+  8e  Linux LVM


Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1         652     5237158+  83  Linux

创建PV:

[root@ www.linuxidc.com ~]# pvcreate /dev/sdb1
  Physical volume “/dev/sdb1” successfully created


VG扩容:


[root@ www.linuxidc.com ~]# vgdisplay
  /dev/hdc: open failed: No medium found
  — Volume group —
  VG Name               VolGroup00
  System ID            
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               14.88 GB
  PE Size               32.00 MB
  Total PE              476
  Alloc PE / Size       476 / 14.88 GB
  Free  PE / Size       0 / 0  
  VG UUID               3RQ6rK-WGtT-3eIv-0KBt-bimt-CS2A-WmAOei



[root@ www.linuxidc.com ~]# vgextend VolGroup00 /dev/sdb1
  /dev/hdc: open failed: No medium found
  Volume group “VolGroup00” successfully extended



[root@ www.linuxidc.com ~]# vgdisplay VolGroup00
  /dev/hdc: open failed: No medium found
  — Volume group —
  VG Name               VolGroup00
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               19.84 GB
  PE Size               32.00 MB
  Total PE              635
  Alloc PE / Size       476 / 14.88 GB
  Free  PE / Size       159 / 4.97 GB
  VG UUID               3RQ6rK-WGtT-3eIv-0KBt-bimt-CS2A-WmAOei


扩展LV:


[root@ www.linuxidc.com ~]# lvdisplay /dev/VolGroup00/LogVol00
  /dev/hdc: open failed: No medium found
  — Logical volume —
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                5OkZew-3rlV-4KyR-tf8A-djM5-mXd2-fhfU7o
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                12.91 GB
  Current LE             413
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  – currently set to     256
  Block device           253:0



[root@ www.linuxidc.com ~]# lvextend -L 16g /dev/VolGroup00/LogVol00
  /dev/hdc: open failed: No medium found
  Extending logical volume LogVol00 to 16.00 GB
  Logical volume LogVol00 successfully resized


[root@ www.linuxidc.com ~]# lvdisplay /dev/VolGroup00/LogVol00
  /dev/hdc: open failed: No medium found
  — Logical volume —
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                5OkZew-3rlV-4KyR-tf8A-djM5-mXd2-fhfU7o
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                16.00 GB
  Current LE             512
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  – currently set to     256
  Block device           253:0

安装ext2resize工具:

[root@ www.linuxidc.com rpm]#  rpm -ivh ext2resize-1.1.19-3.1.x86_64.rpm
Preparing…                ########################################### [100%]
   1:ext2resize             warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root%)
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root%)
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root%)
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root%)
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root%)
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
########################################### [100%]
warning: user abuild does not exist – using root
warning: group abuild does not exist – using root
[root@ www.linuxidc.com rpm]# ext
ext2online      ext2resize      extend_dmalloc  extlinux        extractrc      
ext2prepare     extcheck        extensionproxy  extractattr


安装过程中有warning信息,应该不会有影响。


在线扩展文件系统:


[root@ www.linuxidc.com ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       13G   12G  249M  98% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1006M     0 1006M   0% /dev/shm
.host:/                98G   94G  4.1G  96% /mnt/hgfs


[root@ www.linuxidc.com rpm]# ext2online /dev/VolGroup00/LogVol00
ext2online v1.1.18 – 2001/03/18 for EXT2FS 0.5b


[root@ www.linuxidc.com rpm]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       16G   12G  3.1G  80% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                1006M     0 1006M   0% /dev/shm
.host:/                98G   94G  4.1G  96% /mnt/hgfs


搞定!这个工具不错,现在有空间建库了。

赞(0) 打赏
转载请注明出处:服务器评测 » 在Linux使用ext2resize在线扩展文件系统
分享到: 更多 (0)

听说打赏我的人,都进福布斯排行榜啦!

支付宝扫一扫打赏

微信扫一扫打赏