回收VMWare虛擬機器佔用的磁碟空間

來源:互聯網
上載者:User

虛擬機器裡裝了個Ubuntu 10.04,是老早以前了的了,由於僅安裝了開發環境和Oracle 10g,佔用空間在8G左右。

前幾天升級了12.04.01,麻煩來了,虛擬機器硬碟空間暴增至16G左右,卸載了openoffice等不用的軟體,apt-get clean了,apt-get autoremove了。

df -H了一下,OK,磁碟佔用8G左右了,可是虛擬機器硬碟還是16G大小!

折騰了半天,查了N多資料,終於搞定:

1. 虛擬機器設定的硬碟選項中先Compac一下;

2.開虛擬機器

Before we try to shrink the virtual disk files, we should try to remove any unneeded files from the virtual machine to free space. For example, on Debian-based VMs, you can run

apt-get clean

to clear out the local repository of retrieved package files.

Next, run

cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill

to fill the unused space with zeros.

Then power down the VM and open the command window on the Windows host:

3.宿主機執行命令:vmware-vdiskmanager.exe -k F:\*****\ubuntu-10.04.4-desktop-i386.vmdk

提示 Shrink: 100% done.

Shrink completed successfully.

完成

注意:折騰了多次,就是因為,沒有cat /dev/zero > zero.fill;sync;sleep 1;sync;rm -f zero.fill,所以沒成,可能是需要wipe吧。

小提示

以下這些情況是無法使用shrink功能的:

★使用預設建立的GSX Server虛擬機器。

★使用了快照功能的虛擬機器。

★使用了物理磁碟為虛擬機器磁碟。

★虛擬磁碟儲存在CD-ROM或DVD-ROM上。

★你不能收縮預分配的磁碟。

在進行收縮之前,需要刪除建立的快照,之後,直接登入虛擬,開啟VmwareTools就可能收縮磁碟了。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.