Inspired by Linode’s documentation of the general case of installing a custom Linux distribution on a remote machine that can’t boot from an arbitrary ISO image.

You’ll need:

  • a staging machine: either a physical box that can boot from a VyOS live CD or a virtual machine that can boot from an ISO image of one;

  • a target machine on which you ultimately want to run VyOS;

  • a disk of at least 1 GB (2 GB recommended) on each machine;

  • console access to both machines;

  • the ability to establish a network connection between them; and

  • the ability to boot the target machine from a rescue CD, such as Finnix.


  1. Boot the staging machine from the VyOS live CD. (Don’t take the shortcut of using VyOS’s OVA template.)

  2. Install VyOS:

     vyos@vyos:~$ install system
    
  3. Boot the remote machine from the Finnix live CD.

  4. Create /dev/xvda1 (or equivalent) to match the staging machine’s /dev/sda1 (or equivalent):

     root@hvc0:~# parted /dev/xvda mklabel msdos
     root@hvc0:~# parted /dev/xvda mkpart primary "0%" "100%"
     root@hvc0:~# parted /dev/xvda set 1 boot on
    
  5. Confirm your changes:

     root@hvc0:~# parted /dev/xvda print
    
  6. Give the new partition a filesystem:

     root@hvc0:~# mkfs.ext4 /dev/xvda1
    
  7. Mount it:

     root@hvc0:~# mount /dev/xvda1 /mnt
    
  8. Enable SSH:

     root@hvc0:~# passwd
     root@hvc0:~# vi /etc/ssh/sshd_config
     # Type: :%s/^PermitRootLogin without-password/PermitRootLogin yes/g<Enter>
     root@hvc0:~# service ssh start
    
  9. On the staging machine, copy the root filesystem to the target machine’s new partition (substituting the latter’s IP address, of course):

     vyos@vyos:~$ sudo -i
     root@vyos:~# mount /dev/sda1 /mnt/rootfs
     root@vyos:~# rsync -ahz --stats /mnt/rootfs/ root@192.0.2.253:/mnt/
    
  10. On the target machine, update the filesystem table:

    root@hvc0:~# blkid
    root@hvc0:~# vi /mnt/etc/fstab
    # Replace given UUID with that returned for /dev/xvda1.
    
  11. Follow Finnix’s instructions for reconfiguring GRUB:

    root@hvc0:~# mount -t proc none /mnt/proc
    root@hvc0:~# mount -t sysfs none /mnt/sys
    root@hvc0:~# mount --bind /dev /mnt/dev
    root@hvc0:~# chroot /mnt
    root@finnix:/# cat /proc/mounts > /etc/mtab
    root@finnix:/# vi /etc/mtab
    # Remove all lines before "/dev/xvda1".
    root@finnix:/# /opt/vyatta/sbin/vyatta-grub-setup xvda1
    root@finnix:/# grub-install /dev/xvda
    
  12. Back out:

    root@finnix:/# exit
    root@hvc0:~# umount /mnt/dev
    root@hvc0:~# umount /mnt/sys
    root@hvc0:~# umount /mnt/proc
    root@hvc0:~# umount /mnt
    
  13. Reboot the target machine. Depending on your console, you may not see the usual GRUB menu, but if you type <Enter> you should see the VyOS login prompt:

    Welcome to VyOS - vyos ttyS0
    
    vyos login: