在Linux使用ext2resize在线扩展文件系统
时间:2014-12-06 01:00 来源:linux.it.net.cn 作者:IT
一个做Oracle的工程师,笔记本上居然没有一套Oracle环境,说起来还真搞笑。今天要帮老婆倒腾一些数据,没办法,只好先装一套Oracle。在笔记本上已经有一个linux的虚拟机,本来是装DB2的,懒得再重装OS了,打算就在里面装Oracle。
整个系统就一个文件系统,再装完11g软件后,准备建库时发现没有空间了,数据库就装在根目录下,于是打算给根卷划一些空间,然后在线扩展文件系统。
这次准备用ext2resize工具在线扩展文件系统。
环境:
[root@ linux ~]# 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@ linux ~]# 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@ linux ~]# 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 BootStartEndBlocksIdSystem
/dev/sda1*1 1310439183Linux
/dev/sda2141958 15623212+8eLinux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
磁盘分区:
[root@ linux ~]# 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
atoggle a bootable flag
bedit bsd disklabel
ctoggle the dos compatibility flag
ddelete a partition
llist known partition types
mprint this menu
nadd a new partition
ocreate a new empty DOS partition table
pprint the partition table
qquit without saving changes
screate a new empty Sun disklabel
tchange a partition's system id
uchange display/entry units
vverify the partition table
wwrite table to disk and exit
xextra functionality (experts only)
Command (m for help): n
Command action
eextended
pprimary 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@ linux ~]# 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 BootStartEndBlocksIdSystem
/dev/sda1*1 1310439183Linux
/dev/sda2141958 15623212+8eLinux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device BootStartEndBlocksIdSystem
/dev/sdb116525237158+83Linux
创建PV:
[root@ linux ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
VG扩容:
[root@ linux ~]# vgdisplay
/dev/hdc: open failed: No medium found
--- Volume group ---
VG NameVolGroup00
System ID
Format lvm2
Metadata Areas1
Metadata Sequence No3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV2
Max PV 0
Cur PV 1
Act PV 1
VG Size14.88 GB
PE Size32.00 MB
Total PE476
Alloc PE / Size 476 / 14.88 GB
FreePE / Size 0 / 0
VG UUID3RQ6rK-WGtT-3eIv-0KBt-bimt-CS2A-WmAOei
[root@ linux ~]# vgextend VolGroup00 /dev/sdb1
/dev/hdc: open failed: No medium found
Volume group "VolGroup00" successfully extended
[root@ linux ~]# vgdisplay VolGroup00
/dev/hdc: open failed: No medium found
--- Volume group ---
VG NameVolGroup00
System ID
Format lvm2
Metadata Areas2
Metadata Sequence No4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV2
Max PV 0
Cur PV 2
Act PV 2
VG Size19.84 GB
PE Size32.00 MB
Total PE635
Alloc PE / Size 476 / 14.88 GB
FreePE / Size 159 / 4.97 GB
VG UUID3RQ6rK-WGtT-3eIv-0KBt-bimt-CS2A-WmAOei
扩展LV:
[root@ linux ~]# 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 Accessread/write
LV Statusavailable
# open1
LV Size 12.91 GB
Current LE 413
Segments1
Allocation inherit
Read ahead sectorsauto
- currently set to256
Block device253:0
[root@ linux ~]# 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@ linux ~]# 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 Accessread/write
LV Statusavailable
# open1
LV Size 16.00 GB
Current LE 512
Segments2
Allocation inherit
Read ahead sectorsauto
- currently set to256
Block device253:0
安装ext2resize工具:
[root@ linux 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@ linux rpm]# ext
ext2onlineext2resizeextend_dmallocextlinuxextractrc
ext2prepareextcheckextensionproxyextractattr
安装过程中有warning信息,应该不会有影响。
在线扩展文件系统:
[root@ linux ~]# df -h
FilesystemSizeUsed Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
13G12G249M98% /
/dev/sda199M13M82M14% /boot
tmpfs 1006M0 1006M0% /dev/shm
.host:/ 98G94G4.1G96% /mnt/hgfs
[root@ linux rpm]# ext2online /dev/VolGroup00/LogVol00
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b
[root@ linux rpm]# df -h
FilesystemSizeUsed Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
16G12G3.1G80% /
/dev/sda199M13M82M14% /boot
tmpfs 1006M0 1006M0% /dev/shm
.host:/ 98G94G4.1G96% /mnt/hgfs
搞定!这个工具不错,现在有空间建库了。
(责任编辑:IT)
一个做Oracle的工程师,笔记本上居然没有一套Oracle环境,说起来还真搞笑。今天要帮老婆倒腾一些数据,没办法,只好先装一套Oracle。在笔记本上已经有一个linux的虚拟机,本来是装DB2的,懒得再重装OS了,打算就在里面装Oracle。
这次准备用ext2resize工具在线扩展文件系统。
[root@ linux ~]# cat /etc/RedHat-release
Disk /dev/sda: 16.1 GB, 16106127360 bytes
Device BootStartEndBlocksIdSystem
Disk /dev/sdb: 5368 MB, 5368709120 bytes
[root@ linux ~]# fdisk /dev/sdb Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): h
Command (m for help): n
Command (m for help): w
Calling ioctl() to re-read partition table. [root@ linux ~]# fdisk -l
Disk /dev/sda: 16.1 GB, 16106127360 bytes
Device BootStartEndBlocksIdSystem
Disk /dev/sdb: 5368 MB, 5368709120 bytes
Device BootStartEndBlocksIdSystem
[root@ linux ~]# pvcreate /dev/sdb1
[root@ linux ~]# vgdisplay
[root@ linux ~]# vgextend VolGroup00 /dev/sdb1
[root@ linux ~]# vgdisplay VolGroup00
[root@ linux ~]# lvdisplay /dev/VolGroup00/LogVol00
[root@ linux ~]# lvextend -L 16g /dev/VolGroup00/LogVol00
[root@ linux ~]# lvdisplay /dev/VolGroup00/LogVol00
[root@ linux rpm]#rpm -ivh ext2resize-1.1.19-3.1.x86_64.rpm
在线扩展文件系统:
[root@ linux ~]# df -h
[root@ linux rpm]# ext2online /dev/VolGroup00/LogVol00
[root@ linux rpm]# df -h
(责任编辑:IT) |