Obsolete:Aaron Huang

第一篇 建立nova 系統 控制中心Nova 也被稱為 OpenStack Compute, 是一套用開源控制基礎架構Iaas 的雲端運算平台軟體. 它的架構與功能類似Amazon EC2 與 Rackspace Cloud Servers. Nova 它本身是不包含虛擬化軟體，它是定義了一個驅動既有底層虛擬化作業系統的機制，並且將功能擴展為透過web API來進行操作. Openstack Nova (模式:單一控制台與多個節點 )繁體中文 安裝紀錄nova安裝硬體條件一 環境要求1.至少兩台一般電腦 安裝nova-compute需求CPU有支援Virtualization- CPU,若要查是否自己的cpu是否支援可以打egrep -c '(vmx|svm)' /proc/cpuinfo 檢查cpu是否支援虛擬化,如果算出來的數字大於 0 的話，就表示有支援了，不過還是記得要去 BIOS 裡確認是否有 Enable CPU Virtualization 的功能喔上 AMD 的官方網站查詢CPU是否支援ñ  http://www.amdtaiwan.com.tw/us-en/Processors/ProductInformation/030_11...上 Intel 的官方網頁查詢CPU是否支援ñ   http://processorfinder.intel.com/Default.aspx2. A.網路環境要求每台電腦配裝雙網卡(最好能上 GIGALAN )    B.需要網路環境有兩台一般Switch或者 Hub C.需要有兩個區段的網段,且兩部機器的外部網路(public),   與內部網路(Rang)必須個別的可找到對方使用ping 指令能有回應3.Linux版本:ubuntu 11.04 Server LTS4.硬碟空間則須看你把openstack nova 的分成幾個元件安裝,我們的例子是裝一台All in one的

二 網路拓璞架構圖'圖一' 

若以此圖將網路環境設好後請利用ping指令測試兩台電腦的兩個網段是否可以互相連接成功三':'安裝 'nova-controler Setp-1 更新安裝之前先進行更新 sudo apt-get update ;sudo apt-get upgrade Setp-2 設定安裝網路環境'目標:安裝 bridge '指令': sudo apt-get install bridge-utils '檢查 ':dpkg -l | grep bridge-utils '成功結果 :ii bridge-utils 1.4-5ubuntu2 Utilities for configuring the Linux Ethernet bridge錯誤狀況'/'故障排除': 網路可能不通 或者 apt-get 因網路環境無法更新 指令: sudo nano /etc/network/interfaces '編輯'ok '重啟 'sudo /etc/init.d/networking restartauto loiface lo inet loopbackauto br100iface br100 inet staticbridge_ports eth0bridge_stp offbridge_maxwait 0bridge_fd 0address 10.10.10.1netmask 255.255.255.0 auto eth1iface eth1 inet staticaddress 192.168.104.11netmask 255.255.255.0broadcast 192.168.104.255gateway 192.168.104.254dns-nameservers 61.64.127.1 檢查 :ifconfig成功結果 : br100    Link encap:Ethernet HWaddr 00:21:5e:01:02:33          inet addr:10.10.10.1 Bcast:10.10.10.255 Mask:255.255.255.0          inet6 addr: fe80::221:5eff:fe01:233/64 Scope:Link          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0          TX packets:189 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:0 (0.0 B) TX bytes:18749 (18.7 KB) eth0      Link encap:Ethernet HWaddr 00:10:18:1a:48:13          inet addr:192.168.104.11 Bcast:192.168.104.255 Mask:255.255.255.0          inet6 addr: fe80::210:18ff:fe1a:4813/64 Scope:Link          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1          RX packets:6470 errors:0 dropped:0 overruns:0 frame:0          TX packets:473 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:690979 (690.9 KB) TX bytes:108272 (108.2 KB)          Interrupt:16 eth1      Link encap:Ethernet HWaddr 00:21:5e:01:02:33          inet6 addr: fe80::221:5eff:fe01:233/64 Scope:Link          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1          RX packets:98 errors:0 dropped:0 overruns:0 frame:0          TX packets:148 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:8820 (8.8 KB) TX bytes:17781 (17.7 KB)          Interrupt:17 lo        Link encap:Local Loopback          inet addr:127.0.0.1 Mask:255.0.0.0          inet6 addr: ::1/128 Scope:Host          UP LOOPBACK RUNNING MTU:16436 Metric:1          RX packets:4 errors:0 dropped:0 overruns:0 frame:0          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:240 (240.0 B) TX bytes:240 (240.0 B)錯誤狀況'/'故障排除': '失敗 'networking '是無法 'restart '大概就是編輯錯誤Setp-3 安裝NTP ServerNova的各個所有組件的OpenStack要同步. 我們需要運做 NTPServer將每個組件同步時間指令': 'sudo apt-get install ntp'檢查 :'dpkg -l | grep ntp '成功結果 ':'ii ntp                 1:4.2.6.p2+dfsg-1ubuntu5.1                 Network Time Protocol daemon and utility programs'ii ntpdate           1:4.2.6.p2+dfsg-1ubuntu5.1                 client for setting system time from NTP servers'錯誤狀況'/'故障排除':'網路可能不通 或者 'apt-get '因網路環境無法更新安裝完成後接著我們必須編輯sudo vi /etc/ntp.conf 將底下這兩行加入後存檔server 127.127.1.0fudge 127.127.1.0 stratum 10 然後我們將 NTP Server 重新啟動sudo /etc/init.d/ntp restart* Stopping NTP server ntpd                                                                                            [ OK ] * Starting NTP server ntpd                                                                                            [ OK ]Setp-4 安裝mysql-server 設定nova需要的資料庫環境' OpenStack Nova提供兩種Database PostgreSQL or MySQL 我們選擇以MySQL進行目標:安裝 mysql-server '指令': sudo apt-get install -y mysql-server 接著我們會看到安裝的過程會需要設MySQL 的password 且需要輸入兩次一樣密碼按 ok,請設定一組密碼並將該密碼記住

