用虚拟机安操作系统,一般把空间分大点,也就不用扩展了,
分大了也不会占那么大空间,只要你选不是立即分配磁盘空间,最好直接分100G
参考:
VMware虚拟机更改硬盘大小之扩大篇
http://www.linuxidc.com/Linux/2012-09/69568.htm
VMware调整Linux硬盘大小的方法
http://blog.163.com/telereceive@126/blog/static/150309229201110394938892/
虚拟机,设置--磁盘--实用程序--扩展容量
本样例是从20G扩展到40G,最好直接扩展到100G,
[root@weblogic ~]# df -h
文件系统 容量 已用可用已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
18G 15G 2.2G 88% /
/dev/sda1 99M 14M 80M 15% /boot
tmpfs 872M 0 872M 0% /dev/shm
none 872M 40K 872M 1% /var/lib/xenstored
[root@weblogic ~]# du -h *
8.0K anaconda-ks.cfg
8.0K Desktop
40K install.log
8.0K install.log.syslog
8.0K RHEL5.7/packages
16K RHEL5.7
--挂载前
[root@weblogic ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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 2610 20860402+ 8e Linux LVM
[root@weblogic ~]#
--------------------------------------------------
[root@weblogic dev]# fdisk /dev/sda 对该硬盘进行操作
The number of cylinders for this disk is set to 5221.
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): n 新建分区
Command action
e extended
p primary partition (1-4)
p 主分区
Selected partition 3 默认的分区编号
w 保存
重启系统
重启后
[root@weblogic ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 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 2610 20860402+ 8e Linux LVM
/dev/sda3 2611 5221 20972857+ 83 Linux
[root@weblogic ~]# df -h
文件系统 容量 已用可用已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
18G 15G 2.2G 88% /
/dev/sda1 99M 14M 80M 15% /boot
tmpfs 872M 0 872M 0% /dev/shm
none 872M 104K 872M 1% /var/lib/xenstored
[root@weblogic ~]# partprobe /dev/sda3
扩展LVM
[root@weblogic dev]# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
[root@weblogic dev]# vgextend /dev/mapper/VolGroup00 /dev/sda3
Volume group "VolGroup00" successfully extended
[root@weblogic dev]# lvextend -L +20G /dev/mapper/VolGroup00-LogVol00
Extending logical volume LogVol00 to 37.91 GB
Logical volume LogVol00 successfully resized
[root@weblogic dev]# resize2fs /dev/mapper/VolGroup00-LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/VolGroup00-LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00 to 9936896 (4k) blocks.
The filesystem on /dev/mapper/VolGroup00-LogVol00 is now 9936896 blocks long.
核实磁盘空间是否增大
[root@weblogic dev]# df -h
文件系统 容量 已用可用已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
37G 15G 21G 42% /
/dev/sda1 99M 14M 80M 15% /boot
tmpfs 872M 0 872M 0% /dev/shm
none 872M 104K 872M 1% /var/lib/xenstored