# Migrate jail system to fully virtualized system like qemu



## ro (Jul 19, 2019)

Hi.

I have legacy (FreeBSD 7.4) bare metal host with jail in it.
Is it possible to move jail from this host into qemu virtual maschine by coping jail file system and kernel from host system?

Is it necessary to do anything else besides such copy?


----------



## SirDice (Jul 19, 2019)

Why do you have a need for a version that's been EoL for more than 6 years?


----------



## ro (Jul 19, 2019)

In ugly commercial software reasons on this host.
I have no chance to update system without brake this software =(


----------



## SirDice (Jul 19, 2019)

ro said:


> In ugly commercial software reasons on this host.


Which one?


----------



## ro (Jul 19, 2019)

This software was written by request. Software support is no longer being implemented. We have no sources


----------



## SirDice (Jul 19, 2019)

Have you tried running it on a recent version by using misc/compat7x for example?


----------



## ro (Jul 19, 2019)

Problen with this software is not it binary compatibility, but in library dependencies
I can't update the existing environment


----------



## SirDice (Jul 19, 2019)

ro said:


> but in library dependencies


That's what misc/compat7x is for. At least for the base system's libraries. Which other libraries does the application use?


----------



## ro (Jul 19, 2019)

You surprised me. I didn't know about misс/compat*. I will try, thanks.
But I want to remove the jail regardless of success. Сould You answer the main question of the topic?


----------



## SirDice (Jul 19, 2019)

I think it'll be easier if you do a clean install on the VM. Then move the application over. Just copying the files doesn't create the boot sector and swap for example. But you could do those by hand too. Set up the partitions, boot info, etc, then copy the files. Be careful though, there are lots of hard-linked files, a "plain" copy would break those and create independent files instead.


----------



## ro (Jul 19, 2019)

Great thanks for Your help


----------



## gkontos (Jul 19, 2019)

ro said:


> Hi.
> 
> I have legacy (FreeBSD 7.4) bare metal host with jail in it.
> Is it possible to move jail from this host into qemu virtual maschine by coping jail file system and kernel from host system?
> ...



Yes, you can copy the Jail to a FreeBSD 12.0-RELEASE host physical or virtual. All you need to have is misc/compat7x installed on the host system.

You will need to adjust the rc.conf of the host system so that the jail can start properly


----------



## _martin (Jul 19, 2019)

For the sake of the OP's original question:  moving to qemu is possible. It all depends on the setup within the 7.4 system. But generally it's easier to first install FreeBSD and then move the application to it. My assumpiton: qemu host has graphics output. If not, you can play with the -console, -vnc and alike options to get the job done. 

On a qemu host you could do the following:

Download the old FreeBSD from the archive here.
Prepare the virtual disk: `qemu-img create -f qcow2 qbsd7.qcow2 10g`
Launch the FreeBSD installer: `qemu-system-x86_64 -hda  qbsd7.qcow2 -cdrom FreeBSD-7.4-RELEASE-amd64-disc1.iso`

Follow through the installation process and boot to the newly installed system. Then you can start migrating the application from old physical system to new virtual. 
There's also an option to play with the virtio drivers to get the better performance out of it (I don't know if virtio drivers are supported on 7.4)

Again, there are more ways to skin a cat, this is one of them.


----------



## SirDice (Jul 19, 2019)

gkontos said:


> Yes, you can copy the Jail to a FreeBSD 12.0-RELEASE host physical or virtual. All you need to have is misc/compat7x installed on the host system.


To be complete, you actually need all these too:
misc/compat7x
misc/compat8x
misc/compat9x
misc/compat10x
misc/compat11x

7x is for running 7 binaries on 8, 8x is for 8 binaries on 9, etc. You need to "fill" this all the way to N-1, where N is the major version you have. The same is true for the required kernel options, COMPAT_FREEBSD7, COMPAT_FREEBSD8, etc.


----------



## gkontos (Jul 20, 2019)

SirDice You are correct!


----------



## ro (Aug 8, 2019)

Great thanks for all for help one more time.
I've run this jail in kvm virtual machine.

Best regards


----------



## teo (Aug 16, 2019)

_martin said:


> There's also an option to play with the virtio drivers to get the better performance out of it (I don't know if virtio drivers are supported on 7.4)


Hello _martin, a little question, does qemu libraries serve as (devices, audio, copy/paste, folder) with FreeBSD as guest system?


----------



## _martin (Aug 16, 2019)

teo said:


> does qemu libraries serve as (devices, audio, copy/paste, folder)


Not sure what you mean by that. You can define various types of devices within qemu instance. However all my FreeBSD machines are headless so I don't have any experience with setting up desktop-related features in qemu on FreeBSD.


----------

