2

I ordered a VPS with Debian 9 stretch from OVH, but they don't support FreeBSD, so they told me to use KVM, to install FreeBSD, but for some reason I'm failing at mounting the iso file.

I don't know what steps should I take to install an iso file containing FreeBSD.

Already called them to get more informations, but the guy who accepted the call told me to do it by myself, that he can help me with this, as there is no official "recipe" to do it, but he knows that lots of their users do it.

strangereu
  • 21
  • 1
  • 2
  • What command do you use to create VM? – Egor Vasilyev Dec 13 '17 at 10:48
  • I only did this, because I don't know how to continue `wget https://download.freebsd.org/ftp/snapshots/amd64/amd64/ISO-IMAGES/11.1/FreeBSD-11.1-STABLE-amd64-20171109-r325551-disc1.iso mkdir -p /mnt/iso mount -o loop mini.iso /mnt/iso` – strangereu Dec 13 '17 at 10:58
  • Did you VPS provider say that you need to create virtual machine and install freebsd manually? If yes, then try to read kvm manual and create VM using virt-install with `--cdrom /path/to/iso` mandatory option. – Egor Vasilyev Dec 13 '17 at 11:15
  • Nope. They only told me to use KVM, but didn't specify how. Anyway --cdrom doesnt work "-bash: --cdrom: command not found" – strangereu Dec 13 '17 at 11:30
  • You need to read manual about KVM and how to install it and create virtual machine. Then you need to buy additional external ip to use it with freebsd VM. See article https://www.cyberciti.biz/faq/kvm-virt-install-install-freebsd-centos-guest/ – Egor Vasilyev Dec 13 '17 at 11:41
  • KVM is a hypervisor that allows you possibillity of virtual machine creation with any operating systems (e.s. freebsd or Ubuntu or Windows or something else). – Egor Vasilyev Dec 13 '17 at 11:44
  • Tried what you said, but I think it didn't work... It might be because I'm doing it for the first time... This is what it did https://pastebin.com/aLvczZtd – strangereu Dec 13 '17 at 11:55
  • Let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/70156/discussion-between-strangereu-and-egor-vasilyev). – strangereu Dec 13 '17 at 11:58
  • there are a couple of howtos on the internet how to get FreeBSD onto an OVH VPS, e.g. http://tim.thechases.com/posts/installing-freebsd-on-ovh/ – arved Jan 12 '18 at 09:55

2 Answers2

4

This is a "fun" chicken and egg problem for a beginner. There are many roads to accomplish what you want but you need to have an incredible good understanding of all the elements to choose the one which will be most easy for you.

Beware that you may kill your server with some of the steps below - but luckily it is very easy to get back to square one with a quick reinstall.

Debian 9

The VPS is now running Debian 9. Which is fine if that is what you want. But from what you have been doing with virt-install it looks like you try to use the Debian 9 to act as hypervisor/host for a FreeBSD Guest. If that is what you want - all is good. You might have a look at the ready made FreeBSD VM images for the purpose.

But from your question is sounds like you want to only run only FreeBSD on the host. Then I would choose another path. Getting familiar with this path will give the added benefit of learning some really nice tricks for recovery when things go really bad.

Changing shoes

Replacing an operating system with another operating system on a running server is akin to two people switching shoes while wearing them. It can be done but it is rarely worth the trouble. Your current Debian 9 is currently most probably using all of the disk space. Then you would need to resize partitions, add a boot selector etc. etc.

If you do not want to dual boot into Debian 9 the much easier route is to replace what you have on disk. For this we need to boot the VPS into an operating system in memory and not using the disk.

mfsBSD

If you are able to boot via the KVM it will be fine to use either the CD ISO or the DVD ISO files which are pretty complete.

But as we are doing all of this over the network we might as well boot a minimal image and let the installer fetch the packages via the network.

There is a "minimal" official FreeBSD iso named bootonly but it weighs in at 298 MB.

What people are commonly using is mfsBSD as the regular version weighs in at 57 MB and there is even a mini version at 23 MB. It is a slim live (in memory) version of FreeBSD which is perfect for installing or rescue operations. Good hosting provides often offer this as a PXE boot option even if they do not officially support FreeBSD.

I have found mfsBSD invaluable getting FreeBSD installed on many remote systems over the years. This is an important tool to know of and it is used in the rather involved example in the FreeBSD Handbook

Booting

There are 3 typical ways to boot a system:

  • CD
  • PXE (network boot)
  • HDD

