linux虚拟机空间不足解决

深圳装修网

1、关闭虚拟机电源;启动Windows下的命令提示符界面;开始-运行-cmd:


2、通过 cd 命令进入VMware的安装目录 输入 d: 回车 cd D:\Program Files\VMware\VMware Workstation 回车(如:D:\Program

Files\VMware\VMware Workstation),输入“vmware-vdiskmanager”后按回车键,可显示关于该命令的说明。


3、执行如下命令:
vmware-vdiskmanager -x 30Gb "D:\RedHatVM\linux.vmdk" //该目录是你安装linux虚拟机的位置
参数 -x 表示要扩展虚拟机硬盘空间;紧随其后的数字指要扩展的大小(如30Gb,表示磁盘总量,包含原来的磁盘容量);最后是要操作的虚
拟机Linux的具体文件。


【注意】若路径名中有空格,必须以双引号括起来。


执行完毕,退出命令提示符窗口,重启VMware,这时虚拟机硬盘空间已变成30GB了。
如果原来的虚拟机硬盘已被分成了多个分区,那么在通过 vmware-vdiskmanager.exe扩大了硬盘空间后,还需要在虚拟机系统中安装第三方分

区工具来调整分区,如 Partition Magic.............等磁盘工具

----------------------------------------------------------------------------------------

Microsoft Windows XP [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.

C:\Documents and Settings\Thinkpad User>d:

D:\>cd D:\Program Files\VMware\VMware Workstation

D:\Program Files\VMware\VMware Workstation>dir
驱动器 D 中的卷是 TOOL
卷的序列号是 204B-E29E

D:\Program Files\VMware\VMware Workstation>vmware-vdiskmanager -x 30Gb "D:\RedH
atVM\Red Hat Enterprise Linux 4.vmdk"
Using log file C:\DOCUME~1\THINKP~1\LOCALS~1\Temp\vmware-Thinkpad User\vdiskmana
ger.log
Grow: 100% done.
The old geometry C/H/S of the disk is: 1305/255/63
The new geometry C/H/S of the disk is: 2088/255/63
Disk expansion completed successfully.

WARNING: If the virtual disk is partitioned, you must use a third-party
utility in the virtual machine to expand the size of the
partitions. For more information, see:
http://www.vmware.com/support/kb/enduser/std_adp.php?p_faqid=1647

D:\Program Files\VMware\VMware Workstation>

好了,到此就ok了。

Reboot your vm,check .

再根据下面的方法进行····

我们先启动Linux系统来fdisk -l 看一下

root@localhost ~]# fdisk -l
                                                                               
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
                                                                               
   Device Boot    Start       End    Blocks   Id System
/dev/sda1   *         1        25    200781   83 Linux
/dev/sda2            26       620   4779337+ 83 Linux
/dev/sda3           621       652    257040   82 Linux swap

可以看到硬盘空间确实已经增大了,但没有出现在我们的分区列表中。df 查看也和原来一样

[root@localhost ~]# df -l

文件系统    1K-块        已用         可用           已用%   挂载点

/dev/sda2              4704236    4374939    329297        93%        /
/dev/sda1              194443      9377        175027        6%          /boot
none                     95336        0              95336          0%         /dev/shm

那么我们就把这个空余空间用起来吧—— fdisk命令在/dev/sda(第一块scsi硬盘) 上   n 新加一个分区

[root@localhost ~]# fdisk /dev/sda

The number of cylinders for this disk is set to 1305.
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): m       按m或输入 help 获取参数帮助
Command action
Command action
a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
Command (m for help):n          选择 n 添加一个新分区

Command action
   e   extended
   p   primary partition (1-4)        选择p 创建主分区,e为创建逻辑分区
p

Selected partition 4
First cylinder (653-1305, default 653):               不作输入按系统默认大小去分配
Using default value 653
Last cylinder or +size or +sizeM or +sizeK (653-1305, default 1305):       不作输入按系统默认大小去分配
Using default value 1305

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: \x{8BBE}\x{5907}\x{6216}\x{8D44}\x{6E90}\x{5FD9}.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.

