ดีแล้ว ไป几天ก่อน ผมแนะนำคุณกับ Kernel-based Virtual Machine (KVM) technology โซลูชันการเสมือนฟรีและ open-source ที่คุณอาจพิจารณาใช้แทน VirtualBox และ VMware products - หรืออาจร่วมกับเหล่านั้น ก็ได้ ไม่ว่าจะเป็นอย่างไร เราได้ลอง basic management แต่อาจ storage และ network ไว้ทำ tutorials แยกกัน
วันนี้ ผมอยากให้คู่มือ in-depth มากขึ้นเกี่ยวกับการจัดการ storage ใน KVM นี่ค่อนข้างคล้ายกับสิ่งที่เราทำกับ VirtualBox รวมถึงการเพิ่ม, shrink และ expand virtual disks เราจะได้เรียนรู้วิธีสร้าง storage pools และ volumes รวมถึงตรวจสอบ fancy options บางอย่าง เช่น การใช้ NFS storage และ USB-connected external disks ที่ format ด้วย NTFS

Storage management
เปิด Virtual Machine Manager (VMM) คลิก Edit > Host Details > Storage tab

นี่จะเปิด Storage section ในคอลัมน์ซ้าย คุณจะเห็น storage pools ทั้งหมดที่ listed โดย default จะมีเพียงอันเดียว คือ default อยู่ภายใต้ /var ใน screenshot ด้านล่าง 18% ของ storage pool ถูกใช้งานอยู่ โดยไม่มี volumes available เพิ่งเริ่มต้น Not bad แต่ไม่จำเป็นว่านี่คือสิ่งที่เราต้องการ

ใน right pane คุณได้ overview ของ selected pool แรก คือ type เราจะพูดถึงเร็วๆ นี้ สอง คือ location State บอกสถานะของ pool ว่า active และ in use หรือ suspended Autostart บอกว่า pool นี้พร้อมสำหรับ virtual machines ของคุณเมื่อ KVM เปิดใช้งาน Volumes sub-section list virtual disks ทั้งหมดที่มีอยู่ใน pool รวมถึง names, sizes และ formats เราจะเห็นตัวอย่างในไม่ช้า KVM รองรับหลายประเภทของ images เราจะได้เรียนรู้เพิ่มเติมเร็วๆ นี้
Add storage pool
ตอนนี้ เราอยากเพิ่ม storage มองไปที่ล่างของ left column มีปุ่มหลายปุ่ม Plus หมายถึงเพิ่ม storage pools ปุ่ม play และ stop ใช้สำหรับ activate และ deactivate pools ตามลำดับ โดยไม่ลบมัน ปุ่มสุดท้ายจะทำแค่ลบ มาเพิ่ม disk space กัน

จำไว้: storage pool - logical storage group ที่สามารถ contain volumes หนึ่งหรือมากกว่า ซึ่งเป็น virtual disks ในทุกรูปแบบ มี 2 ขั้นตอน
ขั้นแรก เลือก name และ type คุณสามารถใช้ directories (mount points) รวมถึง NFS, SCSI และ iSCSI storage, LVM และแม้แต่ physical disks ผมลองใช้ NTFS-formatted external disk ที่เชื่อมต่อผ่าน USB และมันทำงานได้ดีเยี่ยม

Step 2 จะแตกต่างกัน ขึ้นอยู่กับตัวเลือกของคุณ สำหรับ filesystem directories กล่องส่วนใหญ่จะเป็นสีเทา แค่ใส่ Target Path และเสร็จแล้ว

แต่ถ้าคุณเลือก เช่น NFS คุณจะต้องใส่ข้อมูลเพิ่มเติม เช่น hostname, export directory, mountpoint, filesystem type


Create new volume
ตอนนี้ เราต้องการ volumes ใหม่ (disks) พวกมันจะมี suffix .img แต่มันสามารถ format ได้อย่างไรก็ได้ คุณอาจอยากใช้ raw หรือ vmdk ตัวอย่างเช่น Format จะกำหนดว่าคุณสามารถใช้ virtual machines กับโซลูชันอื่นๆ ได้หรือไม่


Storage formats รวมถึง raw, bochs, loopback, dmg, iso, qemu copy on write, vmdk, และ vpc ในทฤษฎี นี่ช่วยให้คุณใช้ virtual disks กับ Bochs, Parallels, QEMU, VMware, และ Hyper-V คุณยังสามารถสร้าง loopback devices และ ISO images ได้

Max. capacity คือ max. size ของ volume Allocation คือว่าคุณอยาก allocate เท่าไหร่ตอนนี้ กล่าวคือ หากคุณเลือก zero size คุณสร้าง sparse file ด้วย size 0 คุณสามารถ allocate ค่าไหนก็ได้ระหว่าง zero และ max. capacity
Job done
ในที่สุด คุณจะได้อย่างนี้:

และนั่นคือเสร็จสิ้น Finito il tutorial กล่าวได้
Conclusion
บทช่วยสอนนี้ไม่ใช่ rocket science แต่ก็ elaborate บาง typical questions ที่ new KVM user อาจมีเกี่ยวกับ storage management เราจำกัดงานของเราไว้ที่ graphical interface ดังนั้นคำถามจึงเกิดขึ้นว่า command line ยังไง? เราจะไปถึงที่นั่น eventually ตอนนี้ เราเรียนรู้ basics แล้ว เรารู้ว่า storage pools และ volumes คืออะไร และใช้ยังไง
เรามี tutorials อีกมากมายข้างหน้า รวมถึงการทำให้ VirtualBox และ KVM cooperate, setup bridged networking และดู many other neat, open-source virtualization solutions Stay tuned.
Cheers.