前几天在虚拟机下装了centos4+oracle,用着用着10G的空间就不够了,登入oracle时候总是提示无法写入日志文件,导致登入失败,汗。。。看了下已经占用了8G多的空间,加上swap的2G,已经把空间占满了。。。
为了不想重装系统和oracle,就打算给他分配更大的空间咯。。。
有两种方案,第一种是直接加一个硬盘,就是编辑虚拟机,然后add一个硬盘,然后格式化磁盘,挂载磁盘(这个跟第二种方案的差不多)。。。这个给我的感觉比较麻烦,为什么不直接扩大原来分区的容量呢,接着就找到了第二种方案。
第二种方案,用vmware自带的vmware-vdiskmanager来扩大分区容量,具体步骤如下:
First:执行ctrl+R调出允许,然后输入cmd,进入dos模式,然后进到vmware的安装目录,我的是:F:\vmwar
Second:执行指令“vmware-vdiskmanager”,会提示该指令的参数信息:
VMware Virtual Disk Manager - build 59824.
Usage: vmware-vdiskmanager.exe OPTIONS |
Offline disk manipulation utility
Options:
-c : create disk; need to specify other create options
-d : defragment the specified virtual disk
-k : shrink the specified virtual disk
-n : rename the specified virtual disk; need to
specify destination disk-name
-p : prepare the mounted virtual disk specified by
the drive-letter for shrinking
-q : do not log messages
-r : convert the specified disk; need to specify
destination disk-type
-x : expand the disk to the specified capacity
Additional options for create and convert:
-a : (for use with -c only) adapter type (ide, buslogic o
r lsilogic)
-s : capacity of the virtual disk
-t : disk type id
Disk types:
0 : single growable virtual disk
1 : growable virtual disk split in 2Gb files
2 : preallocated virtual disk
3 : preallocated virtual disk split in 2Gb files
The capacity can be specified in sectors, Kb, Mb or Gb.
The acceptable ranges:
ide adapter : [100.0Mb, 950.0Gb]
scsi adapter: [100.0Mb, 950.0Gb]
ex 1: vmware-vdiskmanager.exe -c -s 850Mb -a ide -t 0 myIdeDisk.vmdk
ex 2: vmware-vdiskmanager.exe -d myDisk.vmdk
ex 3: vmware-vdiskmanager.exe -r sourceDisk.vmdk -t 0 destinationDisk.vm
dk
ex 4: vmware-vdiskmanager.exe -x 36Gb myDisk.vmdk
ex 5: vmware-vdiskmanager.exe -n sourceName.vmdk destinationName.vmdk
ex 6: vmware-vdiskmanager.exe -k myDisk.vmdk
ex 7: vmware-vdiskmanager.exe -p
(A virtual disk first needs to be mounted at )
Third:执行指令“vmware-vdiskmanager -x 16GB "f:\vmware\centos-Linux 4.vmdk"”
-x:指扩展;
16GB:扩展后的总容量;
引号内的为你装系统的.VMDK文件,
如果有多个如:centos-Linux 4-s001.vmdk,centos-Linux 4-s002.vmdk等,就写centos-Linux 4.vmdk
这样,原来分给linux的空间就变成16G了;
接下来是第一和第二两个方案都要执行的步骤:
由于前面分出来的空间还没有格式化,所以linux系统还无法识别,所以需要对它进行格式化,我用的是gparted工具格式化,步骤如下:
1、 把gparted考到linux的任意目录下,我放在/root/tool下,然后在命令窗口中执行unzip *.zip来解压下载的gparted.zip(因为我下的是压缩文件)文件,解压后会得到:COPYING,GParted-live-version,live,syslinux,utils;
2、 从命令窗口进入到gparted解压的目录,我的是/root/tool,然后执行命令“parted”(原来是这么近的,还不要安装呢),提示:
Copyright (C) 1998 - 2004 Free Software Foundation, Inc.
This program is free software, covered by the GNU General Public License.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
Using /dev/sda
(parted)
,执行“help”会有提示信息;
3、 补充下,可以通过:cat /proc/partitions来查看未格式化的分区,通过:df 查看可用的分区,还可通过sfdisk –l查看更详细的分区信息,/dev/shm是虚拟内存,没有深入研究
4、 接着开始分区:在(parted)下执行“mkpartfs primary ext3 1304 1700”,这里primay:定义主分区,相对于extended(扩展分区);ext3:系统文件类型,相当于windows的fat32;后面两个参数是磁盘开始点和结束点。
5、 上面执行成功后,linux应该就可以看到了,但是还有最后一步“挂载分区”:
在/创建一个挂载点 /extend, 看你自己子欢喜方在哪都可以.
去到/etc/fstab修改该文件(用文本编辑器), 如下所示例:
在/创建一个挂载点 /extend, 看你自己子欢喜方在哪都可以.
去到/etc/fstab修改该文件(用文本编辑器), 如下所示例:
# This file is edited by fstab-sync - see 'man fstab-sync' for details
LABEL=/ / ext3 defaults 1 1
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
LABEL=SWAP-sda2 swap swap defaults 0 0
/dev/hdc /media/cdrecorder auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
/dev/fd0 /media/floppy auto pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0
/dev/sda3 /extend ext3 defaults 0 0
然后,reboot系统,就大功告成了,哈哈。。。
附录:
ext2转成ext3的方法:
· Log in as root
· Make sure /etc/fstab has /dev/sda3 mounted to /test as ext2, read write
· umount /dev/sda3
o If you can't unmount it, then remount it read only (mount -o remount,ro /dev/sda10)
· tune2fs -j /dev/sda3
· Edit /etc/fstab, and for /dev/sda3, change ext2 to ext3
· mount /dev/sda3
· /sbin/shutdown -h now
· mount | grep /dev/sda3
o If it's not shown as ext3, reboot, if still not, troubleshoot
o Otherwise, you're done.
Ext3转成ext2的方法:
· tune2fs -O ^has_journal /dev/sda3
· e2fsck /dev/sda3
· Edit /etc/fstab to change /dev/sda3 to mount type ext2
· mount /dev/sda3
晕,这个编辑器还真不爽,字体都不好改,只能这样了
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10493602/viewspace-610911/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/10493602/viewspace-610911/