w保存并退出,将空余空间全部划分给了一个新分区 sda4,The kernel still uses the old table.
The new table will be used at the next reboot.   好吧,重启后再来 reboot 。

好了,再来fdisk -l 看一下

[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes


   Device Boot    Start       End    Blocks   Id System
/dev/sda1   *         1        25    200781   83 Linux
/dev/sda2            26       620   4779337+ 83 Linux
/dev/sda3           621       652    257040   82 Linux swap
/dev/sda4           653      1305   5245222+ 83 Linux

/dev/sda4出来了,但还没有格式化,也没有挂载到目录上面去。接下来就将它格式化成ext3,并挂载到 根目录(/)下去。

格式化成ext3 命令 mkfs.ext3 /dev/sda4

[root@localhost~]# mkfs.ext3 /dev/sda4
mke2fs 1.32 (09-Nov-2002)
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
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 (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

挂载到根目录命令:mount /dev/sda4   /         命令执行完,成功则没有任何提示,我们df 看一下

[root@localhost ~]# df -l

文件系统    1K-块        已用         可用           已用%   挂载点

/dev/sda2              4704236    4374939    329297        93%        /
/dev/sda1              194443      9377        175027        6%          /boot
none                     95336        0              95336          0%         /dev/shm

/dev/sda4              4704236    4374939    329297        93%        /
           成了这个样子,看来这方法并不行,怎么新挂上去的分区也被占用了93%。这里没懂是怎么回事 。没有达到我想要的效果,这个问题用这个方法解决不了,怎么办呢?歇会儿,再去百度&Google逛逛。

           恩,据CSDN有位仁兄说,Linux有这么个命令 parted ,可以来调整分区,不过很麻烦,全部是命令操作,还要自己计算好调整分区的起始和结束位置,技术含量太高,偶不会了,只会搞些简单的。

          继续找ing ~~,又找到这么个方法,有个软件可以像Windows中的partitionmagic一样操作Linux分区,名叫gparted ,和parted命令有些相似,是不是有些根源?赶快去网上找找,在它的官网下载了这个软件,最新版滴,liveCD版的ISO文件,加载在光驱中启动去操作分区。init 6 重启 ,加载ISO文件,设置虚拟机BIOS从光驱启动………………  


GNOME partition editor 启动选择界面,就第一个直接回车吧,反正我也不晓得 。接下来好像还有软件语言选择吧,找了下,好像没有Chinese,有Japanese (TMD小日本),不过还是直接回车用USA吧。进入软件,看一下界面,是不是很像partitionmagic。

里面也看到了我的所有分区信息,接下来就是删除sda4,让他空出来,然后调整sda2,将它调大。

          又有问题了,swap分区在sda2 后面,sda2调不动。那就把swap先删了,把sda2调大,给swap留256M,然后再把这256M左右(调不准,输数字还不行)化成swap分区。

嘿嘿,还可以,行了,所有调整好后,最后Apply,等待它去执行吧! 等待



完成后,再重启,进入Linux系统,用fdisk -l 和df 命令查看,哈哈 ,OK了

[root@localhost ~]# fdisk -l

Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot    Start       End    Blocks   Id System
/dev/sda1   *         1        25    200781   83 Linux
/dev/sda2            26      1272 10016527+ 83 Linux
/dev/sda3          1273      1305    265072+ 82 Linux swap
[root@localhost ~]# df
文件系统    1K-块        已用         可用           已用%   挂载点

/dev/sda2              9860296   2024280    7435356     22%       /
/dev/sda1              194443      9377         175027       6%        /boot
none                     95336       0              95336        0%        /dev/shm

         到此所有问题已解决,花费了大半天的时间才整理出文档性的记录,以后可以直接参考着解决了。睡觉@@@

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值