原文地址: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訪問新擴大的磁碟了。