檢查 :'dpkg -l | grep mysql-server'成功結果 :ii mysql-server  5.1.54-1ubuntu4     MySQL database server (metapackage depending on the latest version)ii mysql-server-5.1   5.1.54-1ubuntu4   MySQL database server binaries and system database setupii mysql-server-core-5.1   5.1.54-1ubuntu4          MySQL database server binaries錯誤狀況'/'故障排除': 網路可能不通 或者 apt-get 因網路環境無法更新安裝完成後必須在將nova的資料庫環境設定完成請一以下步驟完成,我們以較簡單 4.個步驟完成方式將底下的$MYSQL_PASS 都改成 剛剛所設定的MySql密碼,例如都設成novapasswd1.sudo mysql -uroot -p$MYSQL_PASS -e 'CREATE DATABASE nova;' 2.sudo mysql -uroot -p$MYSQL_PASS -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" 3.sudo mysql -uroot -p$MYSQL_PASS -e "SET PASSWORD FOR 'root'@'%' = PASSWORD('$MYSQL_PASS');"  1.'sudo mysql -uroot -pnovapasswd -e 'CREATE DATABASE nova;' 2.sudo mysql -uroot -pnovapasswd -e "GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;" 3.sudo mysql -uroot -pnovapasswd -e "SET PASSWORD FOR 'root'@'%' = PASSWORD('novapasswd');" '4.'sudo sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf ; sudo service mysql restartmysql start/running, process 220725.'接著我們安裝 'phpmysql'sudo apt-get -y install apache2 php5 libapache2-mod-auth-mysql php5-mysql 'phpmyadmin '來方便以後查詢'nova database'狀態','安裝過程一樣需要輸入密碼','請輸入'mysql root 密碼 這個例子中我們輸入novapasswd''' '我們可以輸入網址 http:// nova-cc ip/phpmyadmin/ '來查看與管理資料庫'''

