I 've written about Xen rapid deployment (http://www.linuxidc.com/Linux/2012-07/66081.htm) on Ubuntu and a recent deployment of KVM virtualization on Ubuntu (http://www.linuxidc.com/Linux/2012-07/66082.htm ). The previous article was written earlier, and Xen has been replaced by KVM. The later article mainly uses graphical interfaces for operations. Although it is versatile, it is more efficient.
I 've written about Xen rapid deployment (http://www.linuxidc.com/Linux/2012-07/66081.htm) on Ubuntu and a recent deployment of KVM virtualization on Ubuntu (http://www.linuxidc.com/Linux/2012-07/66082.htm ). The previous article was written earlier, and Xen has been replaced by KVM. Later, Xen is mainly operated on a graphical interface. Although its versatility is strong, it is inefficient and cannot be batch quantified.
This time, a tool provided by Ubuntu is used to quickly batch customize the KVM-based Ubuntu virtual machine.
First, install the custom package apt-get install ubuntu-vm-builder
cd /data/virtual; ubuntu-vm-builder kvm lucid --debug
--addpkg=openssh-server --hostname=Webserver --bridge=br0
-m 512 --ip=192.168.1.55 --gw=192.168.1.254 --dns=8.8.8.8
-a i386 --user=litrin --password=litrin
--libvirt qemu:///system
The entire system downloads and installs the image by itself, and silently installs the entire system. The rest is that it is really convenient to wait until it is finished! There are very few Chinese documents, most of which are posted. Here I will explain several important parameters first.
All parameters except the beginning of "Kvm lucid" can be omitted and the system default value can be used.
Kvm lucidThe installation version type. Common sense: the customer version cannot exceed the host version. That is, lucid (1004) cannot be installed with natty (1104), but lucid can be installed on natty.
-Hostname = WebserverThe name of the VM. It must be unique.
-DebugDebug the output. Enable it for the first time. At least know where the error is.
-Bridge = br0See here for the name of the bound Nic
-A i386 |-arch = i386Platform type. The default value is the same as that of the host platform.
-Cpus = 2Number of Virtual Machine CPUs. The default value is 1.
-M512 |-mem = 512Memory size allocated. The default value is 128, in MB.
-Ip = 192.168.1.55-gw = 192.168.1.254Configure the IP address and gateway of the virtual machine. The default value is DHCP. The corresponding-mac address (mac address)-mask (mask)-net (network)-bcast (broadcast) -dns (guess it yourself !)
-User = litrin |-password = litrinThe default account and password are added. Here, I didn't use these two parameters for the first time. Instead, I used the default value. After the installation is complete, I realized that I could not enter the system, I tried to use ubuntu users and ubuntu as the password. It seems that I am lucky to get home, and I suddenly guessed the default configuration. If it is directly on the public network, to prevent people from being as lucky as me, you should set it up during installation. Another similar-rootpass is not recommended.
-Ssh-key = ~ /. Ssh/authorized_keysAutomatically add a root ssh authentication public key.
-Libvirt qemu: // systemDirectly add the virtual machine to the local virt-manager. Note that the local machine is not Localhost, but system, which is a bit unreasonable. Supports remote hosts through ssh.
-Addpkg = openssh-serverInstall software packages. You can configure multiple packages. -Removepkg = openssh-server
-Install-mirrorChoose Ubuntu image site, such as http://mirrors.163.com/ubuntu-releases
-Iso = ~ /Ubuntu. isoDirectly use the local ISO for installation, which is strongly recommended with the current network bandwidth
-Lang = zh_CN.utf-8Default character, en_US.UTF-8 by default
-Timezone = CSTDefault Time Zone, UTC by default
-Firstboot = PATHThe script for the first startup can be set in this way because the above-addpkg = openssh-server method only adds the ssh server and is not set as the startup Item. Similar to-firstlogin = PATH, the first login script.
-Rootsize = SIZE |-optsize = SIZE |-swapsize = SIZEThe partition sizes of/,/opt and swap are respectively. By default, only one 3.8G swap and one gb swap need more detailed configuration, and the operations are performed through the-part = configuration file, configuration File Format:
root 2000 /boot 512 swap 1000 --- /var 8000 /var/log 2000
Use-to use the new Virtual Disk
-Raw = PATHUse a bare device as the first virtual disk. I have never tested it. If you are interested, try it.
After joining virt-manager by default, you need to start it manually and bind the local port 5900 to listen to the vnc Server by default. The remote host can connect to the server through the ssh channel at a cost of 5900. However, using the VNC tool that comes with MAC is a tragedy. It does not support connecting to local 5900 and can only be used to connect to the console.
PS:
Due to Wordpress display problems, all dual lines (--) are replaced with single lines (-). Here, all the documents on this site must follow the consistent principles of Linux: A single line is followed by a single letter, and a parameter is configured after a space. A dual line is followed by a full configuration, a single line is used for word rooms, and a = and is used for subsequent configuration.