Track2Agenda: ex-debian-kvm-libvirt.htm

File ex-debian-kvm-libvirt.htm, 53.9 KB (added by trac, 3 years ago)
Line 
1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5  <meta http-equiv="Content-Style-Type" content="text/css" />
6  <meta name="generator" content="pandoc" />
7  <title>Debian, KVM and libvirt</title>
8  <style type="text/css">code{white-space: pre;}</style>
9  <link href="data:text/css,%2F%2A%0A%20%20%20%20Buttondown%0A%20%20%20%20A%20Markdown%2FMultiMarkdown%2FPandoc%20HTML%20output%20CSS%20stylesheet%0A%20%20%20%20Author%3A%20Ryan%20Gray%0A%20%20%20%20Date%3A%2015%20Feb%202011%0A%20%20%20%20Revised%3A%2021%20Feb%202012%0A%20%20%20%0A%20%20%20%20General%20style%20is%20clean%2C%20with%20minimal%20re%2Ddefinition%20of%20the%20defaults%20or%20%0A%20%20%20%20overrides%20of%20user%20font%20settings%2E%20The%20body%20text%20and%20header%20styles%20are%20%0A%20%20%20%20left%20alone%20except%20title%2C%20author%20and%20date%20classes%20are%20centered%2E%20A%20Pandoc%20TOC%20%0A%20%20%20%20is%20not%20printed%2C%20URLs%20are%20printed%20after%20hyperlinks%20in%20parentheses%2E%20%0A%20%20%20%20Block%20quotes%20are%20italicized%2E%20Tables%20are%20lightly%20styled%20with%20lines%20above%20%0A%20%20%20%20and%20below%20the%20table%20and%20below%20the%20header%20with%20a%20boldface%20header%2E%20Code%20%0A%20%20%20%20blocks%20are%20line%20wrapped%2E%20%0A%20%0A%20%20%20%20All%20elements%20that%20Pandoc%20and%20MultiMarkdown%20use%20should%20be%20listed%20here%2C%20even%20%0A%20%20%20%20if%20the%20style%20is%20empty%20so%20you%20can%20easily%20add%20styling%20to%20anything%2E%0A%20%20%20%20%0A%20%20%20%20There%20are%20some%20elements%20in%20here%20for%20HTML5%20output%20of%20Pandoc%2C%20but%20I%20have%20not%20%0A%20%20%20%20gotten%20around%20to%20testing%20that%20yet%2E%0A%2A%2F%0A%20%0A%2F%2A%20NOTES%3A%0A%20%0A%20%20%20%20Stuff%20tried%20and%20failed%3A%0A%20%20%20%20%0A%20%20%20%20It%20seems%20that%20specifying%20font%2Dfamily%3Aserif%20in%20Safari%20will%20always%20use%20%0A%20%20%20%20Times%20New%20Roman%20rather%20than%20the%20user%27s%20preferences%20setting%2E%0A%20%20%20%20%0A%20%20%20%20Making%20the%20font%20size%20different%20or%20a%20fixed%20value%20for%20print%20in%20case%20the%20screen%20%0A%20%20%20%20font%20size%20is%20making%20the%20print%20font%20too%20big%3A%20Making%20font%2Dsize%20different%20for%20%0A%20%20%20%20print%20than%20for%20screen%20causes%20horizontal%20lines%20to%20disappear%20in%20math%20when%20using%20%0A%20%20%20%20MathJax%20under%20Safari%2E%0A%2A%2F%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Front%20Matter%20%2D%2D%2D%2D%20%2A%2F%0A%20%0A%2F%2A%20Pandoc%20header%20DIV%2E%20Contains%20%2Etitle%2C%20%2Eauthor%20and%20%2Edate%2E%20Comes%20before%20div%23TOC%2E%20%0A%20%20%20Only%20appears%20if%20one%20of%20those%20three%20are%20in%20the%20document%2E%0A%2A%2F%0A%20%0Adiv%23header%2C%20header%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Put%20border%20on%20bottom%2E%20Separates%20it%20from%20TOC%20or%20body%20that%20comes%20after%20it%2E%20%2A%2F%0A%20%20%20%20border%2Dbottom%3A%201px%20solid%20%23aaa%3B%0A%20%20%20%20margin%2Dbottom%3A%200%2E5em%3B%0A%20%20%20%20%7D%0A%20%0A%2Etitle%20%2F%2A%20Pandoc%20title%20header%20%28h1%2Etitle%29%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20text%2Dalign%3A%20center%3B%0A%20%20%20%20%7D%0A%20%0A%2Eauthor%2C%20%2Edate%20%2F%2A%20Pandoc%20author%28s%29%20and%20date%20headers%20%28h2%2Eauthor%20and%20h3%2Edate%29%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20text%2Dalign%3A%20center%3B%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20Pandoc%20table%20of%20contents%20DIV%20when%20using%20the%20%2D%2Dtoc%20option%2E%0A%20%20%20NOTE%3A%20this%20doesn%27t%20support%20Pandoc%27s%20%2D%2Did%2Dprefix%20option%20for%20%23TOC%20and%20%23header%2E%20%0A%20%20%20Probably%20would%20need%20to%20use%20div%5Bid%24%3D%27TOC%27%5D%20and%20div%5Bid%24%3D%27header%27%5D%20as%20selectors%2E%0A%2A%2F%0A%20%0Adiv%23TOC%2C%20nav%23TOC%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Put%20border%20on%20bottom%20to%20separate%20it%20from%20body%2E%20%2A%2F%0A%20%20%20%20border%2Dbottom%3A%201px%20solid%20%23aaa%3B%0A%20%20%20%20margin%2Dbottom%3A%200%2E5em%3B%0A%20%20%20%20%7D%0A%20%0A%40media%20print%0A%20%20%20%20%7B%0A%20%20%20%20div%23TOC%2C%20nav%23TOC%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%2F%2A%20Don%27t%20display%20TOC%20in%20print%20%2A%2F%0A%20%20%20%20%20%20%20%20display%3A%20none%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Headers%20and%20sections%20%2D%2D%2D%2D%20%2A%2F%0A%20%0Ah1%2C%20h2%2C%20h3%2C%20h4%2C%20h5%2C%20h6%0A%7B%0A%20%20%20%20font%2Dfamily%3A%20%22Helvetica%20Neue%22%2C%20Helvetica%2C%20%22Liberation%20Sans%22%2C%20Calibri%2C%20Arial%2C%20sans%2Dserif%3B%20%2F%2A%20Sans%2Dserif%20headers%20%2A%2F%0A%20%0A%20%20%20%20%2F%2A%20font%2Dfamily%3A%20%22Liberation%20Serif%22%2C%20%22Georgia%22%2C%20%22Times%20New%20Roman%22%2C%20serif%3B%20%2F%2A%20Serif%20headers%20%2A%2F%0A%20%0A%20%20%20%20page%2Dbreak%2Dafter%3A%20avoid%3B%20%2F%2A%20Firefox%2C%20Chrome%2C%20and%20Safari%20do%20not%20support%20the%20property%20value%20%22avoid%22%20%2A%2F%0A%7D%0A%20%0A%2F%2A%20Pandoc%20with%20%2D%2Dsection%2Ddivs%20option%20%2A%2F%0A%20%0Adiv%20div%2C%20section%20section%20%2F%2A%20Nested%20sections%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20margin%2Dleft%3A%202em%3B%20%2F%2A%20This%20will%20increasingly%20indent%20nested%20header%20sections%20%2A%2F%0A%20%20%20%20%7D%0A%20%0Ap%20%7B%7D%0A%20%0Ablockquote%0A%20%20%20%20%7B%20%0A%20%20%20%20font%2Dstyle%3A%20italic%3B%0A%20%20%20%20%7D%0A%20%0Ali%20%2F%2A%20All%20list%20items%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Ali%20%3E%20p%20%2F%2A%20Loosely%20spaced%20list%20item%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20margin%2Dtop%3A%201em%3B%20%2F%2A%20IE%3A%20lack%20of%20space%20above%20a%20%3Cli%3E%20when%20the%20item%20is%20inside%20a%20%3Cp%3E%20%2A%2F%0A%20%20%20%20%7D%0A%20%0Aul%20%2F%2A%20Whole%20unordered%20list%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Aul%20li%20%2F%2A%20Unordered%20list%20item%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Aol%20%2F%2A%20Whole%20ordered%20list%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Aol%20li%20%2F%2A%20Ordered%20list%20item%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Ahr%20%7B%7D%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Some%20span%20elements%20%2D%2D%2D%20%2A%2F%0A%20%0Asub%20%2F%2A%20Subscripts%2E%20Pandoc%3A%20H%7E2%7EO%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Asup%20%2F%2A%20Superscripts%2E%20Pandoc%3A%20The%202%5End%5E%20try%2E%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%20%20%20%0Aem%20%2F%2A%20Emphasis%2E%20Markdown%3A%20%2Aemphasis%2A%20or%20%5Femphasis%5F%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%20%20%20%0Aem%20%3E%20em%20%2F%2A%20Emphasis%20within%20emphasis%3A%20%2AThis%20is%20all%20%2Aemphasized%2A%20except%20that%2A%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20font%2Dstyle%3A%20normal%3B%0A%20%20%20%20%7D%0A%20%0Astrong%20%2F%2A%20Markdown%20%2A%2Astrong%2A%2A%20or%20%5F%5Fstrong%5F%5F%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Links%20%28anchors%29%20%2D%2D%2D%2D%20%2A%2F%0A%20%0Aa%20%2F%2A%20All%20links%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Keep%20links%20clean%2E%20On%20screen%2C%20they%20are%20colored%3B%20in%20print%2C%20they%20do%20nothing%20anyway%2E%20%2A%2F%0A%20%20%20%20text%2Ddecoration%3A%20none%3B%0A%20%20%20%20%7D%0A%20%0A%40media%20screen%0A%20%20%20%20%7B%0A%20%20%20%20a%3Ahover%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%2F%2A%20On%20hover%2C%20we%20indicate%20a%20bit%20more%20that%20it%20is%20a%20link%2E%20%2A%2F%0A%20%20%20%20%20%20%20%20text%2Ddecoration%3A%20underline%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%0A%40media%20print%0A%20%20%20%20%7B%0A%20%20%20%20a%20%20%20%7B%0A%20%20%20%20%20%20%20%20%2F%2A%20In%20print%2C%20a%20colored%20link%20is%20useless%2C%20so%20un%2Dstyle%20it%2E%20%2A%2F%0A%20%20%20%20%20%20%20%20color%3A%20black%3B%0A%20%20%20%20%20%20%20%20background%3A%20transparent%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20a%5Bhref%5E%3D%22http%3A%2F%2F%22%5D%3Aafter%2C%20a%5Bhref%5E%3D%22https%3A%2F%2F%22%5D%3Aafter%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%2F%2A%20However%2C%20links%20that%20go%20somewhere%20else%2C%20might%20be%20useful%20to%20the%20reader%2C%0A%20%20%20%20%20%20%20%20%20%20%20so%20for%20http%20and%20https%20links%2C%20print%20the%20URL%20after%20what%20was%20the%20link%20%0A%20%20%20%20%20%20%20%20%20%20%20text%20in%20parens%0A%20%20%20%20%20%20%20%20%2A%2F%0A%20%20%20%20%20%20%20%20content%3A%20%22%20%28%22%20attr%28href%29%20%22%29%20%22%3B%0A%20%20%20%20%20%20%20%20font%2Dsize%3A%2090%25%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Images%20%2D%2D%2D%2D%20%2A%2F%0A%20%0Aimg%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Let%20it%20be%20inline%20left%2Fright%20where%20it%20wants%20to%20be%2C%20but%20verticality%20make%20%0A%20%20%20%20%20%20%20it%20in%20the%20middle%20to%20look%20nicer%2C%20but%20opinions%20differ%2C%20and%20if%20in%20a%20multi%2Dline%20%0A%20%20%20%20%20%20%20paragraph%2C%20it%20might%20not%20be%20so%20great%2E%20%0A%20%20%20%20%2A%2F%0A%20%20%20%20vertical%2Dalign%3A%20middle%3B%0A%20%20%20%20%7D%0A%20%0Adiv%2Efigure%20%2F%2A%20Pandoc%20figure%2Dstyle%20image%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Center%20the%20image%20and%20caption%20%2A%2F%0A%20%20%20%20margin%2Dleft%3A%20auto%3B%0A%20%20%20%20margin%2Dright%3A%20auto%3B%0A%20%20%20%20text%2Dalign%3A%20center%3B%0A%20%20%20%20font%2Dstyle%3A%20italic%3B%0A%20%20%20%20%7D%0A%20%0Ap%2Ecaption%20%2F%2A%20Pandoc%20figure%2Dstyle%20caption%20within%20div%2Efigure%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Inherits%20div%2Efigure%20props%20by%20default%20%2A%2F%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Code%20blocks%20and%20spans%20%2D%2D%2D%2D%20%2A%2F%0A%20%0Apre%2C%20code%20%0A%20%20%20%20%7B%0A%20%20%20%20background%2Dcolor%3A%20%23fdf7ee%3B%0A%20%20%20%20%2F%2A%20BEGIN%20word%20wrap%20%2A%2F%0A%20%20%20%20%2F%2A%20Need%20all%20the%20following%20to%20word%20wrap%20instead%20of%20scroll%20box%20%2A%2F%0A%20%20%20%20%2F%2A%20This%20will%20override%20the%20overflow%3Aauto%20if%20present%20%2A%2F%0A%20%20%20%20white%2Dspace%3A%20pre%2Dwrap%3B%20%2F%2A%20css%2D3%20%2A%2F%0A%20%20%20%20white%2Dspace%3A%20%2Dmoz%2Dpre%2Dwrap%20%21important%3B%20%2F%2A%20Mozilla%2C%20since%201999%20%2A%2F%0A%20%20%20%20white%2Dspace%3A%20%2Dpre%2Dwrap%3B%20%2F%2A%20Opera%204%2D6%20%2A%2F%0A%20%20%20%20white%2Dspace%3A%20%2Do%2Dpre%2Dwrap%3B%20%2F%2A%20Opera%207%20%2A%2F%0A%20%20%20%20word%2Dwrap%3A%20break%2Dword%3B%20%2F%2A%20Internet%20Explorer%205%2E5%2B%20%2A%2F%0A%20%20%20%20%2F%2A%20END%20word%20wrap%20%2A%2F%0A%20%20%20%20%7D%0A%20%0Apre%20%2F%2A%20Code%20blocks%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Distinguish%20pre%20blocks%20from%20other%20text%20by%20more%20than%20the%20font%20with%20a%20background%20tint%2E%20%2A%2F%0A%20%20%20%20padding%3A%200%2E5em%3B%20%2F%2A%20Since%20we%20have%20a%20background%20color%20%2A%2F%0A%20%20%20%20border%2Dradius%3A%205px%3B%20%2F%2A%20Softens%20it%20%2A%2F%0A%20%20%20%20%2F%2A%20Give%20it%20a%20some%20definition%20%2A%2F%0A%20%20%20%20border%3A%201px%20solid%20%23aaa%3B%0A%20%20%20%20%2F%2A%20Set%20it%20off%20left%20and%20right%2C%20seems%20to%20look%20a%20bit%20nicer%20when%20we%20have%20a%20background%20%2A%2F%0A%20%20%20%20margin%2Dleft%3A%20%200%2E5em%3B%0A%20%20%20%20margin%2Dright%3A%200%2E5em%3B%0A%20%20%20%20%7D%0A%20%0A%40media%20screen%0A%20%20%20%20%7B%0A%20%20%20%20pre%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%2F%2A%20On%20screen%2C%20use%20an%20auto%20scroll%20box%20for%20long%20lines%2C%20unless%20word%2Dwrap%20is%20enabled%20%2A%2F%0A%20%20%20%20%20%20%20%20white%2Dspace%3A%20pre%3B%0A%20%20%20%20%20%20%20%20overflow%3A%20auto%3B%0A%20%20%20%20%20%20%20%20%2F%2A%20Dotted%20looks%20better%20on%20screen%20and%20solid%20seems%20to%20print%20better%2E%20%2A%2F%0A%20%20%20%20%20%20%20%20border%3A%201px%20dotted%20%23777%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%0Acode%20%2F%2A%20All%20inline%20code%20spans%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Ap%20%3E%20code%2C%20li%20%3E%20code%20%2F%2A%20Code%20spans%20in%20paragraphs%20and%20tight%20lists%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Pad%20a%20little%20from%20adjacent%20text%20%2A%2F%0A%20%20%20%20padding%2Dleft%3A%20%202px%3B%0A%20%20%20%20padding%2Dright%3A%202px%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0Ali%20%3E%20p%20code%20%2F%2A%20Code%20span%20in%20a%20loose%20list%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20We%20have%20room%20for%20some%20more%20background%20color%20above%20and%20below%20%2A%2F%0A%20%20%20%20padding%3A%202px%3B%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Math%20%2D%2D%2D%2D%20%2A%2F%0A%20%0Aspan%2Emath%20%2F%2A%20Pandoc%20inline%20math%20default%20and%20%2D%2Djsmath%20inline%20math%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%2F%2A%20Tried%20font%2Dstyle%3Aitalic%20here%2C%20and%20it%20messed%20up%20MathJax%20rendering%20in%20some%20browsers%2E%20Maybe%20don%27t%20mess%20with%20at%20all%2E%20%2A%2F%0A%20%20%20%20%7D%0A%20%20%20%20%0Adiv%2Emath%20%2F%2A%20Pandoc%20%2D%2Djsmath%20display%20math%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%20%20%20%0Aspan%2ELaTeX%20%2F%2A%20Pandoc%20%2D%2Dlatexmathml%20math%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%20%0A%20%0Aeq%20%2F%2A%20Pandoc%20%2D%2Dgladtex%20math%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%20%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Tables%20%2D%2D%2D%2D%20%2A%2F%0A%20%0A%2F%2A%20%20A%20clean%20textbook%2Dlike%20style%20with%20horizontal%20lines%20above%20and%20below%20and%20under%20%0A%20%20%20%20the%20header%2E%20Rows%20highlight%20on%20hover%20to%20help%20scanning%20the%20table%20on%20screen%2E%0A%2A%2F%0A%20%0Atable%0A%20%20%20%20%7B%0A%20%20%20%20border%2Dcollapse%3A%20collapse%3B%0A%20%20%20%20border%2Dspacing%3A%200%3B%20%2F%2A%20IE%206%20%2A%2F%0A%20%0A%20%20%20%20border%2Dbottom%3A%202pt%20solid%20%23000%3B%0A%20%20%20%20border%2Dtop%3A%202pt%20solid%20%23000%3B%20%2F%2A%20The%20caption%20on%20top%20will%20not%20have%20a%20bottom%2Dborder%20%2A%2F%0A%20%0A%20%20%20%20%2F%2A%20Center%20%2A%2F%0A%20%20%20%20margin%2Dleft%3A%20auto%3B%0A%20%20%20%20margin%2Dright%3A%20auto%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0Athead%20%2F%2A%20Entire%20table%20header%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20border%2Dbottom%3A%201pt%20solid%20%23000%3B%0A%20%20%20%20background%2Dcolor%3A%20%23eee%3B%20%2F%2A%20Does%20this%20BG%20print%20well%3F%20%2A%2F%0A%20%20%20%20%7D%0A%20%0Atr%2Eheader%20%2F%2A%20Each%20header%20row%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%20%0A%20%0Atbody%20%2F%2A%20Entire%20table%20%20body%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20Table%20body%20rows%20%2A%2F%0A%20%0Atr%20%20%7B%0A%20%20%20%20%7D%0Atr%2Eodd%3Ahover%2C%20tr%2Eeven%3Ahover%20%2F%2A%20Use%20%2Eodd%20and%20%2Eeven%20classes%20to%20avoid%20styling%20rows%20in%20other%20tables%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20background%2Dcolor%3A%20%23eee%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%2F%2A%20Odd%20and%20even%20rows%20%2A%2F%0Atr%2Eodd%20%7B%7D%0Atr%2Eeven%20%7B%7D%0A%20%0Atd%2C%20th%20%2F%2A%20Table%20cells%20and%20table%20header%20cells%20%2A%2F%0A%20%20%20%20%7B%20%0A%20%20%20%20vertical%2Dalign%3A%20top%3B%20%2F%2A%20Word%20%2A%2F%0A%20%20%20%20vertical%2Dalign%3A%20baseline%3B%20%2F%2A%20Others%20%2A%2F%0A%20%20%20%20padding%2Dleft%3A%20%20%200%2E5em%3B%0A%20%20%20%20padding%2Dright%3A%20%200%2E5em%3B%0A%20%20%20%20padding%2Dtop%3A%20%20%20%200%2E2em%3B%0A%20%20%20%20padding%2Dbottom%3A%200%2E2em%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0A%2F%2A%20Removes%20padding%20on%20left%20and%20right%20of%20table%20for%20a%20tight%20look%2E%20Good%20if%20thead%20has%20no%20background%20color%2A%2F%0A%2F%2A%0Atr%20td%3Alast%2Dchild%2C%20tr%20th%3Alast%2Dchild%0A%20%20%20%20%7B%0A%20%20%20%20padding%2Dright%3A%200%3B%0A%20%20%20%20%7D%0Atr%20td%3Afirst%2Dchild%2C%20tr%20th%3Afirst%2Dchild%20%0A%20%20%20%20%7B%0A%20%20%20%20padding%2Dleft%3A%200%3B%0A%20%20%20%20%7D%0A%2A%2F%0A%20%0Ath%20%2F%2A%20Table%20header%20cells%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20font%2Dweight%3A%20bold%3B%20%0A%20%20%20%20%7D%0A%20%0Atfoot%20%2F%2A%20Table%20footer%20%28what%20appears%20here%20if%20caption%20is%20on%20top%3F%29%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0Acaption%20%2F%2A%20This%20is%20for%20a%20table%20caption%20tag%2C%20not%20the%20p%2Ecaption%20Pandoc%20uses%20in%20a%20div%2Efigure%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20caption%2Dside%3A%20top%3B%0A%20%20%20%20border%3A%20none%3B%0A%20%20%20%20font%2Dsize%3A%200%2E9em%3B%0A%20%20%20%20font%2Dstyle%3A%20italic%3B%0A%20%20%20%20text%2Dalign%3A%20center%3B%0A%20%20%20%20margin%2Dbottom%3A%200%2E3em%3B%20%2F%2A%20Good%20for%20when%20on%20top%20%2A%2F%0A%20%20%20%20padding%2Dbottom%3A%200%2E2em%3B%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20%2D%2D%2D%2D%20Definition%20lists%20%2D%2D%2D%2D%20%2A%2F%0A%20%0Adl%20%2F%2A%20The%20whole%20list%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20border%2Dtop%3A%202pt%20solid%20black%3B%0A%20%20%20%20padding%2Dtop%3A%200%2E5em%3B%0A%20%20%20%20border%2Dbottom%3A%202pt%20solid%20black%3B%0A%20%20%20%20%7D%0A%20%0Adt%20%2F%2A%20Definition%20term%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20font%2Dweight%3A%20bold%3B%0A%20%20%20%20%7D%0A%20%0Add%2Bdt%20%2F%2A%202nd%20or%20greater%20term%20in%20the%20list%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20border%2Dtop%3A%201pt%20solid%20black%3B%0A%20%20%20%20padding%2Dtop%3A%200%2E5em%3B%0A%20%20%20%20%7D%0A%20%20%20%20%0Add%20%2F%2A%20A%20definition%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20margin%2Dbottom%3A%200%2E5em%3B%0A%20%20%20%20%7D%0A%20%0Add%2Bdd%20%2F%2A%202nd%20or%20greater%20definition%20of%20a%20term%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20border%2Dtop%3A%201px%20solid%20black%3B%20%2F%2A%20To%20separate%20multiple%20definitions%20%2A%2F%0A%20%20%20%20%7D%0A%20%20%20%20%0A%2F%2A%20%2D%2D%2D%2D%20Footnotes%20%2D%2D%2D%2D%20%2A%2F%0A%20%0Aa%2Efootnote%2C%20a%2EfootnoteRef%20%7B%20%2F%2A%20Pandoc%2C%20MultiMarkdown%20footnote%20links%20%2A%2F%0A%20%20%20%20font%2Dsize%3A%20small%3B%20%0A%20%20%20%20vertical%2Dalign%3A%20text%2Dtop%3B%0A%7D%0A%20%0Aa%5Bhref%5E%3D%22%23fnref%22%5D%2C%20a%2Ereversefootnote%20%2F%2A%20Pandoc%2C%20MultiMarkdown%2C%20%3F%3F%20footnote%20back%20links%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0A%40media%20print%0A%20%20%20%20%7B%0A%20%20%20%20a%5Bhref%5E%3D%22%23fnref%22%5D%2C%20a%2Ereversefootnote%20%2F%2A%20Pandoc%2C%20MultiMarkdown%20%2A%2F%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%2F%2A%20Don%27t%20display%20these%20at%20all%20in%20print%20since%20the%20arrow%20is%20only%20something%20to%20click%20on%20%2A%2F%0A%20%20%20%20%20%20%20%20display%3A%20none%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A%20%20%20%20%0Adiv%2Efootnotes%20%2F%2A%20Pandoc%20footnotes%20div%20at%20end%20of%20the%20document%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%20%20%20%0Adiv%2Efootnotes%20li%5Bid%5E%3D%22fn%22%5D%20%2F%2A%20A%20footnote%20item%20within%20that%20div%20%2A%2F%0A%20%20%20%20%7B%0A%20%20%20%20%7D%0A%20%0A%2F%2A%20You%20can%20class%20stuff%20as%20%22noprint%22%20to%20not%20print%2E%20%0A%20%20%20Useful%20since%20you%20can%27t%20set%20this%20media%20conditional%20inside%20an%20HTML%20element%27s%20%0A%20%20%20style%20attribute%20%28I%20think%29%2C%20and%20you%20don%27t%20want%20to%20make%20another%20stylesheet%20that%20%0A%20%20%20imports%20this%20one%20and%20adds%20a%20class%20just%20to%20do%20this%2E%0A%2A%2F%0A%20%0A%40media%20print%0A%20%20%20%20%7B%0A%20%20%20%20%2Enoprint%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20display%3Anone%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D%0A" rel="stylesheet" type="text/css" />
10</head>
11<body>
12<div id="header">
13<h1 class="title">Debian, KVM and libvirt</h1>
14</div>
15<div id="TOC">
16<ul>
17<li><a href="#objectives"><span class="toc-section-number">1</span> Objectives</a></li>
18<li><a href="#install-debian"><span class="toc-section-number">2</span> Install Debian</a><ul>
19<li><a href="#partitioning"><span class="toc-section-number">2.1</span> Partitioning</a></li>
20<li><a href="#software-selection"><span class="toc-section-number">2.2</span> Software selection</a></li>
21<li><a href="#basic-configuration"><span class="toc-section-number">2.3</span> Basic configuration</a></li>
22<li><a href="#network-configuration"><span class="toc-section-number">2.4</span> Network configuration</a><ul>
23<li><a href="#edit-etchostname"><span class="toc-section-number">2.4.1</span> Edit <code>/etc/hostname</code></a></li>
24<li><a href="#edit-etchosts-and-change-it-to-look-like-this"><span class="toc-section-number">2.4.2</span> Edit <code>/etc/hosts</code>, and change it to look like this:</a></li>
25<li><a href="#install-additional-networking-packages"><span class="toc-section-number">2.4.3</span> Install additional networking packages</a></li>
26<li><a href="#edit-etcnetworkinterfaces"><span class="toc-section-number">2.4.4</span> Edit <code>/etc/network/interfaces</code></a></li>
27<li><a href="#edit-etcresolv.conf"><span class="toc-section-number">2.4.5</span> Edit <code>/etc/resolv.conf</code></a></li>
28<li><a href="#reboot"><span class="toc-section-number">2.4.6</span> Reboot</a></li>
29<li><a href="#test-ssh"><span class="toc-section-number">2.4.7</span> Test ssh</a></li>
30</ul></li>
31</ul></li>
32<li><a href="#virtual-machine-tools"><span class="toc-section-number">3</span> Virtual machine tools</a><ul>
33<li><a href="#install-kvm-and-libvirt"><span class="toc-section-number">3.1</span> Install KVM and <code>libvirt</code></a></li>
34<li><a href="#check-for-hardware-virtualization-support"><span class="toc-section-number">3.2</span> Check for hardware virtualization support</a></li>
35<li><a href="#desktop-environment"><span class="toc-section-number">3.3</span> Desktop environment</a></li>
36<li><a href="#install-virt-manager-gui"><span class="toc-section-number">3.4</span> Install virt-manager GUI</a></li>
37</ul></li>
38<li><a href="#create-a-vm"><span class="toc-section-number">4</span> Create a VM</a><ul>
39<li><a href="#copy-ubuntu-iso-image"><span class="toc-section-number">4.1</span> Copy Ubuntu ISO image</a></li>
40<li><a href="#start-the-virt-manager-gui"><span class="toc-section-number">4.2</span> Start the virt-manager GUI</a></li>
41<li><a href="#create-a-vm-1"><span class="toc-section-number">4.3</span> Create a VM</a></li>
42<li><a href="#look-at-the-kvm-process"><span class="toc-section-number">4.4</span> Look at the KVM process</a></li>
43<li><a href="#find-the-disk-image-file"><span class="toc-section-number">4.5</span> Find the disk image file</a></li>
44</ul></li>
45<li><a href="#using-virsh-cli"><span class="toc-section-number">5</span> Using virsh CLI</a><ul>
46<li><a href="#setup"><span class="toc-section-number">5.1</span> Setup</a></li>
47<li><a href="#simple-commands"><span class="toc-section-number">5.2</span> Simple commands</a></li>
48<li><a href="#adding-a-serial-console"><span class="toc-section-number">5.3</span> Adding a serial console</a></li>
49</ul></li>
50<li><a href="#additional-exercises"><span class="toc-section-number">6</span> Additional exercises</a><ul>
51<li><a href="#vnc-remote-access-to-virt-manager-desktop"><span class="toc-section-number">6.1</span> VNC remote access to virt-manager desktop</a></li>
52<li><a href="#libvirt-storage-pools"><span class="toc-section-number">6.2</span> libvirt storage pools</a></li>
53<li><a href="#virt-install"><span class="toc-section-number">6.3</span> virt-install</a></li>
54<li><a href="#install-vm-with-qcow2-disk-iamge"><span class="toc-section-number">6.4</span> Install VM with QCOW2 disk iamge</a></li>
55<li><a href="#libvirt-snapshots"><span class="toc-section-number">6.5</span> libvirt snapshots</a></li>
56</ul></li>
57</ul>
58</div>
59<h1 id="objectives"><a href="#objectives"><span class="header-section-number">1</span> Objectives</a></h1>
60<p>Working in pairs, you will build a Linux-based virtualization host server on hardware provided in the class.</p>
61<ul>
62<li>Install Debian Linux. (This is because Ganeti, which we will be using later, is better supported under Debian than Ubuntu)</li>
63<li>Configure LVM during installation with manual partitioning so that most of the volume group is unused</li>
64<li>Use KVM with the <code>virt-manager</code> GUI and the <code>virsh</code> command-line interface to install and manage a VM.</li>
65</ul>
66<p>NOTE: please take care to install LVM as shown, creating some small logical volumes for the system but leaving most of the volume group unused, because later exercises will need to create more logical volumes from the free space.</p>
67<p>Please also name your volume group &quot;ganeti&quot;, because this has to be consistent throughout a cluster of machines.</p>
68<h1 id="install-debian"><a href="#install-debian"><span class="header-section-number">2</span> Install Debian</a></h1>
69<p>It may be necessary to press a key (e.g. F12) to get the option to boot from the USB stick.</p>
70<p>If you get the Debian splash screen, select &quot;install&quot; instead of &quot;graphical install&quot;.</p>
71<ul>
72<li>Language: English</li>
73<li>Country: as appropriate</li>
74<li>Locale settings: United States</li>
75<li>Keymap: American English</li>
76<li>Hostname: as allocated by instructor (hostX where X is a number)</li>
77<li>Domain name: ws.nsrc.org</li>
78<li>Root password: use the class root password</li>
79<li>Full name for new user: NSRC</li>
80<li>Username: &quot;nsrc&quot;</li>
81<li>Password: class user password</li>
82</ul>
83<h2 id="partitioning"><a href="#partitioning"><span class="header-section-number">2.1</span> Partitioning</a></h2>
84<ul>
85<li>Select &quot;Manual&quot;
86<ul>
87<li>Select your disk drive (sda)</li>
88<li>(If there is no partition table, you'll be prompted to create one)</li>
89</ul></li>
90<li>Delete existing partition(s)
91<ul>
92<li>Instructors will tell you the best approach</li>
93<li>If there's a large Windows partition, delete it</li>
94<li>If there's a Recovery partition, keep it</li>
95</ul></li>
96<li>Select &quot;pri/log FREE SPACE&quot;
97<ul>
98<li>Create a new partition</li>
99<li>New partition size: 1G (this is the /boot filesystem)</li>
100<li>Primary</li>
101<li>Beginning</li>
102<li>Use as: Ext4 journalling file system</li>
103<li>Mount point: /boot - static files of the boot loader</li>
104<li>Bootable flag: on</li>
105<li>Done setting up the partition</li>
106</ul></li>
107<li>Select &quot;pri/log FREE SPACE&quot;
108<ul>
109<li>Create a new partition</li>
110<li>Accept whatever size is shown (the rest of the disk)</li>
111<li>Primary</li>
112<li>Use as: physical volume for LVM</li>
113<li>Done setting up the partition</li>
114</ul></li>
115<li>Configure the Logical Volume Manager
116<ul>
117<li>Write changes to disks and configure LVM? Yes</li>
118<li>Create volume group
119<ul>
120<li>Volume group name: ganeti</li>
121<li>Devices for the new volume group: select only the LVM partition (probably /dev/sda2)</li>
122</ul></li>
123<li>Create logical volume
124<ul>
125<li>Volume group: ganeti</li>
126<li>Logical volume name: root</li>
127<li>Logical volume size: 4GB</li>
128</ul></li>
129<li>Create logical volume
130<ul>
131<li>Volume group: ganeti</li>
132<li>Logical volume name: swap</li>
133<li>Logical volume size: 4GB</li>
134</ul></li>
135<li>Create logical volume
136<ul>
137<li>Volume group: ganeti</li>
138<li>Logical volume name: var</li>
139<li>Logical volume size: 20GB</li>
140</ul></li>
141<li>Finish</li>
142</ul></li>
143<li><p>Select the entry #1 underneath LV <em>root</em></p>
144<pre><code>LVM VG ganeti, LV root - 4.0 GB Linux device-mapper (linear)
145     #1             4.0 GB   &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; select this &lt;&lt;&lt;&lt;&lt;&lt;&lt;</code></pre>
146<ul>
147<li>Use as: Ext4 journalling file system</li>
148<li>Mount point: / - the root filesystem</li>
149<li>Done setting up the partition</li>
150</ul></li>
151<li>Select the entry #1 underneath LV <em>swap</em>
152<ul>
153<li>Use as: swap area</li>
154<li>Done setting up the partition</li>
155</ul></li>
156<li>Select the entry #1 underneath LV <em>var</em>
157<ul>
158<li>Use as: Ext4 journalling file system</li>
159<li>Mount point: /var - variable data</li>
160<li>Done setting up the partition</li>
161</ul></li>
162<li>Finish partitioning and write changes to disk</li>
163<li><p>Write the changes to disks? Yes</p></li>
164</ul>
165<h2 id="software-selection"><a href="#software-selection"><span class="header-section-number">2.2</span> Software selection</a></h2>
166<ul>
167<li>Use a network mirror? Yes
168<ul>
169<li>Country: United States</li>
170<li>Mirror: cdn.debian.net</li>
171<li>HTTP proxy: <code>http://apt.ws.nsrc.org:3142/</code></li>
172</ul></li>
173<li>Participate in the package usage survey? No</li>
174<li>Software to install. Select only these:
175<ul>
176<li>[X] SSH server</li>
177<li>[X] Standard system utilities</li>
178<li>(Do not select &quot;Debian desktop environment&quot; or you will get tons of applications including LibreOffice, Iceweasel, The Gimp etc)</li>
179<li>(To save time, do not select &quot;Laptop&quot; even if this is a laptop. You can install package &quot;task-laptop&quot; later if you wish)</li>
180</ul></li>
181<li>Install the GRUB boot loader to the master boot record? Yes</li>
182<li>Installation complete - hit Continue</li>
183</ul>
184<p>You should now boot into the system.</p>
185<h2 id="basic-configuration"><a href="#basic-configuration"><span class="header-section-number">2.3</span> Basic configuration</a></h2>
186<p>Login as root.</p>
187<p>The first thing you will need to do is to get the installer to forget about the CD-ROM.</p>
188<p>As root, edit the file <code>/etc/apt/sources.list</code>, for example using vi:</p>
189<pre><code># editor /etc/apt/sources.list</code></pre>
190<p>Comment out any line which begins &quot;deb cdrom:...&quot; by inserting a hash (<code>#</code>) in front of it, changing it from this:</p>
191<pre><code>deb cdrom:[Debian GNU/Linux 7.3.0 [...]</code></pre>
192<p>To this:</p>
193<pre><code># deb cdrom:[Debian GNU/Linux 7.3.0 [...]</code></pre>
194<p>Then save the file.</p>
195<p>Install <code>sudo</code>, and add the 'nsrc' user into the 'sudo' group</p>
196<pre><code># apt-get update
197# apt-get install sudo
198# usermod -G sudo -a nsrc</code></pre>
199<p>Also install <code>vim</code> which is an improved version of the vi editor</p>
200<pre><code># apt-get install vim</code></pre>
201<h2 id="network-configuration"><a href="#network-configuration"><span class="header-section-number">2.4</span> Network configuration</a></h2>
202<p>Your server may have picked up a dynamic IP address via DHCP, which you can find out using the <code>ifconfig</code> command:</p>
203<pre><code># ifconfig eth0</code></pre>
204<p>Now you are going to give it a static IP address and also configure bridging so that your virtual machines can share the same network interface.</p>
205<p>Your machine will be given IP address 10.10.0.X</p>
206<h3 id="edit-etchostname"><a href="#edit-etchostname"><span class="header-section-number">2.4.1</span> Edit <code>/etc/hostname</code></a></h3>
207<pre><code>hostX.ws.nsrc.org</code></pre>
208<h3 id="edit-etchosts-and-change-it-to-look-like-this"><a href="#edit-etchosts-and-change-it-to-look-like-this"><span class="header-section-number">2.4.2</span> Edit <code>/etc/hosts</code>, and change it to look like this:</a></h3>
209<pre><code>127.0.0.1       localhost
21010.10.0.X       hostX.ws.nsrc.org       hostX</code></pre>
211<h3 id="install-additional-networking-packages"><a href="#install-additional-networking-packages"><span class="header-section-number">2.4.3</span> Install additional networking packages</a></h3>
212<pre><code># apt-get install bridge-utils vlan</code></pre>
213<h3 id="edit-etcnetworkinterfaces"><a href="#edit-etcnetworkinterfaces"><span class="header-section-number">2.4.4</span> Edit <code>/etc/network/interfaces</code></a></h3>
214<p>Change the file so that it looks like this. This removes the (dynamic) IP address from eth0, and instead creates a bridge interface &quot;br-lan&quot; with a static IP address, and eth0 a member of the bridge.</p>
215<pre><code># The loopback network interface
216auto lo
217iface lo inet loopback
218
219# Management interface
220auto eth0
221iface eth0 inet manual
222
223auto br-lan
224iface br-lan inet static
225        address         10.10.0.X
226        netmask         255.255.255.0
227        gateway         10.10.0.254
228        bridge_ports    eth0
229        bridge_stp      off
230        bridge_fd       0
231        bridge_maxwait  0</code></pre>
232<p>You can activate your changes like this:</p>
233<pre><code># ifdown eth0
234# killall dhclient
235# ifup br-lan
236# brctl show
237
238bridge name bridge id       STP enabled interfaces
239br-lan      8000.xxxxxxxxxxxx   no      eth0</code></pre>
240<p>You should see your new IP address on <code>ifconfig br-lan</code>, and you should still be able to ping out (e.g. <code>ping 8.8.8.8</code>)</p>
241<h3 id="edit-etcresolv.conf"><a href="#edit-etcresolv.conf"><span class="header-section-number">2.4.5</span> Edit <code>/etc/resolv.conf</code></a></h3>
242<pre><code>domain ws.nsrc.org
243nameserver 10.10.0.241</code></pre>
244<p>Check you can still resolve names (e.g. <code>ping apt.ws.nsrc.org</code>)</p>
245<h3 id="reboot"><a href="#reboot"><span class="header-section-number">2.4.6</span> Reboot</a></h3>
246<p>As a final check, reboot your server.</p>
247<pre><code># reboot</code></pre>
248<p>It should come up on the same IP address again.</p>
249<h3 id="test-ssh"><a href="#test-ssh"><span class="header-section-number">2.4.7</span> Test ssh</a></h3>
250<p>You should now be able to ssh into your server as user &quot;nsrc&quot; (e.g. using putty under Windows). Check you are able to do this. ssh to either <code>hostX.ws.nsrc.org</code> or <code>10.10.0.X</code></p>
251<p>Both people in the pair should be able to connect to the server from their laptop, so they don't need to share the console.</p>
252<p>NOTE: get into the habit of logging into the server as a normal user, and try to avoid logging in as &quot;root&quot;. You will see a prompt which ends with <code>$</code>. It's advisable to disable logging in as root directly over SSH (not covered here).</p>
253<p>If there is a single command you wish to run as root, prefix it with <code>sudo</code>. If you have a series of commands to run as root, start a root shell with <code>sudo -s</code>, and the prompt will change to <code>#</code>. When you have finished, type <code>exit</code> to leave the root shell.</p>
254<h1 id="virtual-machine-tools"><a href="#virtual-machine-tools"><span class="header-section-number">3</span> Virtual machine tools</a></h1>
255<h2 id="install-kvm-and-libvirt"><a href="#install-kvm-and-libvirt"><span class="header-section-number">3.1</span> Install KVM and <code>libvirt</code></a></h2>
256<pre><code># apt-get install qemu-kvm libvirt-bin</code></pre>
257<p>Now add the 'nsrc' user into the 'libvirt' group.</p>
258<pre><code># usermod -G libvirt -a nsrc</code></pre>
259<p>This is needed so you can talk to the libvirt daemon. If you are currently logged in as 'nsrc' you will need to logout and login again to pick up this group. The command &quot;id&quot; will show you what groups you are a member of.</p>
260<h2 id="check-for-hardware-virtualization-support"><a href="#check-for-hardware-virtualization-support"><span class="header-section-number">3.2</span> Check for hardware virtualization support</a></h2>
261<p>At a command line prompt, type the following:</p>
262<pre><code>$ egrep '(vmx|svm)' /proc/cpuinfo</code></pre>
263<p>If you get one or more lines containing &quot;vmx&quot; or &quot;svm&quot; then the processor has hardware virtualization capabilities. However this doesn't tell you if it's enabled in the BIOS.</p>
264<p>To verify, do:</p>
265<pre><code>$ ls -l /dev/kvm</code></pre>
266<p>If you see:</p>
267<pre><code>crw-rw---- 1 root kvm 10, 232 Jan 17 21:24 /dev/kvm</code></pre>
268<p>Then it's OK <sup><a href="#fn1" class="footnoteRef" id="fnref1">1</a></sup></p>
269<p>If KVM acceleration is not available, then you may need to reboot into the BIOS settings and enable VT-x (Intel) or AMD-V (AMD).</p>
270<h2 id="desktop-environment"><a href="#desktop-environment"><span class="header-section-number">3.3</span> Desktop environment</a></h2>
271<p>Install an X11 desktop (which we want just so that we can run virt-manager)</p>
272<pre><code># apt-get install xorg lxde</code></pre>
273<p>This will take a while - be patient!</p>
274<p>Once the install is finished, start the graphical environment:</p>
275<pre><code># service lightdm start</code></pre>
276<p>You should now be able to login to the graphical environment as the &quot;nsrc&quot; user. You can get a shell window using <code>Start &gt; Accessories &gt; LXTerminal</code>.</p>
277<p>You can also switch between text and graphical consoles using Ctrl-Alt-F1 and Ctrl-Alt-F7 respectively.</p>
278<h2 id="install-virt-manager-gui"><a href="#install-virt-manager-gui"><span class="header-section-number">3.4</span> Install virt-manager GUI</a></h2>
279<pre><code># apt-get install virt-manager</code></pre>
280<p>This installs a lot of extra packages because it depends on a lot of graphics libraries.</p>
281<h1 id="create-a-vm"><a href="#create-a-vm"><span class="header-section-number">4</span> Create a VM</a></h1>
282<p>On the virtualization host you have just built, you are going to install Ubuntu Server in a VM, using the virt-manager GUI which is similar to the VirtualBox GUI.</p>
283<h2 id="copy-ubuntu-iso-image"><a href="#copy-ubuntu-iso-image"><span class="header-section-number">4.1</span> Copy Ubuntu ISO image</a></h2>
284<p>First, copy the file <code>ubuntu-12.04.3-server-i386.iso</code> into the directory <code>/var/lib/libvirt/images</code> on your host.</p>
285<p>How to do this depends on where you are copying the image from.</p>
286<ul>
287<li>If you are copying from a USB stick: insert the stick. If you have a GUI it will ask you if you want to open with the File Manager. Say yes, and it should mount the USB stick automatically (on <code>/media/XXX</code>), and open a window.</li>
288</ul>
289<p>(XXX will be a random number, look at the title of the window)</p>
290<p>You can then copy the ISO:</p>
291<pre><code>~~~
292# cp /media/XXX/iso/ubuntu-12.04.3-server-i386.iso /var/lib/libvirt/images/
293~~~</code></pre>
294<p>If it doesn't work, you may need to mount it by hand:</p>
295<pre><code>~~~
296# dmesg | tail        # find the ID of the device just inserted, e.g. sdb
297# mount /dev/sdb1 /mnt
298# ls /mnt             # find the file
299# ls /mnt/iso         # find the file
300# cp /mnt/iso/ubuntu-12.04.3-server-i386.iso /var/lib/libvirt/images/
301# umount /mnt
302~~~</code></pre>
303<ul>
304<li><p>If you are copying from a web server:</p>
305<pre><code># cd /var/lib/libvirt/images
306# wget http://www.ws.nsrc.org/downloads/ubuntu-12.04.3-server-i386.iso</code></pre></li>
307</ul>
308<h2 id="start-the-virt-manager-gui"><a href="#start-the-virt-manager-gui"><span class="header-section-number">4.2</span> Start the virt-manager GUI</a></h2>
309<p>Use <code>Start &gt; System Tools &gt; Virtual Machine Manager</code>, or just type <code>virt-manager</code> at a terminal prompt while in the GUI.</p>
310<p>NOTE: to release the keyboard and mouse, press left-CTRL and left-ALT together.</p>
311<h2 id="create-a-vm-1"><a href="#create-a-vm-1"><span class="header-section-number">4.3</span> Create a VM</a></h2>
312<p>In the Virtual Machine Manager window:</p>
313<ul>
314<li>Click &quot;New&quot; (this is the PC-shaped button under the File menu)</li>
315<li>Step 1 of 5
316<ul>
317<li>Enter a name, e.g. &quot;ubuntu1&quot;</li>
318<li>Select &quot;Local install media (ISO image or CDROM)&quot;</li>
319<li>Click Forward</li>
320</ul></li>
321<li>Step 2 of 5
322<ul>
323<li>Check &quot;Use ISO image&quot; is selected</li>
324<li>Click &quot;Browse&quot;, and select <code>ubuntu-12.04.3-server-i386.iso</code> (if it's not there, click &quot;Browse Local&quot;, choose <code>File System</code> on the left, and browse to where you copied/downloaded the Ubuntu ISO image.</li>
325<li>OS type: Linux</li>
326<li>Version: select the nearest, which may be &quot;Ubuntu 11.10&quot;</li>
327<li>Click Forward</li>
328</ul></li>
329<li>Step 3 of 5
330<ul>
331<li>Memory: 512 MB</li>
332<li>CPUs: 1</li>
333<li>Click Forward</li>
334</ul></li>
335<li>Step 4 of 5
336<ul>
337<li>Create a disk image on the computer's hard drive</li>
338<li>4.0 GB</li>
339<li>Uncheck &quot;Allocate entire disk now&quot;</li>
340<li>Click Forward</li>
341</ul></li>
342<li>Step 5 of 5
343<ul>
344<li>Open &quot;Advanced options&quot;</li>
345<li>Check that the interface selected is &quot;Host device eth0 (Bridge 'br-lan')&quot;</li>
346<li>Click Finish</li>
347</ul></li>
348</ul>
349<p>At this point the VM will start and the console should appear. Continue to install your Ubuntu virtual machine however you like. Follow the instructions from the VirtualBox exercise if you wish. We recommend using &quot;Guided - use entire disk&quot; for partitioning, and please enter <code>http://apt.ws.nsrc.org:3142/</code> for the HTTP proxy. Install the &quot;OpenSSH Server&quot; package.</p>
350<p>When it has finished and rebooted, your VM should come back up. Login, type &quot;ifconfig&quot; to find what IP address it has come up on. This should be an address on 10.10.0.X which has been picked dynamically via DHCP.</p>
351<p>SSH into this address from your laptop (e.g. using Putty) and login. If you didn't select OpenSSH Server during the installation, then you can add it using <code>apt-get install openssh-server</code></p>
352<p>Congratulations: you have a created a working VM, it is on the network, and you have remote access to it!</p>
353<h2 id="look-at-the-kvm-process"><a href="#look-at-the-kvm-process"><span class="header-section-number">4.4</span> Look at the KVM process</a></h2>
354<p>You should be able to find the running <code>kvm</code> (or qemu-system) process like this:</p>
355<pre><code>$ ps auxwww | egrep '(kvm|qemu-system)'</code></pre>
356<p>Note the very large number of command line parameters given to kvm. Now you can see why we need <code>libvirt</code> to manage this for us :-)</p>
357<h2 id="find-the-disk-image-file"><a href="#find-the-disk-image-file"><span class="header-section-number">4.5</span> Find the disk image file</a></h2>
358<p>The disk image file is in the directory <code>/var/lib/libvirt/images</code> and you can find it like this:</p>
359<pre><code># cd /var/lib/libvirt/images
360# ls -slh</code></pre>
361<p>Note that the total size of the file is 4.0GB, but the disk space used (the left-hand column on the line) is less than this. This means it is a &quot;sparse&quot; file, because we de-selected &quot;allocate entire disk now&quot;.</p>
362<p>To view how much space is really used, you can use the <code>du</code> (disk use) command, like so:</p>
363<pre><code># du -m *</code></pre>
364<p>-m = megabytes</p>
365<h1 id="using-virsh-cli"><a href="#using-virsh-cli"><span class="header-section-number">5</span> Using virsh CLI</a></h1>
366<p>When you are logged into the VM host platform remotely, e.g. over ssh, it's often far easier and quicker to interact using the command line rather than trying to pull back a graphical desktop and GUI.</p>
367<h2 id="setup"><a href="#setup"><span class="header-section-number">5.1</span> Setup</a></h2>
368<p>You should be able to run virsh as a non-root user (remember, it's always a good idea to run as few commands as root as possible). Under Debian you need to create a config file to make this work.</p>
369<p>When logged in as user &quot;nsrc&quot;, do the following to create a config file <code>.libvirt/libvirt.conf</code> in your home directory, containing one line:</p>
370<pre><code>$ cd
371$ mkdir -p .libvirt     # it may already exist
372$ editor .libvirt/libvirt.conf
373uri_default = &quot;qemu:///system&quot;</code></pre>
374<h2 id="simple-commands"><a href="#simple-commands"><span class="header-section-number">5.2</span> Simple commands</a></h2>
375<p>On the host server (either a terminal window or logged in using ssh), try the following commands:</p>
376<pre><code>$ virsh list
377$ virsh list --all</code></pre>
378<p>The first shows only running VMs, the second shows all defined VMs (including halted ones).</p>
379<p>You can send a shutdown signal like this:</p>
380<pre><code>$ virsh shutdown ubuntu1</code></pre>
381<p>After a few seconds, try <code>virsh list</code> again to see if it has shut down. (If it hasn't - this means <code>acpid</code> is not running inside the guest)</p>
382<p>To restart the VM:</p>
383<pre><code>$ virsh start ubuntu1</code></pre>
384<p>You can find all the parameters of the VM, such as how much memory and CPU cores it has, and what disk images are attached, by looking at the XML:</p>
385<pre><code>$ virsh dumpxml ubuntu1 | less</code></pre>
386<p>See if you can find the path to the disk image file in the XML.</p>
387<p>(Hit space to advance to next page, 'b' to go back, and 'q' to quit)</p>
388<p>The XML files are actually stored under <code>/etc/libvirt/qemu/</code>, but it is safer to manipulate them using the <code>virsh</code> commands, which test the XML file for errors before saving it.</p>
389<h2 id="adding-a-serial-console"><a href="#adding-a-serial-console"><span class="header-section-number">5.3</span> Adding a serial console</a></h2>
390<p>On your host server, try connecting to the serial port of your VM:</p>
391<pre><code>$ virsh console ubuntu1</code></pre>
392<p>Hit Enter a few times and you should find nothing happens. This is because the VM isn't configured to give a login prompt on the serial port. Hit ctrl and <code>]</code> (right-hand square bracket) to exit.</p>
393<p>Firstly, let's check that VM does have an emulated serial port, by editing the XML:</p>
394<pre><code>$ virsh edit ubuntu1</code></pre>
395<p>Scroll down and check that it contains the following 6 lines:</p>
396<pre><code>    &lt;serial type='pty'&gt;
397      &lt;target port='0'/&gt;
398    &lt;/serial&gt;
399    &lt;console type='pty'&gt;
400      &lt;target type='serial' port='0'/&gt;
401    &lt;/console&gt;</code></pre>
402<p>If it does, you can exit the editor without saving. If not, then scroll down until you find the section defining the mouse:</p>
403<pre><code>    &lt;input type='mouse' bus='ps2'/&gt;</code></pre>
404<p>and insert the 6 lines of serial and console XML from above, <em>before</em> this line. Exit the editor, then reboot the virtual machine.</p>
405<p>Now login to the virtual machine itself (using the graphical console as you have been doing so far). Create a file <code>/etc/init/ttyS0.conf</code> (as root) with the following contents:</p>
406<pre><code>start on stopped rc RUNLEVEL=[2345]
407stop on runlevel [!2345]
408
409respawn
410exec /sbin/getty -L 115200 ttyS0 xterm</code></pre>
411<p>Once you have created this, you should be able to check the status of the console getty process and start it like this:</p>
412<pre><code># initctl status ttyS0
413# initctl start ttyS0
414# initctl status ttyS0</code></pre>
415<p>Check that there is now a &quot;getty&quot; process running on ttyS0:</p>
416<pre><code># ps auxwww | grep ttyS0</code></pre>
417<p>Now go back to a command line on the <em>host</em> server. On there, type:</p>
418<pre><code>$ virsh console ubuntu1</code></pre>
419<p>and then hit Enter. You should this time get a login prompt. Congratulations, you are now using the emulated serial port (which doesn't require any GUI to get into). Why use a serial console ? In case you lose network access to your virtual machine, and you cannot easily get access to the graphical desktop of your Host machine (if it is for example in a server room somewhere), then the virtual console will let you access your Linux server.</p>
420<p>Login to test, then hit Ctrl and <code>]</code> (right-hand square bracket) to disconnect from the emulated serial console.</p>
421<h1 id="additional-exercises"><a href="#additional-exercises"><span class="header-section-number">6</span> Additional exercises</a></h1>
422<p>Please feel free to try these if time is available, or use them as reference material.</p>
423<h2 id="vnc-remote-access-to-virt-manager-desktop"><a href="#vnc-remote-access-to-virt-manager-desktop"><span class="header-section-number">6.1</span> VNC remote access to virt-manager desktop</a></h2>
424<p>Unfortunately, virt-manager can only run under Linux. However it is possible to create and access a remote Linux desktop so you can use virt-manager remotely.</p>
425<p>Firstly, install the required packages:</p>
426<pre><code># apt-get install vnc4server ssh-askpass</code></pre>
427<p>(If you have not installed a desktop environment like LXDE, then you should also install a simple window manager like &quot;openbox&quot; or &quot;fluxbox&quot;)</p>
428<p>Now as the &quot;nsrc&quot; user - not as root! - type &quot;vncserver&quot; to start a server.</p>
429<pre><code>nsrc@hostX:~$ vncserver
430
431You will require a password to access your desktops.
432
433Password: &lt;choose a password&gt;
434Verify: &lt;enter the same password&gt;
435
436New 'hostX.ws.nsrc.org:1 (nsrc)' desktop is hostX.ws.nsrc.org:1
437
438Creating default startup script /home/nsrc/.vnc/xstartup
439Starting applications specified in /home/nsrc/.vnc/xstartup
440Log file is /home/nsrc/.vnc/hostX.ws.nsrc.org:1.log</code></pre>
441<p>Note the VNC screen number, in the above example it is :1. (The actual TCP port number is this value plus 5900).</p>
442<p>Now connect using a VNC client on your laptop to <code>&lt;yourhost&gt;:&lt;screen&gt;</code>, which would be <code>hostX:1</code> in the above example. You should be prompted for the password.</p>
443<p>If you just get a blank screen, then you are probably in the 'openbox' window manager. Right-click, select Terminal from the menu, and in the terminal type 'virt-manager'.</p>
444<p>Note that you can disconnect and reconnect from the desktop with VNC, and it will be just as you left it.</p>
445<p>If you want the VNC desktop to have the full LXDE desktop environment, you need to edit a config file, comment out a couple of lines and add a new line.</p>
446<pre><code>$ cd
447$ editor .vnc/xstartup
448...
449#x-terminal-emulator -geometry 80x24+10+10 -ls -title &quot;$VNCDESKTOP Desktop&quot; &amp;
450#x-window-manager &amp;
451x-session-manager &amp;</code></pre>
452<p>Now restart your VNC server:</p>
453<pre><code>$ vncserver -kill :1
454$ vncserver</code></pre>
455<p>and reconnect.</p>
456<p>Note 1: If you reboot your VM server, then you will have to login over ssh and type &quot;vncserver&quot; again to restart the VNC server. However it will remember the password you used before.</p>
457<p>Note 2: This is <em>not</em> the way we recommend to manage Linux systems, for many reasons. However it does give you a usable way to run virt-manager over the network.</p>
458<p>If you had a cluster of machines, you can run virt-manager on one machine, and then use <code>File &gt; Add Connection</code> to get it to communicate with libvirt on other machines. Then only the manager machine needs to have a graphical desktop. <sup><a href="#fn2" class="footnoteRef" id="fnref2">2</a></sup></p>
459<h2 id="libvirt-storage-pools"><a href="#libvirt-storage-pools"><span class="header-section-number">6.2</span> libvirt storage pools</a></h2>
460<p>You can create 'storage pools' to make them available to libvirt. Here is how to set up an LVM pool.</p>
461<pre><code># editor ganeti.xml
462&lt;pool type=&quot;logical&quot;&gt;
463  &lt;name&gt;ganeti&lt;/name&gt;
464  &lt;target&gt;
465    &lt;path&gt;/dev/ganeti&lt;/path&gt;
466  &lt;/target&gt;
467&lt;/pool&gt;
468
469# virsh pool-define ganeti.xml
470# virsh pool-list --all
471# virsh pool-start ganeti
472# virsh pool-autostart ganeti
473# virsh pool-list</code></pre>
474<p>Now you have the option of creating VMs within the &quot;ganeti&quot; pool, which will create logical volumes in that volume group.</p>
475<h2 id="virt-install"><a href="#virt-install"><span class="header-section-number">6.3</span> virt-install</a></h2>
476<p>The virt-install tool allows you to create and start a VM, allocate disk and attach CD image, without having to write XML and without having to use the virt-manager GUI.</p>
477<p>This is very useful if you want to do all your management using virsh CLI.</p>
478<pre><code># apt-get install virtinst
479# virt-install --name foo --ram 256 \
480   --cdrom /var/lib/libvirt/images/ubuntu-12.04.3-server-i386.iso \
481   --disk pool=default,size=4 --network=bridge:br-lan \
482   --noautoconsole --graphics vnc,listen=0.0.0.0,password=xyzzy</code></pre>
483<p>(Use <code>pool=ganeti,size=4</code> if you have set up an LVM storage pool and want to use a logical volume rather than an image file)</p>
484<p>With <code>--noautoconsole</code> it does not attempt to start the <code>virt-viewer</code> X11 application to attach to the console. Instead, you can use a VNC viewer on your laptop to connect to the console.</p>
485<p>To find out which VNC port to connect to, type:</p>
486<pre><code># virsh vncdisplay foo</code></pre>
487<p>This will return something like <code>:0</code> which is the VNC display number. (Add 5900 to get the VNC TCP port number).</p>
488<p>Start your VNC viewer, tell it to connect to <code>hostX.ws.nsrc.org:&lt;N&gt;</code> and you should have a password-protected graphical console onto the VM.</p>
489<h2 id="install-vm-with-qcow2-disk-iamge"><a href="#install-vm-with-qcow2-disk-iamge"><span class="header-section-number">6.4</span> Install VM with QCOW2 disk iamge</a></h2>
490<p>By default, virt-manager creates raw files (sparse or pre-allocated)</p>
491<p>If you want to create a different format, e.g. QCOW2, or create an image in a different storage pool, this is what you do.</p>
492<p>When creating a virtual machine, at step 4 of 5 (&quot;Enable storage for this virtual machine&quot;) click &quot;Select managed or other existing storage&quot;, then &quot;Browse&quot;.</p>
493<p>At this point you can select a storage pool from the left-hand pane and click New Volume. This allows you to choose a name for the volume and its format (e.g. QCOW2) and size. Note that you cannot choose the format if you choose an LVM based storage pool - therefore choose the <code>default</code> pool to create a disk image in QCOW2 format.</p>
494<p>When the volume has been create, select it in the right-hand pane, then click &quot;Choose Volume&quot; to continue with the installation using this volume.</p>
495<h2 id="libvirt-snapshots"><a href="#libvirt-snapshots"><span class="header-section-number">6.5</span> libvirt snapshots</a></h2>
496<p>Snaphots are supported using the qcow2 format; the disk image file contains both the disk snapshots and the CPU/RAM state. You can try them out.</p>
497<p>virt-manager GUI support for snapshots is <a href="https://fedoraproject.org/wiki/Changes/Virt_Manager_Snapshots">planned</a> but for now use the command line:</p>
498<pre><code>virsh snapshot-create &lt;vmname&gt;
499virsh snapshot-list &lt;vmname&gt;
500virsh snapshot-revert &lt;vnmame&gt; &lt;snapshotID&gt;</code></pre>
501<p>You can try creating temporary files in the '/run' directory (which is a RAM disk) and watching how they change back when you revert a snapshot.</p>
502<p>If a machine is shutdown, you can use <code>snapshot-revert</code> to start it immediately at the point where the snapshot was taken.</p>
503<div class="footnotes">
504<hr />
505<ol>
506<li id="fn1"><p>On Ubuntu, The <code>kvm-ok</code> utility, included in the package <code>cpu-checker</code>, will tell you.<a href="#fnref1">↩</a></p></li>
507<li id="fn2"><p>If you're running Linux on your own computer, you could manager libvirt on other servers from your own machine. More on this <a href="http://libvirt.org/uri.html">here</a>.<a href="#fnref2">↩</a></p></li>
508</ol>
509</div>
510</body>
511</html>