VirtualBox增大硬碟容量(guest為Linux)

來源:互聯網
上載者:User

原文地址:http://blog.csdn.net/ariesjzj/article/details/7269784

如果virtualbox中的guest系統出現磁碟空間不足的情況,最方便的方法就是將已有硬碟變大。網上能找到不少guest為windows時的擴大硬碟容量的方法,但在guest為linux時又略有不同。其實方法不止一種,下面以virtualbox內建的調整工具為例進行說明。

 

第一步:

如guest系統的vdi為debian_work.vdi,原大小為10G,現在想要擴大到20G,則到virtualbox安裝路徑下運行:

vboxmanage modifyhd debian_work.vdi --resize 20000

註:

1. 只有當vdi建立時選的動態擴充才有效。

2. 參數resize後以M為單位,只能比原來的空間大。

3. 實際當中vdi可能會需要加路徑。

這是官方文檔上的一段說明:

"The --resize option allows you to expand the capacity of an existing image; this increases thelogical size of a virtual disk without affecting the physical size much.[32] This
currently works only for the VDI and VHD formats, and only for the dynamically expanding variants. For example, if you originally created a 10G disk which is now full, you can use the --resize command to add more space to the virtual disk without having to
create a new image and copy all data from within a virtual machine."

 

第二步:

如果第一步成功了的話會在virtualbox的管理介面裡看到該vdi檔案的虛擬大小為20G,但實際大小為10G不到。到guest系統(Linux)中執行

# fdisk -l

會發現/dev/sda中有一塊空間是沒有分配的,執行

# fdisk /dev/sda

進行分配,根據說明依次輸入

n(建立), p(主要磁碟分割), x(數字,代表/dev/sdax),起末位置一般預設即可,最後w儲存退出。

 

第三步:

重啟後看到建立分區(如/dev/sda3),然後將之掛載到某一目錄(如/workspace)。先運行

#blkid

得到建立分區/dev/sda3的UUID,然後編輯/etc/fstab,加上

UUID=xxxxxx    /workspace   ext3   errors =remount-ro  0   1

當中實際的參數請根據需要填寫。以後重啟完了就可以通過/workspace訪問新擴大的磁碟了。

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.