[Plugin] LXC Plugin


Recommended Posts

Thanks!.  I will use the following in my config file:

lxc.cgroup2.memory.max = 8192M 

And see if it works better.

 

Do you plan to add "lxcfs" support?  That could help to get "free" and "htop" report only the container and not the host memory. (I would not call it really  a high priority item either.)

Link to comment
5 minutes ago, hansan said:

Do you plan to add "lxcfs" support?  That could help to get "free" and "htop" report only the container and not the host memory. (I would not call it really  a high priority item either.)

That's not the cause at all, the cause is that on Unraid there are currently only privileged containers and in privileged containers you see all resources where on the other hand you only see resources that you've assigned in unprivileged container.

 

6 minutes ago, hansan said:

And see if it works better.

You can even test that by creating files with dd in /tmp inside the container that is bigger than 8GB, if you reach the 8GB mark then the container will simply crash.

Link to comment
  • 2 weeks later...

Good job.I'm new to this ,I created an OpenWrt lxc container,replaced with my build, running good on 6.11.5 unraid. 
My unraid has eth0 and eth1,how can I add eth1 to OpenWrt which could be anble to create other interface to dial ?

cgroupv2 enabled.

Link to comment
9 hours ago, hunterson said:

My unraid has eth0 and eth1,how can I add eth1 to OpenWrt which could be anble to create other interface to dial ?

Open the config from the container you want to edit, you'll find the exact path by clicking on the container icon -> Show Config and in the following popup the first line shows the path.

 

Edit the path with whatever you want and create a second entry for your second NIC:
 

# Network configuration for second NIC
lxc.net.1.type = veth
lxc.net.1.flags = up
lxc.net.1.link = eth1
lxc.net.1.name = eth1
lxc.net.1.hwaddr=AVALIDMACADDRESS

 

This example is for veth only!

 

lxc.net.1.link is the physical link on your Unraid server, lxc.net.1.name is the interface name in your LXC container.

Please also make sure that you add a valid MAC address to the second NIC.

 

Hope that helps.

 

BTW, I would strongly recommend to upgrade, 6.11.5 is outdated.

Link to comment
On 2/7/2024 at 10:05 PM, ich777 said:
# Network configuration for second NIC
lxc.net.1.type = veth
lxc.net.1.flags = up
lxc.net.1.link = eth1
lxc.net.1.name = eth1
lxc.net.1.hwaddr=AVALIDMACADDRESS

Thks,
I tried it over.
First, eth1 should be setted to bridge ,then br1 showed up,config as follows:
lxc.net.1.type = veth
lxc.net.1.flags = up
lxc.net.1.link = br1
lxc.net.1.name = eth1
it's done.
Or, config as below:
lxc.net.1.type = phys
lxc.net.1.flags = up
lxc.net.1.link = eth1
lxc.net.1.name = eth1
It's done again.

 

 

Link to comment
3 hours ago, ich777 said:

Is it now working?

 

I don't understand your post entirely...

 

You can configure it how you want, the example above was just how it could be done.

Sorry,I mean It's well done. that's the right way to create the second NIC . But PPPoE dialing seemed not a easy thing,  a kernel problem met.

Link to comment
  • 2 weeks later...

Hi Community. In regard to another post.  I seem to have issues setting up a lxc container and looking for guidance.

 

 

image.thumb.png.4d09eea89da277be19a3aac5513ac9f9.png

 

image.thumb.png.c36cd71788fe22a55c07cdb6997121fe.png

 

image.thumb.png.a3bea88826d876a0842314d62bd2c1d1.png

 

I use macvlan dockers and other vms. virbr0 seems correct for the network as that is what my vm settings use to get a network connection.

I original tried to use /mnt/cache/LXC
I changed the path and still seem to have issue creating a container.
 

Link to comment
1 hour ago, bmartino1 said:

I seem to have issues setting up a lxc container and looking for guidance.

Is it in general not working or did you already set up a container?

 

If it is in general not working have you yet tried the fourth recommended post on top of this thread?

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

Is it in general not working or did you already set up a container?

 

If it is in general not working have you yet tried the fourth recommended post on top of this thread?

 

I see. Yep. was general running the 4th pin topic fixed the issue:

image.thumb.png.11f57debe1abe2a80ce84f67b1535feb.png


I needed to run:
 

LXC_PATH=$(cat /boot/config/plugins/lxc/lxc.conf | grep "lxc.lxcpath=" | cut -d '=' -f2 | head -1)
rm -rf /var/cache/lxc ${LXC_PATH}/cache
mkdir -p ${LXC_PATH}/cache
ln -s ${LXC_PATH}/cache /var/cache/lxc


 

image.thumb.png.43dcef19c3dca6173840905da4391afe.png

Thank you for your help and assistance.

Yeah new testing to begin :)
image.thumb.png.56cb2fd7dd4aa24c3e4aaf18e9c7e5ba.png

Edited by bmartino1
  • Like 1
Link to comment
  • 4 weeks later...
On 3/14/2024 at 12:54 AM, ich777 said:

Is it necessary that the card is stubbed in the first place?

 

Why not do it like that:

 

your right, i dont; think it has to be stubed, not sure if this will allow me to add 2 ethernets.

 

I've made a ubuntu router before in the past. I will give that a try. Thanks ich777

  • Like 1
Link to comment

Where is the lxc command located. I would like to do some lxc terminal commands to test. Similar to start and stop a lxc container vs user scripts plugin.

 

root@BMM-Unraid:~# lxc --help
bash: lxc: command not found

 

root@BMM-Unraid:/etc/lxc# ls
default.conf@  lxc.conf@

 

root@BMM-Unraid:/mnt/cache/appdata/lxddata/generallxcpath# ls
Unifi/  cache/  python/

 

not sure how or where your plugin for lxc works to use lxc command.

Link to comment
4 minutes ago, bmartino1 said:

lxc

There is no LXC command.

 

4 minutes ago, bmartino1 said:

Similar to start and stop a lxc container vs user scripts plugin.

You can use:

lxc-start <CONTAINERNAME>

or

lxc-stop <CONTAINERNAME>
 

Can you please be a bit more specific what you want to do?

 

You can also attach to a running container by:

lxc-attach <CONTAINERNAME>

 

There is nothing special to my plugin, just plain simple LXC (without LXD).

  • Like 1
Link to comment

Hi ich777, I am trying to use LXC to solve my dual nic problem for plex container dedicated use and its work fine

 

Problem is passting through nvidia card.

 

I follow the instruction as this thread posted above and update my container config as my ls /dev/nvidia* -l result is as follow

 

root@X13-Unraid:~# ls /dev/nvidia* -l
crw-rw-rw- 1 root root 195, 254 Mar 13 00:32 /dev/nvidia-modeset
crw-rw-rw- 1 root root 236,   0 Mar 13 00:32 /dev/nvidia-uvm
crw-rw-rw- 1 root root 236,   1 Mar 13 00:32 /dev/nvidia-uvm-tools
crw-rw-rw- 1 root root 195,   0 Mar 13 00:32 /dev/nvidia0
crw-rw-rw- 1 root root 195, 255 Mar 13 00:32 /dev/nvidiactl

/dev/nvidia-caps:
total 0
cr-------- 1 root root 241, 1 Mar 13 00:32 nvidia-cap1
cr--r--r-- 1 root root 241, 2 Mar 13 00:32 nvidia-cap2


then I update the container config as follows

# Template used to create this container: /usr/share/lxc/templates/lxc-download
# Parameters passed to the template: --dist debian --release bullseye --arch amd64
# Template script checksum (SHA-1): 78b012f582aaa2d12f0c70cc47e910e9ad9be619
# For additional config options, please look at lxc.container.conf(5)

# Uncomment the following line to support nesting containers:
#lxc.include = /usr/share/lxc/config/nesting.conf
# (Be aware this has security implications)


# Distribution configuration
lxc.include = /usr/share/lxc/config/common.conf
lxc.arch = linux64

# Container specific configuration
lxc.rootfs.path = dir:/mnt/os_cache/lxc/debian11/rootfs
lxc.uts.name = debian11

# Allow cgroup access
lxc.cgroup2.devices.allow = c 195:* rwm
lxc.cgroup2.devices.allow = c 236:* rwm
lxc.cgroup2.devices.allow = c 241:* rwm

# Pass through device files
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file

# Network configuration
lxc.net.0.type = veth
lxc.net.0.flags = up
lxc.net.0.link = br0
lxc.net.0.name = eth0

lxc.net.0.hwaddr=52:54:00:04:EC:67
lxc.start.auto=0

 

After this, in the LXC tab the container shows faulty config error 

 

my unraid set is 6.12.8, the container img is debian 11

lxc.PNG

Link to comment
4 minutes ago, stamina77 said:
# Pass through device files
lxc.mount.entry: /dev/nvidia0 dev/nvidia0 none bind,optional,create=file
lxc.mount.entry: /dev/nvidiactl dev/nvidiactl none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm dev/nvidia-uvm none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-modeset dev/nvidia-modeset none bind,optional,create=file
lxc.mount.entry: /dev/nvidia-uvm-tools dev/nvidia-uvm-tools none bind,optional,create=file

These entries are wrong.

You can't use : you have to use =

: where the old format and are not supported anymore.

 

4 minutes ago, stamina77 said:

After this, in the LXC tab the container shows faulty config error 

Yes, because of the formatting error.

 

May I ask why you are using LXC for Plex in the first place? A Docker container would be much easier to set up or did I get this wrong and you have a different use case for the container?

Link to comment

Hi,

 

I'm quite new to Unraid but have used other Hypervisors in the past. LXC is very appealing to me because i could migrate some existing containers from my previous servers.

 

I tried your plugin on a fresh installation of Unraid 6.12.8 and LXC plugin verison 2024.03.14. ´Creating containers worked fine but destroying them always results in this error:

 

 

Destroy Container morbo, please wait until the DONE button is displayed!

ERROR, failed to destroy morbo!

lxc-destroy: morbo: ../src/lxc/utils.c: _recursive_rmdir: 160 Operation not permitted - Failed to delete "/mnt/cache/lxc/morbo/rootfs/var/empty"
lxc-destroy: morbo: ../src/lxc/utils.c: _recursive_rmdir: 160 Directory not empty - Failed to delete "/mnt/cache/lxc/morbo/rootfs/var"
lxc-destroy: morbo: ../src/lxc/utils.c: _recursive_rmdir: 160 Directory not empty - Failed to delete "/mnt/cache/lxc/morbo/rootfs"
lxc-destroy: morbo: ../src/lxc/storage/dir.c: dir_destroy: 104 Directory not empty - Failed to delete "/mnt/cache/lxc/morbo/rootfs"
lxc-destroy: morbo: ../src/lxc/lxccontainer.c: container_destroy: 3007 Error destroying rootfs for morbo
lxc-destroy: morbo: ../src/lxc/tools/lxc_destroy.c: do_destroy: 110 Destroying morbo failed

 

I have tried rebooting and disabling/enabling the plugin already. The folders on `/mnt/cache/lxc` are owned by `root`. Is that correct?

 

> stat /mnt/cache/lxc/morbo/rootfs/var/empty
  File: /mnt/cache/lxc/morbo/rootfs/var/empty
  Size: 0               Blocks: 0          IO Block: 4096   directory
Device: 0,43    Inode: 279359      Links: 1
Access: (0555/dr-xr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2024-03-18 09:02:41.724269344 -0700
Modify: 2024-03-18 09:02:41.724269344 -0700
Change: 2024-03-18 09:02:41.728269369 -0700
 Birth: 2024-03-18 09:02:41.724269344 -0700

 

Edited by buxel
updated stat command to the folder mentioned in the error
Link to comment
1 hour ago, ich777 said:

These entries are wrong.

You can't use : you have to use =

: where the old format and are not supported anymore.

 

Yes, because of the formatting error.

 

May I ask why you are using LXC for Plex in the first place? A Docker container would be much easier to set up or did I get this wrong and you have a different use case for the container?

 

I have 2 nic on my mb, eth 0 for unraid main port (192.168.50.164) and use openwrt gateway (192.168.50.200) to connect to CA since I'm in China and its hard to connect to CA or dockerhub. 

 

eth 1 for docker dedicated use, I use it connect to main route ( ASUS AX11000 ) to host img like qbittorrent, transmission, plex and others that need direct linkage to pub since I can just port forward via eth 1.

 

The plex docker issue is that If I use custom eth 1, I cant visit the local ip ( set plex ip to 192.168.50.5) via http://ip:32400/web, also port forwarding not succeed. However if I use eth 0 host for plex, the local net visit is fine but also port forwarding not ok.

 

Weird things is the qb and tr docker is ok as the same setting as plex.

 

So I turned into lxc to try yesterday, found its great and above network problem solved. 

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

These entries are wrong.

You can't use : you have to use =

: where the old format and are not supported anymore.

 

Yes, because of the formatting error.

 

May I ask why you are using LXC for Plex in the first place? A Docker container would be much easier to set up or did I get this wrong and you have a different use case for the container?

 

yeah I changed : to = the error status disappear

now in the container i can ls /dev/nvidia* -l and get the right result like

 

crw-rw-rw- 1 root root 195, 254 Mar 12 16:32 /dev/nvidia-modeset
crw-rw-rw- 1 root root 236,   0 Mar 12 16:32 /dev/nvidia-uvm
crw-rw-rw- 1 root root 236,   1 Mar 12 16:32 /dev/nvidia-uvm-tools
crw-rw-rw- 1 root root 195,   0 Mar 12 16:32 /dev/nvidia0
crw-rw-rw- 1 root root 195, 255 Mar 12 16:32 /dev/nvidiactl

 

the explore carries on :)

  • Like 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.