Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> ซอฟต์แวร์ >> เครื่องเสมือน

ขยายฮาร์ดดิสก์ VirtualBox พร้อม Snapshots: คู่มือขั้นตอน

นานมาแล้วเขียน tutorial shrink/expand VirtualBox hard disks ตอนนั้น shrink ง่าย แต่ grow disks ต้อง imaging โต๊ะพลิก Starting VirtualBox 4.X รองรับ native resize command ต้องใช้ native VBox hard disk formats ทำงานกับ dynamically resized volumes เท่านั้น แต่ยืดหยุ่นกว่าเดิม

มี VM ใกล้เต็ม disk ลองคำสั่ง สำเร็จ แต่ disk ไม่ใหญ่ขึ้น ตระหนักว่าใช้ snapshots ซึ่ง highlight แม้ใน original guide 10 ปีก่อน tutorial updated นี้จะแสดงวิธี expand disks safely/elegantly แม้มี snapshots ตามมา

(ภาพประกอบ)

Modifyhd (modifymedium)

การเปลี่ยนแปลงใหญ่ VirtualBox 4.X+: native resize command คำสั่ง:

sudo VBoxManage modifyhd "Ubuntu 18.10.vdi" --resize 16000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

รันคำสั่ง boot VM unchanged 10 GB boot live session GParted แสดง original size ไม่มี free/unallocated space อ่าน docs/forums: snapshots interfere with resizing ตอนนี้ delete snapshots - merge ทุกอย่าง single current state - หรือ better: keep snapshots และ expand testing ด้วย tiny catch ลอง scenario ที่สอง

(ภาพประกอบ)

โคลน VM และ Collapse Snapshots (Clone virtual machine & collapse snapshots)

ต้องทำ: clone machine collapse all snapshots single image แล้ว repeat resize operation เลือกชื่อ clone ใหม่ decide reinitialize network adapter addresses เลือก Full clone สำคัญ: select Current machine state - ใช้ latest snapshot เท่านั้น merge previous snapshot data เข้าไปในนี้ ได้ machine ไม่มี 'history' และ no snapshots tiny catch ประมาณนั้น

(ภาพประกอบ clone wizard)

Boot Live Session & Resize Disk (Boot into live session & resize disk)

ตรวจสอบ VM settings reflect size change ก่อนหน้า VM disk 10 GB ไม่เปลี่ยนถ้า modifyhd ตอนนี้ show ได้ ตรวจสอบด้วย partition manager GParted แต่ต้อง expand system root partition

(ภาพประกอบ GParted)

ตาม GParted tutorial: เพิ่มขนาด root partition ทำกับ root partition unmounted (live session) พยายาม mounted ได้แต่ไม่ advisable อาจ lose data ในทุก disk manipulation ต้องมี full backup หรือ system image เผื่อ complications

(ภาพประกอบ resized partition)

เสร็จแล้ว VM มี bigger disk ปัญหาพื้นที่หายไป ไม่ trivial หลาย cases ไม่สามารถ cloning หรือ resizing ได้ แต่ overall streamlined procedure กว่า decade ก่อน

สรุป (Conclusion)

หวังว่า useful ทั่วไปคนจะ run out of space ไม่ใช่มีมากเกิน ซึ่งเป็นเหตุผลที่ resize VMs สำคัญ - มักสร้างด้วย modest settings ไม่นับ future growth มากขึ้นถ้าทำได้ quick และไม่มาก interim steps

VirtualBox 4.X+ ให้ทำได้ relatively little fuss เรียนรู้ modifyhd, cloning หมายความว่าอะไรต่อ snapshots revisit old guide partition management GParted สิ่งบางอย่างไม่เปลี่ยน cloning = imaging ของกาลเก่า แต่ทำ native ใน VirtualBox useful จบแล้ว Take care.

Cheers.