{"id":530,"date":"2019-01-02T07:00:33","date_gmt":"2019-01-02T12:00:33","guid":{"rendered":"http:\/\/www.thesmarthomehookup.com\/test_install\/?p=530"},"modified":"2023-02-08T16:39:33","modified_gmt":"2023-02-08T21:39:33","slug":"migrate-your-hass-io-from-a-raspberry-pi-to-a-windows-virtual-machine","status":"publish","type":"post","link":"http:\/\/www.thesmarthomehookup.com\/test_install\/migrate-your-hass-io-from-a-raspberry-pi-to-a-windows-virtual-machine\/","title":{"rendered":"Migrate your Hass.io from a Raspberry Pi to a Windows Virtual Machine"},"content":{"rendered":"<p><iframe width=\"560\" height=\"315\" src=\"https:\/\/www.youtube.com\/embed\/vnie-PJ87Eg\" frameborder=\"0\" allow=\"accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen=\"\"><\/iframe><\/p>\n<p>Today on the hookup I\u2019m going to show you how to migrate your hassio installation from a raspberry pi to a windows virtual machine, and I\u2019ll help you figure out whether it is the right decision for you.<\/p>\n<p>I\u2019ve been running home assistant since October 2017 and so much has changed since I first started.&nbsp; Up until last week I had been running my instance of hass.io on this raspberry pi model 3B, but for a few months I had been questioning whether it\u2019s the best solution.<\/p>\n<p>The raspberry pi is great because it is small, self contained and low power.&nbsp; But in my case I also have an always on computer that runs my plex server, stores all our media files, and handles backups for the rest of the computers in the house.&nbsp; It\u2019s a powerful computer and it basically never reboots and it never turns off, so running hassio on this extra computer is a no brainer.<\/p>\n<p>If you don\u2019t have an always on computer a raspberry pi is a great solution, but if you do I\u2019m going to show you how to migrate your raspberry pi hassio instance to a windows virtual machine relatively painlessly and keep it running reliably.<\/p>\n<p>But before we begin, let me show you some of my favorite parts about running hassio on a virtual machine:&nbsp; Do you hate waiting for your raspberry pi to restart home assistant every time you make a change?&nbsp; Lets time a restart with the virtual machine.<\/p>\n<p>From the time I pressed restart my raspberry pi would take around 2 minutes to come back up, the virtual machine take a fraction of\u2026 oh it\u2019s done already?&nbsp; Nice.<\/p>\n<p>My second favorite thing about running home assistant on a virtual machine is that it completely removes the terror that I feel every time I do an update.&nbsp;&nbsp; With a virtual machine you can easily just clone the hard disk, hit update, and if it breaks everything you can either swap back to the hard drive clone and pretend like it never happened, or you can start fixing everything that broke, but instead of having to block out a chunk of time to make sure you can fix it immediately, you can swap back and forth to your working and not working hard disks whenever it\u2019s convenient for you.<\/p>\n<p>If you end up trying out a virtual machine and you don\u2019t like it, you can easily just plug your raspberry pi back in and you\u2019ll be all set, but I\u2019m guessing you\u2019ll want to stick with the virtual machine.<\/p>\n<p>Here we go.&nbsp; For the initial setup I\u2019m going to follow the instructions put together by Mark M for the DrZzs live stream.&nbsp; I\u2019ve posted a link to Mark\u2019s walkthrough document in the description.<\/p>\n<p><strong>Mark M&#8217;s Document: <a href=\"https:\/\/www.dropbox.com\/s\/kwb9b3ji01leg96\/Installing_HASSOS_on_VirtualBox.pdf?dl=0\">https:\/\/www.dropbox.com\/s\/kwb9b3ji01leg96\/Installing_HASSOS_on_VirtualBox.pdf?dl=0<\/a><\/strong><\/p>\n<p>First we\u2019ll download and install virtual box and the extensions pack for virtual box.&nbsp; Nothing fancy in this step, just get it installed.<\/p>\n<p>While that\u2019s working it\u2019s also a good time to download the VMDK image for hass.io from the home assistant website.&nbsp; For me, this was the first time I switched to HassOS, I had previously been using the original ResinOS version on my raspberry pi, but I didn\u2019t notice any problems switching between the two OS types.<\/p>\n<p>The other thing you\u2019ll need to do is create a full snapshot of your current Hassio instance.&nbsp; Do this in the hassio menu using the snapshots tab, I\u2019m going to call mine \u201cTransfer\u201d. &nbsp;If this is your first time installing hassio, or you want a fresh start you can skip this part.<\/p>\n<p>Once everything is downloaded and installed you need to open virtual box and select \u201cnew\u201d.&nbsp; You\u2019re going to be creating a Linux virtual machine with Ubuntu as the specific distribution, if you have a 64 bit computer, Id suggest using 64 bit Ubuntu.&nbsp; The name is up to you, I\u2019m going to call mine TheHookUpHA, you should avoid spaces in the name of your virtual machine.<\/p>\n<p>On the next screen you can allocate the amount of RAM you want to allow your virtual machine to use.&nbsp; For reference a raspberry pi model 3 has 1 gig of SDRAM.&nbsp; My plex server has 16 gigs of ram, so I\u2019m going to give 2 gigs to this virtual machine.&nbsp; 2 gigs is equal to 2048 megabytes.&nbsp; You can change this value later if you want, so don\u2019t stress about it too much.<\/p>\n<p>Click next and it will ask you about creating a hard disk.&nbsp; For this step you\u2019ll select \u201cuse an existing virtual disk file\u201d and then select the VMDK file that you downloaded earlier and click create.<\/p>\n<p>Click OK, but don\u2019t start the VM yet.&nbsp; Instead click \u201cFile\u201d -&gt; \u201cVirtual Media Manager\u201d, select the VMDK image and click \u201cCopy\u201d.&nbsp; On the pop up box click \u201cnext\u201d then select VDI and click next.&nbsp; On the next screen you can choose between a dynamically allocated file and a fixed size file.&nbsp; Either one is fine, a dynamically allocated file will grow up to a maximum size as you use more space, but a fixed size starts out at the maximum size.&nbsp; I\u2019m going to recommend dynamically allocated since as you saw earlier you\u2019re are going to make copies of this file pretty often whenever you make a major change like an update.<\/p>\n<p>I\u2019m going to call mine \u201cHA_VM\u201d, using underscores instead of spaces, you should avoid spaces in this name also, when you click create nothing is going to happen, that\u2019s fine.&nbsp; Exit the virtual media manager and right click your virtual machine to select settings.&nbsp; Then go to storage and on the SATA controller click the button that says \u201cAdd a hard disk\u201d, then click on \u201cchoose existing disk\u201d and select the vdi file that you just created and click open.&nbsp; You can then right click on the old VMDK file and select \u201cremove attachment\u201d.<\/p>\n<p>Next, under the system tab you\u2019re going to select \u201cEnable EFI\u201d. &nbsp;The system tab is also where you can change the amount of RAM allocated to the machine and under processor you can select how many CPU cores you want to allow your virtual machine to use, mine is running on an i7, so I\u2019m going to give it 2 cores to make it extra snappy.&nbsp; Last, click on Network and select \u201cbridged adapter\u201d and then select the network adapter of the host PC (which is the computer that your virtual machine is installed on).&nbsp; Under advanced click the dropdown menu for promiscuous mode and select \u201callow all\u201d.<\/p>\n<p>Click \u201cOK\u201d then head back over to the virtual media manager one last time to change the size of the disk image.&nbsp; I put mine at 32 gigs, which should give me plenty of space for whatever addons I want to add, I wouldn\u2019t go smaller than 16 gigabytes here, and remember that if you chose a dynamically allocated vdi image it won\u2019t actually use the full size on your hard disk until you fill it up.&nbsp; Exit the media manager and now you\u2019re ready to power up your new virtual machine.<\/p>\n<p>Double click on it and you should see a window pop up with lots of system type messages that aren\u2019t really important for you.&nbsp; When you see the messages \u201cStarting version\u201d and \u201cStarting Eudev\u201d that means your new machine is fully booted and ready to setup.<\/p>\n<p>The next step is the scariest part of this whole thing:<\/p>\n<p>You\u2019ll need to disconnect your old home assistant from your network.&nbsp; Before you pull the power, you need to download the full snapshot that you took of your old HA, do this by going to your home assistant web interface and selecting hassio and then snapshots, select the snapshot that you just took and click the download button, put it somewhere you can find easily on your computer and keep in mind the file name won\u2019t be anything recognizable.<\/p>\n<p>If you have the IP address of your raspberry pi reserved via your router you should delete that reservation before unplugging your raspberry pi, some routers will not let to delete reservations for disconnected devices.<\/p>\n<p>You want your new virtual machine to have the same IP address as our old server you don\u2019t have to reconfigure all of your MQTT devices, So after you\u2019ve freed up that ip address you can pull the plug on the raspberry pi and get your new virtual machine setup with a static ip address.&nbsp; To do this, click on the virtual machine window for your new hassio instance and press enter.&nbsp; It will ask you for a login and the default login will be \u201croot\u201d, press enter and it will give you the hassio ascii art, next you\u2019ll type \u201clogin\u201d to get access to the host system that runs hass.io.<\/p>\n<p>We\u2019re going to use the nmcli tool to set a static IP, so to do that we\u2019ll type \u201cnmcli con edit &#8220;HassOS default&#8221;\u201d, then type \u201cprint ipv4\u201d to see your current configuration.&nbsp; To set a static ip address you\u2019ll type \u201cset ipv4.addresses\u201d followed by the address that you want your virtual machine to have and then \/24.<\/p>\n<p><strong>example: set ipv4.addresses 192.168.1.50\/24<\/strong><\/p>\n<p>It\u2019s also a good idea to set the gateway and DNS servers manually when using a static IP.&nbsp; To do this just type \u201cset ipv4.dns\u201d followed by the address of your router and \u201cset ipv4.gateway\u201d also using the ip address of your router.&nbsp; Then type \u201csave\u201d and \u201cquit\u201d.<\/p>\n<p>Then in virtual box right click your virtual machine, select close, and power off.&nbsp; After that completes, double click on the virtual machine to start it back up.&nbsp; It may be helpful to check your router at this point just to make sure that your virtual machine picked up the right address.&nbsp; Navigate to that IP address port 8123 just as you would with any home assistant installation, then go to hass.io and install the samba addon.&nbsp; If you previously had the samba addon setup in home assistant you should use the same login and password that you did before, otherwise windows will get confused and send the wrong credentials.&nbsp; Click start and then wait for the addon to start up, it should be quick.&nbsp; If you click the refresh button in the logs it will tell you when it is running.<\/p>\n<p>From your computer, access your network share, I usually do this by using the run command typing two backslashes and then the ip address of hassio.&nbsp; Navigate to your backups folder and drag the snapshot file that you downloaded from your raspberry pi to that folder.<\/p>\n<p>Then head back over to the home assistant web interface and click hassio and then snapshots.&nbsp; In the upper right corner click on the refresh button, and your snapshot should show up in the available snapshots UI.<\/p>\n<p>Click on that snapshot and then hit \u201crestore selected\u201d.<\/p>\n<p>Depending on how many addons you had installed this could take anywhere from 1 minute to 20 minutes, but it will probably be closer to one.&nbsp; When home assistant comes back up it should be identical to your old home assistant instance, go ahead and test out the important things, click on some light switches, open up node-red, all that good stuff.<\/p>\n<p>The last thing we need to do is setup your virtual machine as a service so it will automatically start whenever the host PC boots up.&nbsp; This means that your home assistant won\u2019t go down for long if windows decides that your pc needs to reboot.<\/p>\n<p>To do this you\u2019ll download and install the VboxVmService.&nbsp; It automatically chooses the folder c:\/vms, it\u2019s not a big program, so I\u2019d suggest keeping it the default folder so you can just copy and paste the commands we\u2019re going to use without modification.<\/p>\n<p>After the install finishes, navigate to that vms folder and open the VBoxVMService.ini file with notepad or your text editor of choice.&nbsp; Then under the [Vm0] heading type in the exact name of your virtualbox machine where it says \u201cVmName=\u201d, then under shutdown method I suggest using \u201cacpipowerbutton\u201d to make it easier to do a hard reset on your virtual machine if need be.&nbsp; Delete any unused vm definitions and save that file.&nbsp; Then open the command prompt by typing cmd and type in this command \u201cC:vmsVmServiceControl.exe -i\u201d, if you changed the install directory you\u2019ll need to update the command.&nbsp; If you get an error about the specified service existing you can put in this command \u201cC:vmsVmServiceControl.exe -u\u201d followed by the command from before \u201cC:vmsVmServiceControl.exe -i\u201d.&nbsp; Any time you edit the .ini file you\u2019ll need to run those commands to update the service.<\/p>\n<p>These last two steps are totally optional, but I prefer them on my headless server.&nbsp; The first logs into windows automatically on restart, the service will run even from the login screen, but I have other programs that need to be logged in in order to work.&nbsp; To do this just open up the run command and type in netplwiz and unclick the box that says \u201cusers must enter a name and password to use this computer\u201d.<\/p>\n<p>The last optional step is to add the VM service tray icon to be able to easily start and stop your virtual machine. &nbsp;To do this, right click on the VMServiceTray.exe file in the vms folder and select \u201ccopy\u201d, then open the run command and type shell:startup to open your startup folder, and then right click and select paste shortcut, now your vms tray icon will load each time you start windows.<\/p>\n<p>If you run into any problems setting this up you please put it in a comment down below, that way we can get it figured out and others who may have the same problem can benefit from it as well.<\/p>\n<p>Thank you to all my patrons over at patreon for your continued support, if you\u2019re interested in supporting my channel like these wonderful people do, check out the links at the bottom of the description.<\/p>\n<p>I won\u2019t have a new video next week because I\u2019ll be at CES in Las Vegas, follow me on twitter for updates about cool new smart home products that I discover while I\u2019m there.&nbsp; If you\u2019ll be at CES and you want to meet up one day, send me an email or hit me up on twitter.<\/p>\n<p>If you enjoyed this video, please consider subscribing, and as always, thanks for watching the hookup.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today on the hookup I\u2019m going to show you how to migrate your hassio installation from a raspberry pi to a windows virtual machine, and I\u2019ll help you figure out whether it is the right decision for you. I\u2019ve been running home assistant since October 2017 and so much has changed since I first started.&nbsp; [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":2580,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[5],"tags":[],"class_list":["post-530","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials"],"acf":[],"mb":[],"mfb_rest_fields":["title","gutenberg_elementor_mode"],"_links":{"self":[{"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/comments?post=530"}],"version-history":[{"count":4,"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/530\/revisions"}],"predecessor-version":[{"id":2335,"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/posts\/530\/revisions\/2335"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media\/2580"}],"wp:attachment":[{"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/media?parent=530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/categories?post=530"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.thesmarthomehookup.com\/test_install\/wp-json\/wp\/v2\/tags?post=530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}