Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Plugin] LXC Plugin

Featured Replies

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.)

  • Replies 899
  • Views 157.4k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • Install SSH Server in Debian based containers:     Method 1 (recommended) :   Attach to the container with "lxc-attach DebianLXC /bin/bash" (replace DebianLXC with your con

  • Is someone here interested in something like a "Button" on the create container page where a Debian Bullseye container is set up with a pretty basic Desktop environment (XFCE4) in conjunction with Tur

  • domrockt
    domrockt

    AWSOMEEEEEEE   

Posted Images

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

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

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

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.

 

 

  • Author
9 minutes ago, hunterson said:

It's done again.

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.

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.

  • 2 weeks later...
  • Author
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?

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

  • Author
4 hours ago, bmartino1 said:

Will this survive a reboot?

Yes.

 

4 hours ago, bmartino1 said:

Do I need to run that once or is this at every boot???

No.

  • 4 weeks later...
  • Author
1 hour ago, bmartino1 said:

config line command to pass a pcie device form the bind vfio

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

 

Why not do it like that:

 

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

  • Author
1 hour ago, bmartino1 said:

if this will allow me to add 2 ethernets.

You can specify more than two just increase the number and assign it to the correct interface and you should be good to go.

  • Author
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).

  • Author
Just now, bmartino1 said:

to use an openwrt container

Sorry importing contianers from Proxmox is not supported.

However support for container images is coming but no ETA so far.

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

  • Author
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?

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

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. 

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 :)

8 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?

 

thanks ich777,i successful pass through nvidia card and installed plex under instruction of this thread

https://www.geekbitzone.com/posts/2022/proxmox/plex-lxc/install-plex-in-proxmox-lxc/

 

It totally work as I expected,I can use nv card to encode video from unraid folder and port forward plex service on dedicated ethernet(not like orignal unraid docker failed to fulfill that purpose ) to pub connection

 

now I have lots of interest to dive into lxc learning.

 

Thanks ich777, you are the pro

  • Author
8 hours ago, buxel said:

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

Yes.

 

8 hours ago, buxel said:

migrate some existing containers from my previous servers.

What was your previous server and how do you migrate?

 

8 hours ago, buxel said:

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:

Please post your Diagnostics.

Are these migrated containers or are these newly set up containers through the plugin?

I assume that the path /mnt/cache is on a ZFS pool, did you delete by any chance the dataset zfs_lxccontainers?

Or did you maybe create a container, then migrated the data from the old system over?

 

Please describe exactly what you are doing.

 

EDIT: Just as a sanity check I created and felted a container, using also ZFS as Backing Storage type.

Hello @ich777, thank you for the quick response.

 

Migration is something i want to tackle later. For now, all containers are newly created through the plugin.

I have not deleted (or any other way messed with) anything. I first want to see how the system works, before i break it 😉. However, i have not created any dataset myself, i just followed the instructions in the plugin and (i think) it mentioned that the non-existing paths will be created.

 

Please find the logs attached. Before exporting, i have tried again with "test-container", which gave the same error as before.

 

 

hermes-diagnostics-20240319-1929.zip

Edited by buxel

  • Author
1 hour ago, buxel said:

Please find the logs attached. Before exporting, i have tried again with "test-container", which gave the same error as before.

Just out of curiosity I tried also a NIX container 23.11:

grafik.png.a34e1d05323f47cc3384d9aca01080fa.png

 

...let it run for a bit:

grafik.thumb.png.65e177fb287917b55750fbd9c42ab097.png

 

...and then deleted it:

grafik.png.e706501b6a8c7f23e26cdc3df4a89943.png

 

Seems to work fine here...

 

I then changed the plugin to Directory as Backing Storage type:

grafik.png.afac0c3182748fce8e3a0ccdd9210ff3.png

 

...and there it is when I delete the container:
grafik.thumb.png.9222615f4ce6a0dca5cdce95488487e3.png

 

 

However it seems to be related specific to NIXOS since it is not happening with a Debian container.

 

I just noticed that there the immutable bit is set. You have to remove that first and then delete it.

To remove that bit open up a Unraid terminal and type in:

chattr -i <PATHTOCONTAINER>/rootfs/var/empty

(you have to replace the path to container with the absolute path to /rootfs/var/empty like in my screenshot /mnt/nvme/lxc/nix/rootfs/var/empty)

 

After that you can delete the folder for the container from the lxc directory and it will disappear (refresh the LXC page once) or you could also go to the LXC page and delete the container since after that the removal will work as intended.

 

Hope that helps for now and I will look into if I can work around that in the plugin.

 

I'll look into that and report back.

 

EDIT: BTW, please set the Storage Backing Type in the LXC settings to BTRFS in your case since then LXC will use BTRFS nativesnapshots. ;)

 

EDIT2: @buxel please update the LXC plugin to version 2024.03.19a where I implemented a workaround to remove the immutable bit first and then delete the container.

I can confirm everything you just said. The immutable bit seems to date back quite a while: https://github.com/NixOS/nixpkgs/commit/3877ec5b2ff7436f4962ac0fe3200833cf78cb8b#commitcomment-19100105

 

I assume, NixOS being special in it's ways about immutability, this was implemented to keep some declarative guarantees and prevent apps from writing where they shouldn't.

I have (ab)used this bit myself to make sure no app is accidently writing to a not yet mounted share.

 

Oh, and thanks about the note on the backing storage. 👍

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.