先关闭虚拟机电源,做如下设置:“ 虚拟机”--“虚拟机设置”--“磁盘”--“扩展”
可以随意添加你需要增到到的磁盘大小(如15Gb,表示磁盘总量,包含原来的磁盘容量); 再重启电源进入系统做如下步骤设置。
1. 启动虚拟机系统,用root登录(后续所有步骤都应以root用户身份登录操作),在 命令行用fdisk -l查看。由于这里是直接修改了原始空间大小,因此可以看到/dev/sda空间改变为16.1GB(原磁盘空间从10G增加到15G)。如果是从VMware菜单里增加虚拟硬盘,则会多出一个/dev/sd?,这里的?代表硬盘编号,第一个硬盘编号为a即sda,第二个就是sdb,第三个是sdc,以此类推,一般来说,如果以前没有增加过硬盘,那么原来的硬盘就是sda,通过VMware菜单增加的虚拟硬盘编号就是sdb。如果添加的第二块硬盘是IDE硬盘,就应该看到hdb,如果是 SCSI硬盘,看到的就应该是sdb。
2.使用fdisk /dev/sda进入菜单项,m是列出菜单,p是列出分区表,n是增加分区,w是保存并推出。由于这里增加的磁盘只有5G,因此5G划为一个区。
[[email protected] ~]# fdisk /dev/sda
The number of cylinders for this disk is set to 1958.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): p
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 1305 10377990 8e Linux LVM
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1306-1958, default 1306): +1306
Last cylinder or +size or +sizeM or +sizeK (1306-1958, default 1958): +1958
Value out of range.
Last cylinder or +size or +sizeM or +sizeK (1306-1958, default 1958):
Using default value 1958
Command (m for help): p
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 1305 10377990 8e Linux LVM
/dev/sda3 1306 1958 5245222+ 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
/dev/sda3 1306 1958 5245222+ 83 Linux
[[email protected] ~]# reboot #需reboot一下机器继续如下步骤
[[email protected] ~]# df -h #挂载前的分区情况
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
8.6G 2.8G 5.4G 35% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 125M 0 125M 0% /dev/shm
3. 使用mkfs.ext3 /dev/sda3 格式化分区
[[email protected] ~]# mkfs.ext3 /dev/sda3
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
656000 inodes, 1311305 blocks
65565 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1346371584
41 block groups
32768 blocks per group, 32768 fragments per group
16000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[[email protected] ~]# cd /
[[email protected] /]# mkdir /cm #增加一个/cm
[[email protected] /]# mount /dev/sda3 /cm #挂载分区到 /cm
[[email protected] /]# df -h #挂载后的分区情况
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
8.6G 2.8G 5.4G 35% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/sda3 5.0G 139M 4.6G 3% /cm
4.设置开机自动加载
创建加载点:mkdir /cm 挂载之后, 修改vi /etc/fstab 分区表文件,
在文件最后加上 /dev/sda3 /cm ext3 defaults 0 0 然后保存,重启即可。
(注意:修改分区表如果有误,将导致进不了linux桌面系统,但这时系统会进入commandline模式,我们可以在commandline模式下对有误的fstab进行修复更改,不过默认情况下这个commandline模式会是Read-Only file system,这意味着你的任何修改操作都是不允许的,但可以通过命令 mount / -o remount,rw 来解除这个限制)。
转自:http://blog.itpub.net/24435147/viewspace-694200/