'''

<> Setp-5 安裝Nova-Volumes先將硬碟分割完成fdisk /dev/sda'我們先把空間分出一區做'Linux LVM 'sudo apt-get install lvm2 'partprobe'fdisk -l'  Device Boot     Start         End      Blocks   Id System/dev/sda1   *           1        2432    19530752   83 Linux/dev/sda2            2432        3428     8000512   82 Linux swap / Solaris/dev/sda4            3428        9729    50615904+   5 Extended/dev/sda5            3428        9729    50615873   8e Linux LVMpvcreate /dev/sda5Physical volume "/dev/sda5" successfully createdvgcreate nova-volumes /dev/sda5 Volume group "nova-volumes" successfully createdsudo sed -i 's/false/true/g' /etc/default/iscsitarget 'service iscsitarget start'service nova-volume start   Setp-6 安裝nova 元件'目標:安裝 Nova Components'指令': 'sudo apt-get install -y rabbitmq-server nova-common nova-doc python-nova nova-api nova-network nova-volume nova-objectstore nova-scheduler nova-compute apt-get install glance'檢查 ':dpkg -l | grep rabbitmq-server; dpkg -l | grep nova-common;dpkg -l | grep nova-doc; dpkg -l | grep python-nova ; dpkg -l | grep nova-api; dpkg -l | grep nova-network; dpkg -l | grep nova-volume; dpkg -l | grep nova-objectstore; dpkg -l | grep nova-scheduler; dpkg -l | grep nova-compute ; dpkg -l | grep euca2ools ; dpkg -l |grep unzip; dpkg -l | grep bridge-utils 成功結果 :ii rabbitmq-server   2.3.1-1ubuntu1   An AMQP server written in Erlangii nova-common    2011.2-0ubuntu1 OpenStack Compute - Nova - common filesii nova-doc    2011.2-0ubuntu1         OpenStack Compute - Nova - documetationii python-nova     2011.2-0ubuntu1   OpenStack Compute - Nova - Python librariesii python-novaclient   2.4-0ubuntu1   client library for OpenStack Compute APIii nova-api 2011.2-0ubuntu1            OpenStack Compute - Nova - API frontendii nova-network   2011.2-0ubuntu1   OpenStack Compute - Nova - Network thingamajigii nova-volume 2011.2-0ubuntu1     OpenStack Compute - Nova - storageii nova-objectstore 2011.2-0ubuntu1 OpenStack Compute - Nova - object storeii nova-scheduler 2011.2-0ubuntu1   OpenStack Compute - Nova - Schedulerii nova-compute 2011.2-0ubuntu1   OpenStack Compute - Nova - compute nodeii euca2ools     1.3.1-0ubuntu7             managing cloud instances for Eucalyptusii unzip    6.0-4ubuntu1                   De-archiver for .zip filesii glance       2011.2-0ubuntu1        OpenStack Image Registry and Delivery Service - Daemonsii python-glance     2011.2-0ubuntu1   OpenStack Image Registry and Delivery Service - Python library錯誤狀況'/'故障排除: 網路可能不通 或者 apt-get 因網路環境無法更新設定nova 環境 sudo vi /etc/nova/nova.conf'''--dhcpbridge_flagfile=/etc/nova/nova.conf--dhcpbridge=/usr/bin/nova-dhcpbridge--logdir=/var/log/nova--state_path=/var/lib/nova--lock_path=/var/lock/nova--verbose--s3_host=192.168.104.11   ###外部ip--rabbit_host=10.10.10.1     ###內部ip--cc_host=10.10.10.1          ###內部ip--ec2_url=http://192.168.104.11:8773/services/Cloud   ###外部ip--fixed_range=10.0.0.0/8   --network_size=256--FAKE_subdomain=ec2   --routing_source_ip=10.10.10.1    ###內部ip--sql_connection=mysql://root:nova@192.168.104.11/nova ###外部ip 需要mysql帳號:密碼--glance_host=10.10.10.1    ###內部ip--image_service=nova.image.glance.GlanceImageService--iscsi_ip_prefix=10.10.10. 接著設定好後需要建立1.sudo sed -i 's/false/true/g' /etc/default/iscsitarget ; sudo service iscsitarget restart' * Removing iSCSI enterprise target devices:               [ OK ] * Stopping iSCSI enterprise target service:                  [ OK ] * Removing iSCSI enterprise target modules:            [ OK ] * Starting iSCSI enterprise target service                   [ OK ]                                                                                     [ OK ]2.'指令': 'sudo groupadd nova ; chmod 644 /etc/nova/nova.conf '   '檢查 ':'ls -la /etc/nova/nova.conf'成功結果 ':-rw-r--r-- 1 root nova 544 2011-08-06 01:15 /etc/nova/nova.conf3.'指令': 'sudo /etc/init.d/libvirt-bin start; sudo start nova-network; sudo start nova-compute; sudo start nova-api; sudo start nova-objectstore; sudo start nova-scheduler; sudo start nova-volume; sudo start glance-api; sudo start glance-registry'成功結果 ':Since the script you are attempting to invoke has been converted to anUpstart job, you may also use the start(8) utility, e.g. start libvirt-binstart: Job is already running: nova-networkstart: Job is already running: nova-computestart: Job is already running: nova-apistart: Job is already running: nova-objectstorestart: Job is already running: nova-schedulernova-volume start/running, process 21386start: Job is already running: glance-apistart: Job is already running: glance-registry  4.sudo nova-manage db sync 'sudo nova-manage user admin novaexport EC2_ACCESS_KEY=7f29fa0c-7ad1-4c4f-9105-3637daa9cd6dexport EC2_SECRET_KEY=4617cac1-6851-47e8-9c2f-1aef37f1bcefsudo nova-manage project create mycloud nova'sudo nova-manage network create 10.10.10.0/24 1 256'mkdir -p /home/nova/creds'sudo nova-manage project zipfile mycloud nova /home/nova/creds/novacreds.zip'unzip /home/nova/creds/novacreds.zip -d /home/nova/creds/Archive: /home/nova/creds/novacreds.zip extracting: /home/nova/creds/novarc extracting: /home/nova/creds/pk.pem extracting: /home/nova/creds/cert.pem extracting: /home/nova/creds/cacert.pemroot@nova-cc:~# sudo chown -R nova:nova /home/nova/creds/'root@nova-cc:~# ls -la /home/nova/creds/total 32drwxr-xr-x 2 nova nova 4096 2011-08-06 03:15 .drwxr-xr-x 3 root root 4096 2011-08-06 03:10 ..-rw--- 1 nova nova 1029 2011-08-06 03:11 cacert.pem-rw--- 1 nova nova 2503 2011-08-06 03:11 cert.pem-rw-r--r-- 1 nova nova 5786 2011-08-06 03:11 novacreds.zip-rw--- 1 nova nova 981 2011-08-06 03:11 novarc-rw--- 1 nova nova 887 2011-08-06 03:11 pk.pemsource /home/nova/creds/novarc'sudo /etc/init.d/libvirt-bin restart; sudo restart nova-network; sudo restart nova-compute; sudo restart nova-api; sudo restart nova-objectstore; sudo restart nova-scheduler; sudo restart nova-volume; sudo restart glance-api; sudo restart glance-registry Since the script you are attempting to invoke has been converted to anUpstart job, you may also use the stop(8) and then start(8) utilities,e.g. stop libvirt-bin ; start libvirt-bin. The restart(8) utility is also available.libvirt-bin stop/waitinglibvirt-bin start/running, process 23598nova-network start/running, process 23620nova-compute start/running, process 23648nova-api start/running, process 23663nova-objectstore start/running, process 23674nova-scheduler start/running, process 23699nova-volume start/running, process 23708glance-api start/running, process 23715glance-registry start/running, process 23732root@nova-cc:~# euca-describe-availability-zones verboseAVAILABILITYZONE       nova    availableAVAILABILITYZONE        |- nova-ccAVAILABILITYZONE        | |- nova-compute       enabled :-) 2011-08-06 08:15:15AVAILABILITYZONE        | |- nova-scheduler     enabled :-) 2011-08-06 08:15:13AVAILABILITYZONE        | |- nova-network       enabled :-) 2011-08-06 08:15:13AVAILABILITYZONE        | |- nova-volume        enabled :-) 2011-08-06 08:15:13 Nova Dashboard '安裝'sudo apt-get install -y bzr   sudo easy_install virtualenv Searching for virtualenvReading http://pypi.python.org/simple/virtualenv/Reading http://virtualenv.openplans.orgReading http://www.virtualenv.orgBest match: virtualenv 1.6.4Downloading http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.6.4.tar.gz#md5=1072b66d53c24e019a8f1304ac9d9fc5Processing virtualenv-1.6.4.tar.gzRunning virtualenv-1.6.4/setup.py -q bdist_egg --dist-dir /tmp/easy_install-qWaoju/virtualenv-1.6.4/egg-dist-tmp-yFJeF5warning: no previously-included files matching '*.*' found under directory 'docs/_templates'Adding virtualenv 1.6.4 to easy-install.pth fileInstalling virtualenv script to /usr/local/bin Installed /usr/local/lib/python2.7/dist-packages/virtualenv-1.6.4-py2.7.eggProcessing dependencies for virtualenvFinished processing dependencies for virtualenv '''sudo bzr init-repo. Shared repository with trees (format: 2a)Location: shared repository: .sudo bzr branch lp:openstack-dashboard -r 46 /opt/osdb  cd /opt/osdb sudo sh run_tests.sh ''' cd openstack-dashboard' 'cat /home/nova/creds/novarcsudo nano /opt/osdb/openstack-dashboard/local/local_settings.py  sudo tools/with_venv.sh dashboard/manage.py syncdb  sudo tools/with_venv.sh dashboard/manage.py runserver 0.0.0.0:8000' '輸入 http://IP:8000 這樣我們就完成了一個具備 'Dashboard (Web interface )'的 'Nova '控制中心','這個控制中心具有'nova-compute'功能但這樣無法表現'openstack'最大的優勢','彈性擴張計算能力'接著我們建立其他的'node(nova-compute),'讓整理系統擴大','您可以以此方法建立更多的節點','請繼續第二篇說明'有就是圖一'nova-1'電腦'第二篇'接著我們必須一樣先設定好網路環境與NTPServer'目標:設定網路環境'指令':'sudo apt-get install bridge-utils'檢查 :'dpkg -l | grep bridge-utils '成功結果 ':ii bridge-utils 1.4-5ubuntu2 Utilities for configuring the Linux Ethernet bridge錯誤狀況'/'故障排除':網路可能不通 或者 apt-get 因網路環境無法更新 指令: sudo vi /etc/network/interfaces '編輯'ok '重啟 'sudo /etc/init.d/networking restartauto loiface lo inet loopbackauto br100iface br100 inet staticbridge_ports eth0bridge_stp offbridge_maxwait 0bridge_fd 0address 10.10.10.2netmask 255.255.255.0 auto eth0iface eth0 inet staticaddress 192.168.104.12netmask 255.255.255.0broadcast 192.168.104.255gateway 192.168.104.254dns-nameservers 61.64.127.1 檢查 :ifconfig成功結果 : br100    Link encap:Ethernet HWaddr 00:21:5e:01:02:33          inet addr:10.10.10.2 Bcast:10.10.10.255 Mask:255.255.255.0          inet6 addr: fe80::221:5eff:fe01:233/64 Scope:Link          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1          RX packets:0 errors:0 dropped:0 overruns:0 frame:0          TX packets:189 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:0 (0.0 B) TX bytes:18749 (18.7 KB) eth0      Link encap:Ethernet HWaddr 00:10:18:1a:48:15          inet addr:192.168.104.12 Bcast:192.168.104.255 Mask:255.255.255.0          inet6 addr: fe80::210:18ff:fe1a:4813/64 Scope:Link          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1          RX packets:6470 errors:0 dropped:0 overruns:0 frame:0          TX packets:473 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:690979 (690.9 KB) TX bytes:108272 (108.2 KB)          Interrupt:16 eth1      Link encap:Ethernet HWaddr 00:21:5e:01:02:33          inet6 addr: fe80::221:5eff:fe02:233/64 Scope:Link          UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1          RX packets:98 errors:0 dropped:0 overruns:0 frame:0          TX packets:148 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000          RX bytes:8820 (8.8 KB) TX bytes:17781 (17.7 KB)          Interrupt:17 lo        Link encap:Local Loopback          inet addr:127.0.0.1 Mask:255.0.0.0          inet6 addr: ::1/128 Scope:Host          UP LOOPBACK RUNNING MTU:16436 Metric:1          RX packets:4 errors:0 dropped:0 overruns:0 frame:0          TX packets:4 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:0          RX bytes:240 (240.0 B) TX bytes:240 (240.0 B)錯誤狀況'/'故障排除': '失敗 'networking '是無法 'restart '大概就是編輯錯誤'安裝NTP ServerNova的各個所有組件的OpenStack要同步. 我們需要運做 NTPServer將每個組件同步時間指令': 'sudo apt-get install ntp'檢查 :'dpkg -l | grep ntp '成功結果 ':'ii ntp                 1:4.2.6.p2+dfsg-1ubuntu5.1                 Network Time Protocol daemon and utility programs'ii ntpdate           1:4.2.6.p2+dfsg-1ubuntu5.1                 client for setting system time from NTP servers'錯誤狀況'/'故障排除':'網路可能不通 或者 'apt-get '因網路環境無法更新安裝完成後接著我們必須編輯sudo vi /etc/ntp.conf 將底下這兩行加入後存檔server 192.168.104.11   #NTP Server nova 控制中心的ipsudo /etc/init.d/ntp restart 然後我們將 NTP Server 重新啟動* Stopping NTP server ntpd                                                                                            [ OK ]* Starting NTP server ntpd                                                                                            [ OK ]安裝nova 元件'目標:安裝 Nova Components'指令': 'sudo apt-get install -y nova-common python-nova nova-compute vlan euca2ools unzip    設定nova 環境 sudo vi /etc/nova/nova.conf' ('這裡我們可以把剛剛設好的 'nova-cc '的內容複製過來 改一下綠色的部分即可') --dhcpbridge_flagfile=/etc/nova/nova.conf--dhcpbridge=/usr/bin/nova-dhcpbridge--logdir=/var/log/nova--state_path=/var/lib/nova--lock_path=/var/lock/nova--verbose--s3_host=192.168.104.11   ###外部ip--rabbit_host=10.10.10.1     ###內部ip--cc_host=10.10.10.1          ###內部ip--ec2_url=http://192.168.104.11:8773/services/Cloud   ###外部ip--fixed_range=10.0.0.0/8   --network_size=256--FAKE_subdomain=ec2   --routing_source_ip=10.10.10.2 ###'內部'ip  '把'routing source '改成這個節的的內部網路'IP --sql_connection=mysql://root:nova@192.168.104.11/nova ###外部ip 需要mysql帳號:密碼--glance_host=10.10.10.1    ###內部ip--image_service=nova.image.glance.GlanceImageService--iscsi_ip_prefix=10.10.10. 這樣就完成一個node 非常的簡單 安裝過程大部分較困難的地方為 nova 控制中心 因為我們這裡採用All in one方式,簡化了許多各個元件溝通與透過兩張網卡方式減少許多繁瑣的地方方便玩成實際測試環境的過程,不過若真正要真正達成以此營運的目的建議還是最好把nova-network nova-volume nova-objectstore nova-scheduler nova-compute nova-glance 各自分開,當某一個元件失效不至於造成全系統不能運作            手動制作linux image先建立一個5G大小的img aaron@nova-cc:/home/nova$ sudo kvm-img create -f raw ubuntu1104ser.img 5G Formatting 'ubuntu1104ser.img', fmt=raw size=5368709120下載或者若有光碟機也可以利用作ISO檔wget http://releases.ubuntu.com/natty/ubuntu-11.04-server-amd64.iso製作光碟 sudo dd if=/dev/cdrom of=/home/nova/ubuntu-11.04-server-amd64.isoroot@nova-cc:/home/nova# sudo kvm -m 512 -cdrom ubuntu-11.04-server-amd64.iso -drive file=ubuntu1104ser.img,if=scsi,index=0 -boot d -net nic -net user -vnc :0 這個時候Terminal會停住我們要利用VNC 連到安裝的介面需要安裝 sudo apt-get install xvnc4viewer接著我們另開一個Terminal輸入vncviewer IP:1接著就可以安裝了安裝的過程需要注意在分割區工作時的把 5GB 空間全部分割為 ext4 根目錄/ ，一個就好也不用建立 swap 若有警告則不予理會安裝好重新開機接著我們必須用vncviewersudo kvm -hda ubuntu1104ser.img -vnc :0再進入一次調整一下這個OS 的相關設定sudo apt-get update; sudo apt-get upgrade;sudo apt-get install openssh-server cloud-init如果做的是Centos or Fedora yum update yum install openssh-server chkconfig sshd on安裝完成無誤後輸入 sudo rm - rf / etc/udev/rules.d/70-persistent-net.rules 目的在於砍掉當時對eth0的設定讓每次使用的時產生新的該VM網路卡的rule安裝完後 關機 shutdown -h nowsudo losetup -f  ubuntu1104ser.imgsudo losetup -a 你可以看到這樣的結果/dev/loop [0801]:16908388 ($filepath) 接著我們找出起始的sector root@nova-cc:/home/nova# sudo fdisk -cul /dev/loop0Disk /dev/loop1: 5368 MB, 5368709120 bytes 149 heads, 8 sectors/track, 8796 cylinders, total 10485760 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00048055 Device Boot      Start         End      Blocks   Id System /dev/loop1p0 *        2048    10483711     5240832   83 Linux 上面最後一行顯示sector 是從2048开始的，單一sector是512bytes ， 2048 x 512 = 1048576 這個數字要記接著我們要要複製 loop0 先Unmount loop0 sudo losetup -f -o 1048576 server.imgsudo losetup -d /dev/loop0sudo losetup -a 可以看到底下這行/dev/loop0: [0801]:550044 (/home/nova/ubuntutemplate.img), offset 1048576sudo dd if=/dev/loop0 of=ubuntu1104server_template.img10483712+0 records in 10483712+0 records out 5367660544 bytes (5.4 GB) copied, 133.322 s, 40.3 MB/s複製之後先卸載 loop0 sudo losetup -d /dev/loop0再來我們先mountsudo mount -o loop serverfinal.img /mnt將最底下的這行註解掉#UUID=548c16fd-889a-4248-bc45-e75c9802d69a /               ext4    errors=remount-ro $改成 LABEL=uec-rootfs /ext4 defaults 0 0 sudo cp /mnt/boot/vmlinuz-2.6.38-7-server /home/nova