以下教程是寫給已經熟練操作KVM+LVM的人看的。並且也安裝過不少次Ubuntu系統,所以很多內容都跳過了。
個人感覺如果自己用的話LVM是最好的。
首先通過lvm的lvcreate在宿主機上面創建一個邏輯卷
lvcreate -L 8000M -n sys_ubuntu_cn2009 /dev/vg_samsungssd840pro
然后直接把這個邏輯卷格式化成ext4
mkfs.ext4 /dev/mapper/vg_samsungssd840pro-sys_ubuntu_cn2009
接着編輯一個ubuntu-cn2009.xml文件
<domain type='kvm'> <name>ubuntu-cn2009</name> <uuid>3b026891-325a-44c7-82ce-bb531cea816c</uuid> <memory unit='KiB'>2097152</memory> <currentMemory unit='KiB'>2097152</currentMemory> <vcpu placement='static'>4</vcpu> <os> <type arch='x86_64' machine='pc-i440fx-xenial'>hvm</type> <boot dev='hd'/> <boot dev='cdrom'/> </os> <features> <acpi/> <apic/> <pae/> </features> <clock offset='localtime'> <timer name='rtc' tickpolicy='catchup'/> </clock> <on_poweroff>destroy</on_poweroff> <on_reboot>restart</on_reboot> <on_crash>restart</on_crash> <devices> <emulator>/usr/bin/kvm-spice</emulator> <disk type='block' device='disk'> <driver name='qemu' type='raw' cache='writeback'/> <source dev='/dev/mapper/vg_samsungssd840pro-sys_ubuntu_cn2009'/> <target dev='hda' bus='ide'/> <address type='drive' controller='0' bus='0' target='0' unit='0'/> </disk> <disk type='file' device='cdrom'> <driver name='qemu' type='raw'/> <source file='/mnt/iso/linux/ubuntu/ubuntu-16.04.1-server-amd64.iso'/> <target dev='hdc' bus='ide'/> <readonly/> <address type='drive' controller='0' bus='1' target='0' unit='0'/> </disk> <controller type='usb' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/> </controller> <controller type='pci' index='0' model='pci-root'/> <controller type='ide' index='0'> <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/> </controller> <interface type='bridge'> <mac address='52:54:00:ba:93:4f'/> <source bridge='br1'/> <virtualport type='openvswitch'> <parameters interfaceid='9555e13b-3f29-4d1b-9777-4f2b2c08930b'/> </virtualport> <model type='e1000'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/> </interface> <input type='tablet' bus='usb'/> <input type='mouse' bus='ps2'/> <input type='keyboard' bus='ps2'/> <graphics type='vnc' port='52009' autoport='no' listen='0.0.0.0' passwd='123'> <listen type='address' address='0.0.0.0'/> </graphics> <video> <model type='cirrus' vram='16384' heads='1'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/> </video> <memballoon model='virtio'> <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> </memballoon> </devices> </domain>
然后用virsh define ubuntu-cn2009.xml
就開機安裝了。
值得注意的是安裝過程中會提示你是否卸載(umount)掉/dev/sda,我把他的原版提示抄下來了。
The installer has detected that the fallowing disks have mounted partitions:
/dev/sda
Do you want the installer to try to unmount the partitions on these disks before
continuing? If you leave them mounted, you will not be able to create, delete, or resize
partitions on these disks, but you may be able to install to existing partitions there.
Unmount partitions that are in use?
<Go Back> <Yes> <No>
我就選擇了<No>, 因為我確實要把系統直接安裝到這個掛載好的/dev/sda分區里面,
所以后面提示我們要分區或者格式化什么都不需要了。就連GRUB引導都不用安裝了啊。
但是我們在分區的時候要選擇“手動”,然后把#1的假分區(實際就是/dev/sda)掛載(Mount point)到“/”,不用格式化。
當然他肯定會提示我們說沒有swap可能會影響性能什么的,還問要不要回去菜單重新來搞過,
直接選擇<No>就好。
真是麻煩,我都已經選擇不要格式化了,還問。。
繼續選<No>
最后還是會提示我們確認一下的。
這里要選擇<Yes>的。
到了提示你是否要安裝GRUB了,這里選<Yes>
但是他會說安裝出錯,
多試2次,第3次的時候會讓你選擇安裝到/dev/sda里面,就可以成功了。