Install RancherOs on FreeNas 11.3

  • The automated RancherOs installation aka Docker VM has been removed in
  • RancherOs doesn’t support EFI boot out of the box
  • Thanks to MKinney howto
  • This howto is provided without warranty
  • TODO the proper way of doing it is somewhere here
  • Some stuff about losetup

1. Make a EFI bootable RancherOs image

  1. wget
  2. wget
  3. mkdir tmpubuntu tmprancheros tmprancheros_dest
  4. sudo mount ubuntuserverlive.iso tmpubuntu
  5. sudo mount rancheros.iso tmprancheros
  6. fallocate -l 150M rancheros.img
  7. gdisk rancheros.img o,y,n,enter,enter,ef00,w,Y
  8. sudo losetup --partscan --show --find rancheros.img
  9. sudo mkfs.fat /dev/loop2p1
  10. sudo mount /dev/loop2p1 rancheros_dest
  11. sudo cp -r tmprancheros/* tmprancheros_dest/
  12. sudo cp -r tmpubuntu/EFI tmprancheros_dest/
  13. Replace the content of tmprancheros_dest/boot/grub/grub.cfg with:
set timeout=5
menuentry "Install Rancher" {
    linux   /boot/vmlinuz-4.14.138-rancher rancher.autologin=tty1 rancher.autologin=ttyS0 rancher.autologin=ttyS1 console=tty1 console=ttyS0 console=ttyS1 printk.devkmsg=on panic=10 ---
    initrd  /boot/initrd-v1.5.5
  1. sudo umount tmprancheros_dest
  2. sudo losetup -d /dev/loop2
  3. sudo umount tmpubuntu tmprancheros

2. Installation in FreeNas as Vm

  1. Create a VM with EFI boot 2GB RAM choose virtio for all the driver
    better performance with linux
  2. Add a RAW device and select your rancheros.img
  3. Start the VM
  4. Go to serial and in the shell cu -l /dev/nmdmXX at this point you should
    have a rancher shell
  5. sudo fdisk /dev/vda then g,n,1,+200M,t,1,n,enter,enter,w you
    should something like at the end
Disk /dev/vda: 10 GiB, 10737418240 bytes, 20971520 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 16384 bytes
I/O size (minimum/optimal): 16384 bytes / 16384 bytes
Disklabel type: gpt
Disk identifier: 2B56EE14-44BF-6443-A197-EF73723B715F
Device      Start      End  Sectors  Size Type
/dev/vda1    2048   411647   409600  200M EFI System
/dev/vda2  411648 20971486 20559839  9.8G Linux filesystem
  1. Format the boot partition sudo mkdosfs -n RANCHER -F 32 /dev/vda1
  2. Format the main filesystem sudo mkfs.ext4 -L RANCHER_STATE /dev/vda2
  3. Create a cloud-config.yml see for minimum content
  4. sudo mkdir /dev/sr0 for installer checking about iso mounted before
  5. Install ros with sudo ros install -t gptsyslinux -c cloud-config.yml -d /dev/vda -p /dev/vda2
  6. mkdir /mnt/efipart && sudo mount /dev/vda1 /mnt/efipart
  7. mkdir /mnt/installer && sudo mount /dev/vdb1 /mnt/installer
  8. sudo cp -r /mnt/installer/EFI /mnt/efipart
  9. Add a grub.cfg in /mnt/efipart/EFI/BOOT/grub.cfg with in it:
    You might want to add/remove autologin as you wish below
    • tty0 I think is VNC but I havent tested it
    • ttyS0 is serial (I have autologin enable in serial see below)
set timeout=1
menuentry "Rancher from GPT" {
    search --no-floppy --set=root --label RANCHER_STATE
    linux    /boot/vmlinuz-4.14.138-rancher printk.devkmsg=on rancher.state.wait panic=10 console=tty0 console=ttyS0 rancher.autologin=ttyS0
    initrd    /boot/initrd-v1.5.5
  1. sudo umount /mnt/*
  2. sudo reboot
  3. You are good to go
  4. You can remove the RAW device in the VM config in FreeNas

13 commentaires

Rudi Pittman · 18 mars 2020 à 17 h 46 min

Can I or can I not use my existing rancher img that was previously being used by freenas? ie

-rw-r–r– 1 root wheel 21474836480 Mar 18 02:13 rancher.img_docker1

I have around 10 different docker containers defined inside and I really don’t want to have to redo all of them.

    HugoPoi · 11 avril 2020 à 16 h 32 min

    If the image is a VM image like a zvol, I think it will work, but I’m not sure, it will only work if the 11.2 behavior is EFI compatible.
    You may patch your existing image/snapshot by justing installing the efi bootloader aka grub in it.

Rob RD · 4 avril 2020 à 19 h 36 min

Parfait – Merci Beaucoup! :)

dario · 12 avril 2020 à 14 h 07 min

Thanks for this guide. I am stuck at Step 12:
> sudo mount /dev/vdb1 /mnt/installer
ther is no /dev/vdb1, regardingless if I choose to boot at step 10 or not

    HugoPoi · 22 avril 2020 à 23 h 34 min

    Your installer may be on a different disk if you choose SCSI in place of virtio when you add the raw image device in Freenas, you can identified with

    cat /proc/partitions



    it should be /dev/sda1 maybe

somebody · 19 avril 2020 à 13 h 07 min

Thank you so much for the step by step guide, it was very helpful. With this I can finally transition from my old Docker VM inherited from FreeNAS 11.1.

Going to state the obvious (for some) and mention that when new version gets released and you run

sudo ros os upgrade

to upgrade you’ll also need to update initrd command in your grub.cfg file on EFI partition, otherwise you’re just going to boot into the same version.

    Rudi Pittman · 1 juin 2020 à 1 h 58 min

    The problem I have is even though grub is specifying 4.14.138 and initird-v1.5.5 on reboot it tells me those don’t exist. Doing a grub edit and using autocomplete the files it ACTUALLY find are /boot/vmlinuz-4.14.73-rancher and /boot/initrd-v1.4.2. Where the heck are those coming from? When I look on /dev/vda2/boot I see the 4.14.138 and initrd-v1.5.5 as the grub reflects. /mnt/efipart/EFI/BOOT has:

    -rwxr-xr-x 1 root root 1334816 May 30 15:13 BOOTx64.EFI
    -rwxr-xr-x 1 root root 316 May 30 15:15 grub.cfg
    -rwxr-xr-x 1 root root 1146744 May 30 15:13 grubx64.efi

Max · 3 mai 2020 à 16 h 40 min

The image i downloaded does not start. Stuck at step4 in the bhyve shell. Any idea how to proceed from there?

    HugoPoi · 10 mai 2020 à 14 h 53 min

    Try to change the device order to a lower or higher number to be sure it try to load the good bootloader.

Rudi Pittman · 1 juin 2020 à 18 h 28 min

If you do a « ros os version » on your efi image it’s NOT v1.5.5. It’s v1.4.2 and running the command although it MAY download the files does nothing to actually make the grub.cfg FIND those new files. It’s still looking for vmlinuz-4.14.73 and initrd-v1.4.2.

    Johnny Z · 25 juin 2020 à 8 h 49 min

    I found them. The guide doesn’t necessarily state where or when to get the files. You should be able to do this to find and copy the files

    cd /mnt/installer/boot/
    ls -asl
    (here you will find the two files)
    cp vmlinuz-4.14.138-rancher ../../efipart/efi/boot/
    cp initrd-v1.5.5.5 ../../efipart/efi/boot

    Double check my paths here but that should basically get you the files so the kernel can load proper

Toohai · 16 septembre 2020 à 8 h 18 min

Missing step after 12 in part 1?

sudo cp -r tmpubuntu/boot/grub tmprancheros_dest/boot/

pstadler · 18 avril 2021 à 20 h 52 min

As the image is no longer available for download, I decided to share mine. It uses RancherOS v1.5.6 and this needs a slightly different grub.cfg (make sure to copy it from the README) everything else remains the same.


Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *