情况:windows8安装虚拟机VMware,安装CentOS 64bit 虚拟空间分配最大6g,装Oracle提示空间不够
解决:
1:关闭虚拟机的Linux
2:向Linux的虚拟磁盘增加空间
我的Linux虚拟磁盘位置:F:\VMWareFile\CentOS 64-bit\CentOS 64-bit.vmdk 注意不是分开存储那些vmdk文件
我的VMware安装位置:C:\Program Files\VMware
打开windows命令行
切换到VMware的VMware Workstation目录的:cd C:\Program Files\VMware\VMware Workstation
增加虚拟磁盘空间(增加到9G,全量,不是增量):vmware-vdiskmanager.exe -x 9Gb "F:\VMWareFile\CentOS 64-bit\CentOS 64-bit.vmdk"
3:使用root登陆Linux
4:打开终端Teminal
利用df 和 flist命令查看磁盘情况,如下
[root@localhost /]# df -m
Filesystem 1M-blocks Used Available Use% Mounted on
/dev/sda2 3799 2757 849 77% /
tmpfs 495 1 495 1% /dev/shm
/dev/sda1 291 33 244 12% /boot
.host:/ 11257 5868 5389 53% /mnt/hgfs
[root@localhost /]# fdisk -l
Disk /dev/sda: 9663 MB, 9663676416 bytes
255 heads, 63 sectors/track, 1174 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005649
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 531 3951616 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 531 784 2031616 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
使/dev/sda所扩容的空间可以使用: sudo fdisk /dev/sda
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help):
输入n(
选择n表示新建分区):
n
Command action
e extended
p primary partition (1-4)
选择p:
p
Selected partition 4
First cylinder (784-1044, default 784): //此分区起始柱面,直接按回车,使用默认值
Using default value 784
Last cylinder, +cylinders or +size{K,M,G} (784-1044, default 1044): //直接回车
Using default value 1044
Command (m for help):
输入w进行保存: w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
退出fdisk命令后, 重启,重启打开终端输入: sudo fdisk -l
Disk /dev/sda: 9663 MB, 9663676416 bytes
255 heads, 63 sectors/track, 1174 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005649
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 531 3951616 83 Linux
Partition 2 does not end on cylinder boundary.
/dev/sda3 531 784 2031616 82 Linux swap / Solaris
Partition 3 does not end on cylinder boundary.
/dev/sda4 784 1044 2094474 83 Linux
格式化sda4(ext4 类型): mkfs -t ext4 /dev/sda4
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 523618 blocks
26180 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=536870912
16 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
我在Linux虚拟机上曾经创建过Oracle用户(通过这个用户来安装Oracle数据库),该用户的文件系统在home/oracle/下面,Oracle软件放在home/oracle/app下,现在我将新增加的空间挂载到home/oracle/app下
进行挂载:sudo mount -t ext4 /dev/sda4 /home/oracle/app -o rw
如果想让虚拟机每次启动都加载新加的设备,则必须修改etc/fstab的设置
转到etc:cd /etc
我喜欢先备份:cp -r ./fstab ./fstab_bk
打开fstab文件:gedit ./fstab
加入一下内容并保存:/dev/sda4 /home/oracle/app ext4 defaults 1 1
重启
5:要重新来过吗,试一下删除刚才的分区
首先恢复/etc/的fstab设置吧: gedit ./fstab 去掉:/dev/sda4 /home/oracle/app ext4 defaults 1 1
删除挂载:sudo umount /dev/sda4
删除分区:parted
GNU Parted 2.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
打印出来,输入:print
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 9664MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
1 1049kB 316MB 315MB primary ext4 boot
2 316MB 4362MB 4046MB primary ext4
3 4362MB 6442MB 2080MB primary linux-swap(v1)
4 6442MB 8587MB 2145MB primary ext4
(parted)
我们想删除第四个,输入: rm 4
重启
折腾了这么久,还是不够,找个有空间的电脑重新安装吧