# MIgrate QNAP LXD Containers to Ubuntu Server

**URL:** <https://discussion.scottibyte.com/t/migrate-qnap-lxd-containers-to-ubuntu-server/117>\
**Category:** Uncategorized\
**Created:** [August 5, 2022, 11:16pm UTC](https://discussion.scottibyte.com/t/migrate-qnap-lxd-containers-to-ubuntu-server/117 "2022-08-05T23:16:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![scott](https://discussion.scottibyte.com/letter_avatar_proxy/v4/letter/s/3e96dc/32.png) [@scott](https://discussion.scottibyte.com/u/scott)\
**Post date:** [August 5, 2022, 11:16pm UTC](https://discussion.scottibyte.com/t/migrate-qnap-lxd-containers-to-ubuntu-server/117/1 "2022-08-05T23:16:45Z")

</div>

This tutorial is about learning to migrate QNAP Container Station LXD containers to an Ubuntu server running LXD. QNAP networks are defined in the QTS Network & Virtual Switch application from the QTS Desktop.

QNAP physical Ethernet adapters have names like eth0, eth1, eth2, and eth3.

You can ssh into your QNAP with:

```auto
ssh admin@192.168.1.___

```

Examine your QNAP physical adapters with “ifconfig” or “ip a” and look for your “eth” devices and you should see something like this:  
 ![image](https://discussion.scottibyte.com/uploads/default/original/1X/b9b93f46f8c86b30845a05d2339a6e17d8ede6a8.png)

In the same listing, you will see your virtual switches which are labelled as “qvs” devices and they should look like this:

![image](https://discussion.scottibyte.com/uploads/default/original/1X/516052c30c7751ace3633069ba36ace3520fd9c2.png)

You can run QNAP Network & Virtual Switch and you should be able to match up the addresses of the “qvs” devices to your virtual switches:

![image](https://discussion.scottibyte.com/uploads/default/original/1X/019d56c4fd59c5716e0bc0a66514aa097949f9a1.png)

You can also see this association in container station when either editing or creating a container by going into “advanced settings” and looking at the “user interface” for a container whose network mode is “bridge”.

![image](https://discussion.scottibyte.com/uploads/default/original/1X/d0a8b713b0ca848b85d43387e133fc735d3d2dff.png)

To make your container portable, you need to change it from bridged network mode to NAT network mode. I know this will lose the LAN address association and give the LXD container a NAT address temporarily, but we will fix this:

![image](https://discussion.scottibyte.com/uploads/default/original/1X/34a10a15a8717bf1e9fec50838e8479b90ecbb2a.png)

Create a bridge profile from the QNAP command line as follows by ssh’ing into your QNAP:

```auto
ssh admin@192.168.1.___
lxc profile create bridgeprofile

```

Edit the bridge profile to point to the correct “qvs” device for your connection as described above. Simply copy and paste the entire code block below including the “EOF” to the ssh session and press enter:

```auto
cat <<EOF | lxc profile edit bridgeprofile
description: Bridged networking LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: qvs0
    type: nic
EOF

```

Now modify your container to use the new profile:

```auto
lxc profile assign CONTAINER-NAME default,bridgeprofile

```

Wait a few minutes and your LXD container will get the same LAN address it had previously despite the fact that the Container Station thinks NAT network mode is set.

Now lets backup your LXD container while you are still in the ssh session on the QNAP. This leaves the container intact, it just stops it for the backup. We leave it stopped because when we restore it on the target Ubuntu server running LXD, it will have the same MAC address and so it will get the same IP address.

```auto
cd /share/Container
mkdir Backups
cd Backups
lxc stop CONT-NAME
lxc export CONT-NAME CONT-NAME.tar.gz

```

Now connect to your Ubuntu server with ssh or open a terminal if you are on the target ubuntu system desktop. Keep in mind that this assumes you have watched my other videos and have installed and initialized LXD on the Ubuntu target system:

This also assumes you have watched my “Cheap Self-Hosting Server” tutorial where I reviewed how to change your Ubuntu Ethernet controller to a “bridge” device and that you have named the bridge “bridge0”. If so, continue with the commands below.

Create the “bridgeprofile” just like on the QNAP:

```auto
lxc profile create bridgeprofile

```

Now edit the bridge profile by pasting the entire code block that follows to the ssh or terminal:

```auto
cat <<EOF | lxc profile edit bridgeprofile
description: Bridged networking LXD profile
devices:
  eth0:
    name: eth0
    nictype: bridged
    parent: bridge0
    type: nic
EOF

```

You will have to move the backup of the container that we exported to the ubuntu system. Hint: Use Secure File Transfer Protocol “sftp”, which is a part of openssh\_server as I have featured many times before on the channel. Assuming the container backup file is now local, restore it:

```auto
lxc import CONT-NAME.tar.gz CONT-NAME

```

After you import the container, you can start it and it will be running under the same address as before. Note, unless you change the MAC address for the container, you cannot run the QNAP container and this new container at the same time because they will conflict on the network.

```auto
lxc startCONT-NAME

```

**Other noteworthy stuff**

I frequently cover VLANS and Bridging LXD containers on the channel.

If you have a use case for an untagged VLAN interface which also gets an address on your MAIN LAN, you can do the following on the QNAP or a Linux node running LXD.

```auto
lxc profile create untagged
cat <<EOF | lxc profile edit untagged
description: Untagged macvlan profile
devices:
  eth0:
    name: eth0
    nictype: macvlan
    parent: bridge0
    type: nic
EOF

```

An example of a profile for a numbered VLAN that exists on your managed network:

```auto
lxc profile create vlan80
cat <<EOF | lxc profile edit vlan80
description: VLAN80 profile
devices:
  eth0:
    name: eth0
    nictype: macvlan
    parent: bridge0
	vlan: 80
    type: nic
EOF

```

A simple example of how to create a container with the VLAN above:

```auto
lxc launch ubuntu:20.04 example --profile=default --profile=vlan80

```

You can also change assigned profiles on a container:

```auto
lxc profile assign example default,bridgeprofile

```
