Moving an LXC container

Hi,

I read this thread earlier today Flash Memory weared out -> trying to boot from msata

I have an LXC on internal memory at the moment …I have no recollection of being advised this was in the category “under no circumstances do this” :frowning:

I have just plugged a USB stick in to the rear port of my Omnia and I would like to move the LXC to this device.

Some advice please:

  1. What format should I use on the flash stick (ext2 ?)
  2. How do I move the LXC from internal memory to the USB stick …I have done a lot of random tweaking to the VM over the last year-or-so and really don’t want to start all over again.

Hope someone can help.
Thanks,
BC

We recommend Btrfs :slight_smile: Well problem is not LXC itself but how are the distributions inside usually behaving - OpenWRT is optimized to limit flash write, while normal distributions don’t care a many people don’t realize it. Currently in 3.10 we are testing storage plugin that will help you move containers on external flash drive with few clicks in WebUI. In general, you need to format flash drive, make sure it is mounted before LXC tries to start and move data there using either tar or rsync with appropriate options (like numeric ids, preserving rights etc).

If you’re comfortable with using the command line, you can ssh into your router and set this up fairly simply.

While @miska recommends btrfs, I cannot. From what I’ve read, it is still really not ready for production use.

I recommend formatting the disk as ext4 for now, then when you mount it, you should use the UUID and not the device name since with USB, if you have multiple usb storage devices, the device name can change. You should see a section like this in /etc/config/fstab:

config mount
        option target '/mnt/sda1'
        option uuid '36cd0876-db83-473f-bc91-c1a5b6c4d4c4'
        option enabled '1'

You will want to shut down the lxc service before you move the lxc directory.

/etc/init.d/lxc-auto stop

Move the lxc directory to the disk.

cd /srv
mv lxc /mnt/sda1

Then I went to /srv and created a symlink to the lxc directory:

ln -s /mnt/sda1/lxc .

This is all pretty basic linux sysadmin stuff, but I’ve also been doing it for many years so I’m very comfortable with it. YMMV.

Depends on which features you use. Enterprise distros like SUSE Linux Enterprise use it in production, and by default.

Thank you to all that have offered help here :slight_smile:


After considering this: https://btrfs.wiki.kernel.org/index.php/Status#Overview

…and this:
# mount
/dev/mmcblk0p1 on / type btrfs (rw,noatime,ssd,space_cache,commit=5,subvolid=263,subvol=/@)

I concluded that btrfs is stable, and the driver in the Omnia is trusted.


However, I’ve found an interesting problem…
I formatted the partition with:
# mkfs.btrfs -L USB-Omnia -U 1ABE11ED-B7F5-C0DE-DA7A-B007AB1E0001 /dev/sda2
# btrfs filesystem show
Label: ‘USB-Omnia’ uuid: 1abe11ed-b7f5-c0de-da7a-b007ab1e0001
Total devices 1 FS bytes used 384.00KiB
devid 1 size 26.03GiB used 2.02GiB path /dev/sda2

But the UUID being detected by, well, everything, especially Luci is some other random hex string! [shrug]


I also mounted the partition with the option “noatime” to prevent abusive writes which will trash the flash stick …this will also be beneficial on ext filing systems :slight_smile:


I also took the opportunity to add a vfat partition on the front of the flash stick …but I have been unable to convince the Omnia to mount it …either CLI or WebGUI …But I guess that’s another thread


Thanks again for fast, good quality help.
BC

PS. I did try and install the new plugin …but I failed at working out how to install the plugin (or, for that matter, any plugin)

the plugin is only available in 3.10, for that you have to be in RC channel and upgrading the whole system will install it anyway by iself, then you will have a Storage option in the main menu.
But it is better is you are waiting until it will be pushed out from RC into the main stable release

@BlueChip

Like others, I disagree with @jklass. I think btrfs is sufficiently stable, and the benefit of snapshots is a big plus of btrfs.

This is bad advice. It may well break your LXC installation. Instead, see the following thread for advice on how to move LXCs from one FS to another…:

Read the entire thread.

I am sorry, but I cannot comment on 3.10s new feature to move /srv to external storage, as I have never used it.