[Plugin] LXC Plugin


Recommended Posts

55 minutes ago, ich777 said:

What path did you try before?

Not the default path /mnt/user/lxc/ exactly, but something in the /mnt/user/ path. Can't remember.

 

57 minutes ago, ich777 said:

Doesn't your printer get entry in /dev itself?

It's only a scanner, not a all-in-one printer. But yeah I will check that later. Thank you. 👍

  • Like 1
Link to comment
3 minutes ago, Kulisch said:

Not the default path /mnt/user/lxc/ exactly, but something in the /mnt/user/ path. Can't remember.

Have you read the red text on the LXC Settings page:

image.thumb.png.e09552a8aa95f2576da9fad866476f50.png

 

 

3 minutes ago, Kulisch said:

It's only a scanner, not a all-in-one printer. But yeah I will check that later. Thank you. 👍

I think that for printers/scanners a device in /dev is also created but I'm not too sure which one because I even don't own a printer/scanner and haven't done much with printers/scanners...

Link to comment
45 minutes ago, Kulisch said:

Why is the path /mnt/user/... not allowed to be used?

Because this can cause a lot of overhead when copying or installing many small files because it's a FUSE file system and will also cause more system load because of FUSE.

It can get even that far that the WebUI from Unraid itself can become unresponsive and hang for a short time, seen this when installing Docker container inside a LXC container with a huge Layer that has many packages to install/extract.

Don't get me wrong but I write such things for a good reason... ;)

 

Glad that you've worked it out! I will recommend this post on top of this thread.

Link to comment
41 minutes ago, ich777 said:

Because this can cause a lot of overhead when copying or installing many small files because it's a FUSE file system and will also cause more system load because of FUSE.

Ah I see... yeah that makes sense.

 

43 minutes ago, ich777 said:

Don't get me wrong but I write such things for a good reason... ;)

Of course, I just wanted to understand. Thanks for educating and supporting. 👍

  • Like 1
Link to comment
2 hours ago, juan11perez said:

Good day. the usual

 

root@Unraid:~# lxc-start -F focal
Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
[!!!!!!] Failed to mount API filesystems.
Exiting PID 1...
root@Unraid:~# 

 

It's the only ubuntu not working. Xenial, bionic, jammy all ok.

 

It's the same on my server...

Have to look into this but don't hold your breath since now I'm really busy...

  • Thanks 1
Link to comment
9 minutes ago, jmztaylor said:

Is there a way to set static IP?  Adding lxc.net.0.ipv4.address and .gateway has no effect.

Yes, because the plugin uses a existing bridge network.

 

Simply set it in the container according to your Distribution.

 

What would be even easier is to set a static IP for the container in your DHCP server (Router/Firewall).

  • Like 1
Link to comment

Worked just fine.  Another random question.  Do you have a suggestion to clone existing container?  I dunno if I am reading the man page incorrectly but I am doing 

lxc-copy -n existing-name -N new-name

 

All it does is return to terminal with no output

 

EDIT:

So I was able to make it work via snapshot
 

lxc-snapshot container-name snapshot-name

 

Then restore

lxc-snapshot --restore=snapshot-name --name=old-container-name new-container-name

 

 

EDIT 2:

And I guess lxc-copy does work in this syntax

lxc-copy --name=old-container-name --newname=new-container-name

 

 

Creating the containers this way seems to make the GUI unable to destroy the containers also.

Edited by jmztaylor
Link to comment
28 minutes ago, jmztaylor said:

Another random question.  Do you have a suggestion to clone existing container?

Have to look into things like copy at the end of next month, currently I really don‘t have time to help or develop the plugin further since I‘m real busy in real life.

 

Another idea would be maybe to simply just copy the entire folder for the container and preserve the rights?

Just thinking that this should be the easiest solution if it works properly…

 

The plugin is not very polished currently and I‘m really sorry for that but I will definitely continue to improve it after things calmed down a little bit.

 

You should be also able to delete the folder for the Container, this is basically the same as destroying it from the GUI.

  • Like 1
Link to comment
9 minutes ago, ich777 said:

Have to look into things like copy at the end of next month, currently I really don‘t have time to help or develop the plugin further since I‘m real busy in real life.

 

Another idea would be maybe to simply just copy the entire folder for the container and preserve the rights?

Just thinking that this should be the easiest solution if it works properly…

 

The plugin is not very polished currently and I‘m really sorry for that but I will definitely continue to improve it after things calmed down a little bit.

 

Yeah its not too big of a deal.  I think its just a permissions thing.  I can destroy via gui but the folder doesn't get nuked.  Even trying to remove the folder from terminal I get device or resource busy.  Doesn't seem to be running though.  Again not a big deal.  But ultimately it work using the command previously posted.

  • Like 1
Link to comment
On 6/24/2022 at 3:25 AM, ich777 said:

Glad to hear that everything is working now for you... :)

It is not a perfect workaround but it works for now... ;)

 

Not yet, but it should work (please keep in mind that in the next two months I'm not able to do much here because I'm really busy in real life)... :/

LXD is only a set of tools/databases or better speaking a management system for LXC so it is not needed in general.

 

I've don't integrated LXD because it introduces to much dependencies like Python and could maybe interfere with other Python installations which are maybe installed through the NerdPack and so on...

