Instantly share code, notes, and snippets.

Embed
What would you like to do?
Installing RancherOS on FreeNAS using iohyve

RancherOS on FreeNAS

Date: 2016-10-04 Version: 1.2
Author: s1lvester@bockhacker.me

This is my short documentation on how to install RancherOS on FreeNAS.

Versions used:
- RancherOS v.0.6.1
- FreeNAS 9.10-stable
- iohyve v0.7.5 2016/04/14

Setup iohyve

Gav wrote a comprehensive blog-post about this. Find it here: Gav's Tech Blog

Preparing bhyve (iohyve) guest

We're going to differ from Gav's tutorial right bevore he installs Ubuntu. So we're going to instead download RancherOS:

[root@freenas ~]$ iohyve fetch https://releases.rancher.com/os/latest/rancheros.iso
[root@freenas ~]$ iohyve renameiso rancheros.iso rancheros-v0.6.1.iso
[root@freenas ~]$ iohyve isolist

The last command is only to make sure we did everything right. So now we create and setup the guest:

[root@freenas ~]$ iohyve create rancheros 100G
[root@freenas ~]$  iohyve set rancheros loader=grub-bhyve ram=8G cpu=1 con=nmdm0 os=debian
[root@freenas ~]$ iohyve list

I'm not really sure if we're going to need os=debian or if other parameters work better. That's just what I used first and it worked. Obviously you should modify the parameters to your liking.

Installing RancherOS

[root@freenas ~]$ iohyve install rancheros rancheros-v0.6.1.iso

RancherOS doesn't boot on its own, so we need to do this manually via grub-console. Attaching to the console should be done in a seperate ssh-session.

[user@freenas ~]$ sudo iohyve console rancheros

# press ENTER, you should see the grub-prompt
grub> set root=(cd0,msdos1)
grub> linux /boot/vmlinuz ro
grub> initrd /boot/initrd
grub> boot

This should get you to the login-prompt of RancherOS (login: rancher). No password is needed for login or sudo. Next we'll need to create the cloud-config.yml file to store our ssh-keys. Now see references from the RancherOS docs: here and here too

[rancher@rancher ~]$ vi cloud-config.yml

-----

# cloud-config.yml

ssh_authorized_keys:
- <your pubkey here>

CAVE: Don't forget the leading dash before your pubkey!

[rancher@rancher ~]$ sudo ros install -c cloud-config.yml -d /dev/sda

The reboot doesn't actually happen. Now quit the console via ~~. .

Finally start RancherOS via iohyve start rancheros and try to ssh into the machine using ssh rancher@rancher. If wanted/needed you can enable RancherOS to auto-start at boottime via iohyve set rancheros boot=1 . From here on continue your adventures.

@seed1234

This comment has been minimized.

seed1234 commented Apr 22, 2017

When i Run

grub> set root=(cd0,msdos1)
grub> linux /boot/vmlinuz ro
error: file `/boot/vmlinuz' not found.
grub>

could you help

@itavero

This comment has been minimized.

itavero commented May 5, 2017

@seed1234 Use the Tab after typing the /boot/ paths to autofill the correct paths. For me it was /boot/vmlinuz-4.9.24-rancher and /boot/initrd-v1.0.1 (using RancherOS v1.0.1 ISO).

Note that I also needed to supply an option to set the password of the rancher user:

grub> set root=(cd0,msdos1)
grub> linux /boot/vmlinuz-4.9.24-rancher ro rancher.password=rancher
grub> initrd /boot/initrd-v1.0.1 
grub> boot
@famewolf

This comment has been minimized.

famewolf commented Aug 29, 2017

The latest version of rancher os is now 1.0.4. When I try to follow your instructions:

  1. The fetch fails.
    famewolf@freenas:/mnt/volume1/iohyve/ISO % sudo iohyve fetch https://releases.rancher.com/os/latest/rancheros.iso
    Fetching https://releases.rancher.com/os/latest/rancheros.iso...
    cannot create 'volume1/iohyve/ISO/rancheros.iso': dataset already exists
    fetch: https://releases.rancher.com/os/latest/rancheros.iso: Authentication error

So as a workaround I downloaded the iso manually and did a sudo iohyve install rancheros ./rancheros.iso which appeared to work.

When at the grub menu and typing "set root=cd0,msdos1" it returns me to the grub command line however when I try to add the next line it tells me that cd0 does not exist. See following:

famewolf@freenas:~ % sudo iohyve create rancheros 100G
Creating rancheros...
famewolf@freenas:~ % sudo iohyve set rancheros loader=grub-bhyve ram=8G cpu=1 con=nmdm0 os=debian
Setting rancheros loader=grub-bhyve...
Setting rancheros ram=8G...
Setting rancheros cpu=1...
Setting rancheros con=nmdm0...
Setting rancheros os=debian...
famewolf@freenas:~ % iohyve list
Guest VMM? Running rcboot? Description
debvm NO NO NO Mon Feb 27 23:43:28 EST 2017
rancheros YES NO NO Tue Aug 29 14:31:35 EDT 2017
ubu1604 NO NO NO Wed Mar 1 00:10:57 EST 2017
famewolf@freenas:~ % sudo iohyve install rancheros ./rancheros-v1.0.4.iso
Installing rancheros...
GRUB Process does not run in background....
If your terminal appears to be hanging, check iohyve console rancheros in second terminal to complete GRUB process...
/usr/local/sbin/iohyve: cannot create /iohyve/rancheros/device.map: No such file or directory
/usr/local/sbin/iohyve: cannot create /iohyve/rancheros/device.map: No such file or directory

moving to 2nd window
famewolf@freenas:~ % sudo iohyve console rancheros
Password:
Starting console on rancheros...
~~. to escape console [uses cu(1) for console]
Connected

grub> set root=(cd0,msdos1)
grub> [Aisk cd0,msdos1' not found. grub> grub> linux /boot/vmlinuz ro error: disk cd0,msdos1' not found.
grub>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment