0

I would like to boot an Arch Linux instance using LXC. Just about everything works, but I'm encountering the following error when trying to configure an interface using dhcpcd:

# dhcpcd eth0
dhcpcd[4213]: version 5.6.4 starting
dhcpcd[4213]: eth0: if_init: Read-only file system
dhcpcd[4213]: eth0: interface not found or invalid

This appears to be a direct result of dhcpcd trying to modify /proc/sys/net/ipv4/conf/eth0/promote_secondaries:

4210  open("/proc/sys/net/ipv4/conf/eth0/promote_secondaries", O_WRONLY|O_CREAT|O_TRUNC, 0666) = -1 EROFS (Read-only file system)
4210  writev(2, [{"dhcpcd[4210]: eth0: if_init: Read-only file system", 50}, {"\n", 1}], 2) = 51

I can hack around it using a bind mount:

# touch /tmp/promote_secondaries
# mount -o bind /tmp/promote_secondaries \
  /proc/sys/net/ipv4/conf/eth0/promote_secondaries

But that seems like a terrible idea. Is there any way to get dhcpcd to run under LXC without this hack? Why is write access to this sysctl not available under LXC?

larsks
  • 41,276
  • 13
  • 117
  • 170

2 Answers2

1

The reason is that, upon startup, your container mounts a read-only version of /proc/sys on top of the /proc structure.

Inside container:

# grep proc /proc/mounts 
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
proc /proc/sys proc ro,relatime 0 0

You can umount ( or mount -o remount,rw) it and your problem will disappear.

umount /proc/sys

The read-only /proc/sys directory is meant to protect (the overall stability) of your host from (accidental) modifications from the LXC-container, so the above statement does imply a risk.

Zabuzzman
  • 733
  • 10
  • 25
0

I have the same problem. I don't know what can be done in general about the ro filesystem, but to fix the dhcp problem, I use dhclient instead of dhcpcd. dhclient does not try to write anything on /proc/sys.