Just to be clear, LXD also allows managing VMs since it's just a frontend for managing Containers and VMs, so this is how you'd run Windows with LXD. Windows can't run as a container because it's a literally different OS for those wondering. LXC works by sharing the same kernel and containerizing everything, so think of it like a glorified chroot environment.

 

Anyway, it seems totally unnecessary for this purpose, as Unraid already has excellent VM management with libvirt and the webUI. If people need windows for something, use the VM platform unraid comes with.

Edited by JSE
Link to comment
1 hour ago, JSE said:

Windows can't run as a container because it's a literally different OS for those wondering.

That‘s not entirely true because there are workaround so that you can get Windows to work with LXC/LXD (I actually only know a few tutorials which involves LXD to create such a container)

This should be also possible on Unraid in combination with QEMU.

Also ARM containers should be theoretically possible in combination with QEMU and LXC on Unraid but I have to look a little bit more into that when I have more time since I think the necessary QEMU libraries are missing on Unraid, that‘s why I locked the LXC plugin to x86_64 only currently.

 

1 hour ago, JSE said:

Anyway, it seems totally unnecessary for this purpose, as Unraid already has excellent VM management with libvirt and the webUI. If people need windows for something, use the VM platform unraid comes with.

Agreed.

Link to comment
On 7/11/2022 at 7:47 AM, ich777 said:

That‘s not entirely true because there are workaround so that you can get Windows to work with LXC/LXD (I actually only know a few tutorials which involves LXD to create such a container)

This should be also possible on Unraid in combination with QEMU.

Also ARM containers should be theoretically possible in combination with QEMU and LXC on Unraid but I have to look a little bit more into that when I have more time since I think the necessary QEMU libraries are missing on Unraid, that‘s why I locked the LXC plugin to x86_64 only currently.

 

Agreed.

I don't know what you mean by this. What's not true? You can't run windows as a linux "container", it would need to be virtualized :P

I guess you could run QEMU or something in a container, but it's still going to be a VM at the end of the day, it would be a VM with extra steps. 

 

I suppose you could do all the virtualization in software, in a container, but that would be extra slow, so I'm assuming you'd still be using KVM, which is what I mean about a VM with extra steps... might as well just avoid containerizing all that. 

Edited by JSE
Link to comment
  • 2 weeks later...
1 hour ago, Phillip Lurgensten said:

How to limit CPU pinning for LXC containers?

Open up your config in the editor of your choice (to get the path to the file click on the icon from the container and on top you should be able to see: "Path from configuration file:") and add this at the bottom of the file:

lxc.cgroup.cpuset.cpus = 0,1

 

In this example it will limit the container to use only the first and second CPU core, you can of course add more or even do it like this if you want to use for example the first 4 cores:

lxc.cgroup.cpuset.cpus = 0-4

(don't forget to restart the container after changing/adding a value, but I would strongly recommend that if you edit the config to stop the container in the first place anyways)

 

Hope that helps

  • Thanks 1
Link to comment
22 hours ago, ich777 said:

Open up your config in the editor of your choice (to get the path to the file click on the icon from the container and on top you should be able to see: "Path from configuration file:") and add this at the bottom of the file:

lxc.cgroup.cpuset.cpus = 0,1

 

In this example it will limit the container to use only the first and second CPU core, you can of course add more or even do it like this if you want to use for example the first 4 cores:

lxc.cgroup.cpuset.cpus = 0-4

(don't forget to restart the container after changing/adding a value, but I would strongly recommend that if you edit the config to stop the container in the first place anyways)

 

Hope that helps

Could you Add an Option at the Creation of LXC to choose the Wanted CPUs, the RAM and Network Speed?

Like Proxmox LXC Creation?

Link to comment
2 minutes ago, Phillip Lurgensten said:

Could you Add an Option at the Creation of LXC to choose the Wanted CPUs, the RAM and Network Speed?

Yes, but that are planed features and I have this and next month barely time to extend the plugin.

 

I will of course add features but that takes time. Also don't forget I accept PullRequests over on GitHub... :D

 

Also see the first post from this thread where it says ATTENTION ;)

  • Like 1
Link to comment
10 minutes ago, ich777 said:

Yes, but that are planed features and I have this and next month barely time to extend the plugin.

 

I will of course add features but that takes time. Also don't forget I accept PullRequests over on GitHub... :D

 

Also see the first post from this thread where it says ATTENTION ;)

Best Man ^^

 

But could you Add in the ReadMe Section of the plugin on unraid 
this here in Big an Red? ive made an mistake and used the new permissions over the lxc folder >_> now i need to remade all the Containers Dx


- Never run New Permissions from the Unraid Tools menu on this directory because you will basically destroy your container(s)!
 

Link to comment
  • 3 weeks later...

For anyone interested I've put together a Backup script which can be easily used in the User Scripts plugin to run a Daily/Weekly/... schedule.

 

A few things to note:

  • This script is only capable of creating one backup per day
  • The Backup will be stored in a single .tar file
  • The backups are NOT compressed
  • By default Docker subvolumes are excluded if Docker is installed within the LXC container
  • You can specify if you want to stop the container while creating the backup

 

Please don't forget to set your LXC container name, and the Backup location!

 

If you want to keep all backups please set the variable BACKUPS_TO_KEEP to 0

 

For any further questions feel free to ask.

lxc_tar_backup.sh

  • Thanks 1
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.