Right now you are booting the VPS from your virtual hard disk drive (HDD) into Debian 9. If you want to install the entire VPS into FreeBSD then we need to write a FreeBSD filesystem and tranfer it onto the disk. The most easy route is to do this using the FreeBSD installer and this requires us booting into a live FreeBSD at first.

CD

The easiest way to do this is "inserting" a boot CD. Physical CD's are not that common anymore but they live on in the form of ISO images. You should not try to mount the ISO image from within Debian 9 as this will not help you boot into FreeBSD. Instead you should look around in the KVM interface which would be via http/web interface at OVH. If they allow you to attach an ISO file then the VPS would boot into this when restarted. When doing it like this it will look like a proper CD drive to the system when booting.

This is what I would expect if someone tells me to install something via KVM.

You tell precious little about your VPS. As far as I know OVH is using OpenStack but I do not know their interface/limitations.

If you are not able to follow the easy route of booting into an iso image - then we need to go the intermediate route using a network boot.

PXE (network boot)

Network booting a server requires some control over the network environment. I know that OVH previously have had a netboot option which allowed you to fetch an ISO file during the network boot phase. This may or may not be available to you.

Even if it is not available I know that OVH offers booting into rescue mode. Their online documentation is extremely sparse so we do not know what actually happens.

What likely will happen is that the server will do a PXE boot into a memory bound live system without touching the HDD. With many other providers I would expect to be presented with a number of different rescue images. Some even offer to boot into mfsBSD at this stage. If you are not presented with a list I would expect them to boot into "some" Linux based system.

If you cannot PXE or netboot directly into mfsBSD then all is not lost if we can get to some Linux live rescue solution which is not bound to the HDD. We just have to go one step further into a little more advanced territory

HDD

If we somehow have managed to boot into another system which is not bound to the HDD then we can use that system to write mfsBSD directly to disk. We do not care what kind of rescue system we are using as long as they have wget or curl and dd. If not then you need whatever tools are available to fetch the image and write it to disk.

For now we assume that you have booted into a generic Linux rescue system in memory. From the command line we can then fetch a mfsBSD disk image (not iso image!) and write it directly to the disk.

WARNING: At this point you are overwriting whatever you have on your system disk!!!

If you have wget then:

wget -qO- http://mfsbsd.vx.sk/files/images/11/mfsbsd-11.1-RELEASE-amd64.img | dd of=/dev/sda bs=1m

Or with curl you can use:

curl -s http://mfsbsd.vx.sk/files/images/11/mfsbsd-11.1-RELEASE-amd64.img | dd of=/dev/sda bs=1m

Make sure that you are using the correct device name - but most often it is /dev/sda

Caveat emptor: When using the default mfsBSD image you will get the IP via DHCP and use the default password. You have a risk of getting 0wned with the default password. To avoid the default you could build your own image but this is far outside the scope of this "short" answer. See the FreeBSD Handbook

When the image have been written to disk then the server (VPS) is ready to be booted into mfsBSD. You can access it either via the KVM or via ssh.

mfsBSD is running in memory - and now we have the option to install FreeBSD properly to the disk. We can do this because mfsBSD is completely bound to memory and do not care that we overwrite the disk we booted from. You start the installer by typing:

bsdinstall

So even in this roundabout way we are able to run the native installer as long as we can boot into a live Linux.

Claus Andersen
  • 3,239
  • 1
  • 12
  • 24
  • 1
    Thank you, very nice answer, it should be accepted as official answer. I also appreciated reasons why using mfsBSD instead of regular Live DVD install. – gsl Mar 10 '18 at 18:38
1

I managed to get FreeBSD 12.1-STABLE running on my OVH VPS by taking the following steps

Reboot in rescue mode from OVH's management panel. Once logged in (via SSH or KVM, either works), perform the following sequence of commands

  1. Unmount your original filesystem with umount /dev/sdb*. Note that the rescue system is mounted from /dev/sda. Don't touch /dev/sda.

  2. Destroy your original filesystem and the partition it lives on with fdisk. fdisk -u /dev/sdb followed by a series of d until the partition table is empty, then w.

  3. Install (or confirm that your rescue image has) the package xz-utils. Since my VPS started out life as an Ubuntu server, for me this meant running apt-get install xz-utils.
  4. Get a copy of a raw virtual image from FreeBSD.org, decompress it, and write it to /dev/sdb. From the command line in your rescue system, you would type wget https://download.freebsd.org/ftp/snapshots/VM-IMAGES/12.1-STABLE/amd64/Latest/FreeBSD-12.1-STABLE-amd64.raw.xz | xz -dc | dd of=/dev/sdb bs=1M

Then reboot and login via KVM in the OVH control panel to configure your FreeBSD server.