您的位置:首页 > 运维架构 > Linux

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

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

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

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

环境:

[root@cheneydb2 ~]# 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@cheneydb2 ~]# 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@cheneydb2 ~]# 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@cheneydb2 ~]# 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@cheneydb2 ~]# 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@cheneydb2 ~]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

VG扩容:

[root@cheneydb2 ~]# 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@cheneydb2 ~]# vgextend VolGroup00 /dev/sdb1

/dev/hdc: open failed: No medium found

Volume group "VolGroup00" successfully extended

[root@cheneydb2 ~]# 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@cheneydb2 ~]# 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@cheneydb2 ~]# 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@cheneydb2 ~]# 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@cheneydb2 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@cheneydb2 rpm]# ext

ext2online ext2resize extend_dmalloc extlinux extractrc

ext2prepare extcheck extensionproxy extractattr

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

在线扩展文件系统:

[root@cheneydb2 ~]# 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@cheneydb2 rpm]# ext2online /dev/VolGroup00/LogVol00

ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b

[root@cheneydb2 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

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

本文出自 “Cheney.Yu” 博客,请务必保留此出处http://cheneyyu.blog.51cto.com/173219/943937
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: