313 lines
20 KiB
HTML
313 lines
20 KiB
HTML
<!doctype html>
|
||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
|
||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
|
||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
|
||
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||
<title>Set up Hass.io on top of a virtual machine - Home Assistant</title>
|
||
<meta name="author" content="Fabian Affolter">
|
||
<meta name="description" content="A how-to about using Hass.io on x86_64 hardware in a virtualized way.">
|
||
<meta name="viewport" content="width=device-width">
|
||
<link rel="canonical" href="https://home-assistant.io/blog/2017/11/29/hassio-virtual-machine/">
|
||
<meta property="fb:app_id" content="338291289691179">
|
||
<meta property="og:title" content="Set up Hass.io on top of a virtual machine">
|
||
<meta property="og:site_name" content="Home Assistant">
|
||
<meta property="og:url" content="https://home-assistant.io/blog/2017/11/29/hassio-virtual-machine/">
|
||
<meta property="og:type" content="article">
|
||
<meta property="og:description" content="A how-to about using Hass.io on x86_64 hardware in a virtualized way.">
|
||
<meta property="og:image" content="https://home-assistant.io/images/blog/2017-11-hassio-virtual/social.png">
|
||
<meta name="twitter:card" content="summary_large_image">
|
||
<meta name="twitter:site" content="@home_assistant">
|
||
<meta name="twitter:creator" content="@fabaff">
|
||
<meta name="twitter:title" content="Set up Hass.io on top of a virtual machine">
|
||
<meta name="twitter:description" content="A how-to about using Hass.io on x86_64 hardware in a virtualized way.">
|
||
<meta name="twitter:image" content="https://home-assistant.io/images/blog/2017-11-hassio-virtual/social.png">
|
||
<link href="/stylesheets/screen.css" media="screen, projection, print" rel="stylesheet">
|
||
<link href="/atom.xml" rel="alternate" title="Home Assistant" type="application/atom+xml">
|
||
<link rel='shortcut icon' href='/images/favicon.ico' />
|
||
<link rel='icon' type='image/png' href='/images/favicon-192x192.png' sizes='192x192' />
|
||
</head>
|
||
<body >
|
||
<header class='site-header'>
|
||
<div class="grid-wrapper">
|
||
<div class="grid">
|
||
<div class="grid__item three-tenths lap-two-sixths palm-one-whole ha-title">
|
||
<a href="/" class="site-title">
|
||
<img width='40' src='/demo/favicon-192x192.png'>
|
||
<span>Home Assistant</span>
|
||
</a>
|
||
</div>
|
||
<div class="grid__item seven-tenths lap-four-sixths palm-one-whole">
|
||
<nav>
|
||
<input type="checkbox" id="toggle">
|
||
<label for="toggle" class="toggle" data-open="Main Menu" data-close="Close Menu"></label>
|
||
<ul class="menu pull-right">
|
||
<li><a href="/getting-started/">Getting started</a></li>
|
||
<li><a href="/components/">Components</a></li>
|
||
<li><a href="/docs/">Docs</a></li>
|
||
<li><a href="/cookbook/">Examples</a></li>
|
||
<li><a href="/developers/">Developers</a></li>
|
||
<li><a href="/blog/">Blog</a></li>
|
||
<li><a href="/help/">Need help?</a></li>
|
||
<li><a href='#' class='show-search'><i class="icon-search"></i></a></li>
|
||
</ul>
|
||
</nav>
|
||
<div class='search-container' style='display: none'>
|
||
<div class='search'>
|
||
<i class="icon-search"></i>
|
||
<input id='search' placeholder='Search the docs…'>
|
||
<a href='#' class='close'><i class="icon-remove-sign"></i></a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</header>
|
||
<div class="grid-wrapper">
|
||
<div class="grid grid-center">
|
||
<div class="grid__item two-thirds lap-one-whole palm-one-whole">
|
||
<article class="post">
|
||
<header>
|
||
<h1 class="title indent">Set up Hass.io on top of a virtual machine</h1>
|
||
<div class="meta clearfix">
|
||
<time datetime="2017-11-29T06:00:00+00:00" pubdate data-updated="true"><i class="icon-calendar"></i> November 29, 2017</time>
|
||
<span class="byline author vcard"><i class='icon-user'></i> Fabian Affolter</span>
|
||
<span><i class='icon-time'></i> four minutes reading time</span>
|
||
<span>
|
||
<i class="icon-tags"></i>
|
||
<ul class="tags unstyled">
|
||
<li>How-To</li>
|
||
</ul>
|
||
</span>
|
||
<a class='comments'
|
||
href="#post-comments"
|
||
>Comments</a>
|
||
</div>
|
||
</header>
|
||
<p>The images for the Raspberry Pi family and the Intel NUC are an easy way to get started with <a href="/hassio/">Hass.io</a>. For a test or if you have a system which is already hosting virtual machines then the <a href="/hassio/installation/#alternative-install-on-generic-linux-server"><strong>Hass.io installer</strong></a> is an option to use Hass.io in a virtualized environment. In this guide the host is a Fedora 27 system with <a href="https://libvirt.org/">libvirt</a> support and the guest will be running Debian 9. Hass.io will be installed on the guest.</p>
|
||
<a name="read-more"></a>
|
||
<p>Assuming that you already have setup <code class="highlighter-rouge">libvirtd</code>. You might need to install <code class="highlighter-rouge">virt-builder</code> and <code class="highlighter-rouge">virt-viewer</code> additionally.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>sudo dnf -y install libguestfs-tools-c virt-install virt-viewer
|
||
</code></pre>
|
||
</div>
|
||
<p>We will create a virtual machine with Debian 9 and a 10 GB disk image in the QCOW format. Use <code class="highlighter-rouge">$ virt-builder --list</code> to get an overview about what’s operating systems are available if you prefer to use a different system.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>sudo virt-builder debian-9 <span class="se">\</span>
|
||
--output /var/lib/libvirt/images/hassio.img <span class="se">\</span>
|
||
--format qcow2 <span class="se">\</span>
|
||
--size 10G <span class="se">\</span>
|
||
--root-password password:test123 <span class="se">\</span>
|
||
--hostname hassio <span class="se">\</span>
|
||
--firstboot-command <span class="s2">"dpkg-reconfigure openssh-server"</span>
|
||
<span class="o">[</span>...]
|
||
<span class="o">[</span> 147.6] Finishing off
|
||
Output file: /var/lib/libvirt/images/hassio.img
|
||
Output size: 10.0G
|
||
Output format: qcow2
|
||
Total usable space: 9.3G
|
||
Free space: 8.1G <span class="o">(</span>87%<span class="o">)</span>
|
||
</code></pre>
|
||
</div>
|
||
<p>Now, we are making our new virtual machine available for <code class="highlighter-rouge">libvirtd</code>. If you get an error that the OS is unknown, use <code class="highlighter-rouge">$ osinfo-query os</code> to get the name to use with <code class="highlighter-rouge">--os-variant</code>. To access the virtual machine is connected to the bridge <code class="highlighter-rouge">bridge0</code>.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>sudo virt-install --name hassio --import --ram 1024 <span class="se">\</span>
|
||
--os-variant debian9 -w <span class="nv">bridge</span><span class="o">=</span>bridge0 <span class="se">\</span>
|
||
--autostart --disk /var/lib/libvirt/images/hassio.img
|
||
</code></pre>
|
||
</div>
|
||
<p class="img">
|
||
<img src="/images/blog/2017-11-hassio-virtual/virtual-machine-manager.png" />
|
||
Hass.io virtual machine in Virtual Machine Manager
|
||
</p>
|
||
<p>Depending on your preferences you can use the Virtual Machine Manager (<code class="highlighter-rouge">virt-manager</code>) or <code class="highlighter-rouge">virsh</code> to manage the created virtual machine. Log in and create an user with <code class="highlighter-rouge"># useradd ha</code> and set a password with <code class="highlighter-rouge"># passwd ha</code>. We will need that user to make a SSH connection to the virtual machine.</p>
|
||
<p>Log in as <code class="highlighter-rouge">ha</code> with the given password. If your are using the default network of <code class="highlighter-rouge">libvirtd</code> then the DHCP range is defined in <code class="highlighter-rouge">/var/lib/libvirt/dnsmasq/default.conf</code>. In this guide the virtual machine is present at 192.168.0.109.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>ssh ha@192.168.0.109
|
||
ha@192.168.0.109<span class="s1">'s password:
|
||
Linux hassio 4.9.0-3-amd64 #1 SMP Debian 4.9.30-2+deb9u3 (2017-08-06) x86_64
|
||
[...]
|
||
$
|
||
</span></code></pre>
|
||
</div>
|
||
<p>Install the requirements after you switch the user to <code class="highlighter-rouge">root</code>.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">$ </span>su
|
||
Password:
|
||
<span class="gp">root@hassio:/home/ha# </span>
|
||
<span class="gp">root@hassio:/home/ha# </span>apt-get update
|
||
<span class="gp">root@hassio:/home/ha# </span>apt-get install bash socat jq curl avahi-daemon <span class="se">\</span>
|
||
apt-transport-https ca-certificates
|
||
</code></pre>
|
||
</div>
|
||
<p>We want the latest Docker release. This requires additional steps to set it up as unlike other distributions Debian is lacking behind with current packages.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">root@hassio:/home/ha# </span>wget https://download.docker.com/linux/debian/gpg
|
||
<span class="gp">root@hassio:/home/ha# </span>apt-key add gpg
|
||
OK
|
||
<span class="gp">root@hassio:/home/ha# </span><span class="nb">echo</span> <span class="s2">"deb [arch=amd64] https://download.docker.com/linux/debian </span><span class="k">$(</span>lsb_release -cs<span class="k">)</span><span class="s2"> stable"</span> | tee -a /etc/apt/sources.list.d/docker.list
|
||
<span class="gp">root@hassio:/home/ha# </span>apt-get update
|
||
</code></pre>
|
||
</div>
|
||
<p>Now, it’s possible to install a current release of <a href="https://www.docker.com/">Docker</a>.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">root@hassio:/home/ha# </span>apt-get -y install docker-ce
|
||
</code></pre>
|
||
</div>
|
||
<p>Start <code class="highlighter-rouge">docker</code> and enable it.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">root@hassio:/home/ha# </span>systemctl start docker <span class="o">&&</span> systemctl <span class="nb">enable </span>docker
|
||
</code></pre>
|
||
</div>
|
||
<p>An <a href="https://github.com/home-assistant/hassio-build/tree/master/install#install-hassio">installation script</a> will take care about the setup of all moving parts.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">root@hassio:/home/ha# </span>curl -sL https://raw.githubusercontent.com/home-assistant/hassio-build/master/install/hassio_install | bash -
|
||
<span class="o">[</span>INFO] Install supervisor docker
|
||
<span class="o">[</span>INFO] Install generic HostControl
|
||
<span class="o">[</span>INFO] Install startup scripts
|
||
<span class="o">[</span>INFO] Init systemd
|
||
Created symlink /etc/systemd/system/multi-user.target.wants/hassio-supervisor.service → /etc/systemd/system/hassio-supervisor.service.
|
||
<span class="o">[</span>INFO] Start services
|
||
</code></pre>
|
||
</div>
|
||
<p>If it’s done, then there will be two new containers.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">root@hassio:/home/ha# </span>docker ps
|
||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||
ada5bbfc74f0 homeassistant/qemux86-64-homeassistant <span class="s2">"/usr/bin/entry.sh..."</span> 4 minutes ago Up 4 minutes homeassistant
|
||
5954ac452ffc homeassistant/amd64-hassio-supervisor <span class="s2">"/usr/bin/entry.sh..."</span> 7 minutes ago Up 7 minutes hassio_supervisor
|
||
</code></pre>
|
||
</div>
|
||
<p>After a connection to the container which is containing Home Assistant is made, you will see the log output.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">root@hassio:/home/ha# </span>docker attach --sig-proxy<span class="o">=</span><span class="nb">false </span>ada5bbfc74f0
|
||
2017-11-28 19:24:30 INFO <span class="o">(</span>MainThread<span class="o">)</span> <span class="o">[</span>homeassistant.core] Bus:Handling <Event state_changed[L]: <span class="nv">entity_id</span><span class="o">=</span>sun.sun, <span class="nv">old_state</span><span class="o">=</span><state sun.sun<span class="o">=</span>below_horizon; <span class="nv">next_dawn</span><span class="o">=</span>2017-11-29T06:17:58+00:00,...
|
||
</code></pre>
|
||
</div>
|
||
<p>For further details about the container, <code class="highlighter-rouge">inspect</code> can help.</p>
|
||
<div class="language-bash highlighter-rouge"><pre class="highlight"><code><span class="gp">root@hassio:/home/ha# </span>docker inspect bb32b525d1ad
|
||
<span class="o">[</span>...]
|
||
<span class="s2">"OnBuild"</span>: null,
|
||
<span class="s2">"Labels"</span>: <span class="o">{</span>
|
||
<span class="s2">"io.hass.arch"</span>: <span class="s2">"amd64"</span>,
|
||
<span class="s2">"io.hass.machine"</span>: <span class="s2">"qemux86-64"</span>,
|
||
<span class="s2">"io.hass.type"</span>: <span class="s2">"homeassistant"</span>,
|
||
<span class="s2">"io.hass.version"</span>: <span class="s2">"0.58.1"</span>
|
||
<span class="o">}</span>
|
||
<span class="o">[</span>...]
|
||
</code></pre>
|
||
</div>
|
||
<p>Hass.io is now ready. The frontend is available at <a href="http://192.168.0.109:8123">http://192.168.0.109:8123</a>. Yes, the IP address is the one of the guest.</p>
|
||
<p class="img">
|
||
<img src="/images/blog/2017-11-hassio-virtual/hassio.png" />
|
||
Hass.io overview
|
||
</p>
|
||
<p>Keep in mind that there are limitations with this approach. Not all <a href="/addons/">add-ons</a> will work and some don’t make sense to use as the hardware is not present. E.g., use the <a href="https://github.com/hassio-addons/addon-ssh">SSH community add-on</a> instead of the default <a href="/addons/ssh/">SSH add-on</a>.</p>
|
||
</article>
|
||
<div id='post-comments'></div>
|
||
<div id='discourse-comments'></div>
|
||
<script type="text/javascript">
|
||
DiscourseEmbed = { discourseUrl: 'https://community.home-assistant.io/',
|
||
discourseEmbedUrl: 'https://home-assistant.io/blog/2017/11/29/hassio-virtual-machine/' };
|
||
(function() {
|
||
var d = document.createElement('script'); d.type = 'text/javascript'; d.async = true;
|
||
d.src = DiscourseEmbed.discourseUrl + 'javascripts/embed.js';
|
||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(d);
|
||
})();
|
||
</script>
|
||
</div>
|
||
<aside id="sidebar" class="grid__item one-third lap-one-whole palm-one-whole">
|
||
<div class="grid">
|
||
<section class="aside-module grid__item one-whole lap-one-half">
|
||
<h1 class="title delta">About Home Assistant</h1>
|
||
<ul class="divided">
|
||
<li>
|
||
Home Assistant is an open-source home automation platform running on Python 3. Track and control all devices at home and automate control.
|
||
</li>
|
||
<li><a href='/getting-started/'>Get started with Home Assistant</a></li>
|
||
<li><a href='/demo/'>Try the online demo</a></li>
|
||
<li><a class="twitter-follow-button" href="https://twitter.com/Home_Assistant">Follow Home Assistant on Twitter</a></li>
|
||
<li><div class="fb-like" data-href="https://www.facebook.com/homeassistantio/" data-layout="standard" data-action="like" data-size="small" data-show-faces="true" data-share="false"></div></li>
|
||
</ul>
|
||
</section>
|
||
<div id="fb-root"></div>
|
||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.async=true;js.src='//platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||
<script>(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(d.getElementById(id)){return;}js=d.createElement(s);js.id=id;js.async=true;js.src="//connect.facebook.net/en_US/all.js#appId=338291289691179&xfbml=1";fjs.parentNode.insertBefore(js,fjs);}(document,'script','facebook-jssdk'));</script>
|
||
<section class="sharing aside-module grid__item one-whole lap-one-half">
|
||
<h1 class="title delta">Share this post</h1>
|
||
<a href="//twitter.com/share"
|
||
class="twitter-share-button"
|
||
data-via="home_assistant"
|
||
data-related="home_assistant"
|
||
data-url="https://home-assistant.io/blog/2017/11/29/hassio-virtual-machine/"
|
||
data-counturl="https://home-assistant.io/blog/2017/11/29/hassio-virtual-machine/" >Tweet</a>
|
||
<div class="fb-share-button" style='top: -6px;'
|
||
data-href="https://home-assistant.io/blog/2017/11/29/hassio-virtual-machine/"
|
||
data-layout="button_count">
|
||
</div>
|
||
<div class="g-plusone" data-size="standard"></div>
|
||
</section>
|
||
<script src="https://apis.google.com/js/platform.js" async defer></script>
|
||
<section id="recent-posts" class="aside-module grid__item one-whole lap-one-half">
|
||
<h1 class="title delta">Recent Posts</h1>
|
||
<ul class="divided">
|
||
<li class="post">
|
||
<a href="/blog/2018/03/09/release-65/">0.65: Rename entities, new filter sensor, UpCloud and Channels</a>
|
||
</li>
|
||
<li class="post">
|
||
<a href="/blog/2018/02/26/release-64/">0.64: Over 1000 integrations! New: HomeKit, BMW, August.</a>
|
||
</li>
|
||
<li class="post">
|
||
<a href="/blog/2018/02/19/cloud-update/">Cloud Update</a>
|
||
</li>
|
||
<li class="post">
|
||
<a href="/blog/2018/02/10/release-63/">0.63: Entity Registry, SQL Sensor, Mercedes cars</a>
|
||
</li>
|
||
<li class="post">
|
||
<a href="/blog/2018/02/09/disabling-disqus/">Disabling Disqus comments</a>
|
||
</li>
|
||
</ul>
|
||
</section>
|
||
</div>
|
||
</aside>
|
||
</div>
|
||
</div>
|
||
<footer>
|
||
<div class="grid-wrapper">
|
||
<div class="grid">
|
||
<div class="grid__item">
|
||
<div class="copyright">
|
||
<a rel="me" href='https://twitter.com/home_assistant'><i class="icon-twitter"></i></a>
|
||
<a rel="me" href='https://facebook.com/homeassistantio'><i class="icon-facebook"></i></a>
|
||
<a rel="me" href='https://plus.google.com/110560654828510104551'><i class="icon-google-plus"></i></a>
|
||
<a rel="me" href='https://github.com/home-assistant/home-assistant'><i class="icon-github"></i></a>
|
||
<div class="credit">
|
||
Contact us at <a href='mailto:hello@home-assistant.io'>hello@home-assistant.io</a> (no support!).<br>
|
||
Website powered by <a href='http://jekyllrb.com/'>Jekyll</a> and the <a href='https://github.com/coogie/oscailte'>Oscalite theme</a>.<br />
|
||
Hosted by <a href='https://pages.github.com/'>GitHub</a> and served by <a href='https://cloudflare.com'>CloudFlare</a>.
|
||
</div>
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/"><img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png" /></a><br /><span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">home-assistant.io</span> is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/4.0/">Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License</a>.
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</footer>
|
||
<script>
|
||
var _gaq=[['_setAccount','UA-57927901-1'],['_trackPageview']];
|
||
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
||
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
||
s.parentNode.insertBefore(g,s)}(document,'script'));
|
||
</script>
|
||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css" />
|
||
<script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script>
|
||
<script type="text/javascript">
|
||
docsearch({
|
||
apiKey: 'ae96d94b201c5444c8a443093edf3efb',
|
||
indexName: 'home-assistant',
|
||
inputSelector: '#search',
|
||
debug: false // Set debug to true if you want to inspect the dropdown
|
||
});
|
||
document.querySelector('.search .close').addEventListener('click', function(ev) {
|
||
ev.preventDefault();
|
||
document.querySelector('.search-container').style.display = 'none';
|
||
});
|
||
document.querySelector('.show-search').addEventListener('click', function(ev) {
|
||
ev.preventDefault();
|
||
document.querySelector('.search-container').style.display = 'block';
|
||
document.getElementById('toggle').checked = false;
|
||
document.querySelector('.search-container input').focus();
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|