Free Alpine Linux Shell Accounts

1567810

Comments

  • @Not_Oles said:
    Hi guys! Sorry, but I just received an email from Hetrix saying that fmt ping monitor is down on IPv4 and on IPv6. Reported to @Cloudie. Will update when I know more. Thanks very much! Tom

    Hetrix says its monitors are again receiving ping responses from fmt as of eight minutes ago. :)

  • @Not_Oles said: @terrorgen Did you try it too?

    Hey Tom, just trying it and looks like you need to add me to /etc/sub{u,g}id

    DM us for private tracker invite.

  • @terrorgen said:

    @Not_Oles said: @terrorgen Did you try it too?

    Hey Tom, just trying it and looks like you need to add me to /etc/sub{u,g}id

    Hi! Okay, added to /etc/sub*id and also to /etc/lxc/lxc-usernet. Please let me know if you need anything else. Have fun!

  • @Not_Oles said:

    @terrorgen said:

    @Not_Oles said: @terrorgen Did you try it too?

    Hey Tom, just trying it and looks like you need to add me to /etc/sub{u,g}id

    Hi! Okay, added to /etc/sub*id and also to /etc/lxc/lxc-usernet. Please let me know if you need anything else. Have fun!

    Thanks! However, I can't start my LXC container. Maybe it has something to do with lxcbr0?

    DM us for private tracker invite.

  • Not_OlesNot_Oles Provider
    edited February 2023

    Hi again @terrorgen!

    Can you please take another look at how @subenhon got his container started?

    If you did everything the same as @subenhon, are you seeing any errors? It can be helpful for seeing errors to use the "-F" a/k/a "--foreground" option to lxc-start.

    I've been busy, so, unfortunately, I haven't tried this myself yet. But I will, eventually.

    Thanks!

    Tom

  • edited February 2023

    I did, and it is stored at ~terrorgen/log if you want to take a peek.

    To save everyone's time, I think it is because of this:

    lxc-start nixos 20230220204723.613 ERROR    start - ../src/lxc/start.c:lxc_spawn:1795 - Failed to setup cgroup limits for container "nixos"
    

    Does the lack of systemd in Alpine contribute to this? Cause I also saw some TRACE messages related to systemd not being found.

    DM us for private tracker invite.

  • There are many interesting entries in those logs!

    I forgot to initialize the bridge when I last rebooted. I have to set the bridge so it starts automagically.

    Want to try starting your container again, please?

  • And it's still not working for me to get NixOS run on LXC.

    I tried downloading a standard debian and Ubuntu templates but was unsuccessful as well.
    Must be the configuration.

    DM us for private tracker invite.

  • It seems that the LXC containers might be working on this server! Thanks to @yoursunny for helping a lot to prepare the way! Thanks to @subenhon for blazing the trail!

    @subenhon said:
    @Not_Oles ,Here is how I create the Lxc container.

    ~ $ cat $HOME/.config/lxc/default.conf
    lxc.include = /etc/lxc/default.conf
    lxc.idmap = u 0 1022000000 65536
    lxc.idmap = g 0 1022000000 65536
    ~ $ lxc-create -n alpine -f $HOME/.config/lxc/default.conf -t download -- --dist alpine --release 3.17 --arch amd64
    Using image from local cache
    Unpacking the rootfs
    ---
    You just created an Alpinelinux 3.17 x86_64 (20230123_20:03) container.
    ~ $# change container root password and network setting frome dhcp to manual
    ~ $ lxc-attach -n alpine
    / # passwd
    Changing password for root
    New password: 
    Retype password: 
    passwd: password for root changed by root
    / # exit
    ~ $ # container ip config  
    ~ $ echo -e "lxc.net.0.ipv4.address = 192.168.188.58/24\nlxc.net.0.ipv4.gateway = auto" >> $HOME/.local/share/lxc/alpine/config
    ~ $ echo -e "lxc.net.0.ipv6.address = 2602:fba1:999:1c00:58::/64\nlxc.net.0.ipv6.gateway = auto" >> $HOME/.local/share/lxc/alpine/config
    ~ $ #restart container
    ~ $ lxc-stop -n alpine
    ~ $ lxc-start -n alpine
    ~ $ lxc-console -n alpine
    Connected to tty 1
    Type <Ctrl+a q> to exit the console, <Ctrl+a Ctrl+a> to enter Ctrl+a itself
    Welcome to Alpine Linux 3.17
    Kernel 6.1.8-0-lts on an x86_64 (/dev/tty1)
    
    alpine login: root
    Password: 
    Welcome to Alpine!
    
    The Alpine Wiki contains a large amount of how-to guides and general
    information about administrating Alpine systems.
    See <https://wiki.alpinelinux.org/>.
    
    You can setup the system with the command: setup-alpine
    
    You may change this message by editing /etc/motd.
    
    alpine:~# #add nameserver
    alpine:~# echo -e "nameserver 1.1.1.1\nnameserver 2001:470:20::2\n" >> /etc/resolv.conf
    alpine:~# ping -4 google.com
    PING google.com (142.251.46.238): 56 data bytes
    64 bytes from 142.251.46.238: seq=0 ttl=119 time=1.691 ms
    64 bytes from 142.251.46.238: seq=1 ttl=119 time=1.604 ms
    --- google.com ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 1.604/1.647/1.691 ms
    alpine:~# ping -6 google.com
    PING google.com (2607:f8b0:4005:80b::200e): 56 data bytes
    64 bytes from 2607:f8b0:4005:80b::200e: seq=0 ttl=117 time=50.880 ms
    64 bytes from 2607:f8b0:4005:80b::200e: seq=1 ttl=117 time=1.773 ms
    

    There are some small differences between my procedure and @subenhon's procedure. In particular, I don't understand why @subenhon seemed to get working autoconfigured IPv4 out of the box and I perhaps didn't.

    Here is my transcript.

    # See @subenhon's post at
    # https://lowendspirit.com/discussion/comment/127589/#Comment_127589
    fmt:~/.config/lxc$ cat default.conf 
    lxc.include = /etc/lxc/default.conf
    lxc.idmap = u 0 1000000000 65536
    lxc.idmap = g 0 1000000000 65536
    fmt:~/.config/lxc$ cd
    fmt:~$ lxc-create -n alpine -f $HOME/.config/lxc/default.conf -t download -- --dist alpin
    e --release 3.17 --arch amd64
    ../src/lxc/cmd/lxc_usernsexec.c: 64: opentty - Permission denied - Failed to open tty
    ../src/lxc/cmd/lxc_usernsexec.c: 64: opentty - Permission denied - Failed to open tty
    ../src/lxc/cmd/lxc_usernsexec.c: 64: opentty - Permission denied - Failed to open tty
    Downloading the image index
    Downloading the rootfs
    Downloading the metadata
    The image cache is now ready
    Unpacking the rootfs
    
    ---
    You just created an Alpinelinux 3.17 x86_64 (20230220_13:11) container.
    fmt:~$ lxc-ls
    alpine 
    fmt:~$ lxc-attach -n alpine
    lxc-attach: alpine: ../src/lxc/attach.c: get_attach_context: 406 Connection refused - Failed to get init pid
    lxc-attach: alpine: ../src/lxc/attach.c: lxc_attach: 1470 Connection refused - Failed to get attach context
    fmt:~$ lxc-start -n alpine
    fmt:~$ lxc-attach -n alpine
    / # cd
    /bin/ash: cd: can't cd to /home/notoles: No such file or directory
    / # whoami
    root
    / # cd root
    ~ # pwd
    /root
    ~ # passwd
    Changing password for root
    New password: 
    Retype password: 
    passwd: password for root changed by root
    ~ # echo -e "nameserver 1.1.1.1\nnameserver 2001:470:20::2\n" >> /etc/resolv.conf
    ~ # ping -4 -c 2 google.com
    ping: bad address 'google.com'
    ~ # exit
    fmt:~$ echo -e "lxc.net.0.ipv4.address = 192.168.188.10/24\nlxc.net.0.ipv4.gateway = auto
    " >> $HOME/.local/share/lxc/alpine/config
    fmt:~$ echo -e "lxc.net.0.ipv6.address = 2602:fba1:999:1c00:10::/64\nlxc.net.0.ipv6.gatew
    ay = auto" >> $HOME/.local/share/lxc/alpine/config
    fmt:~$ cat -n $HOME/.local/share/lxc/alpine/config
         1  # Template used to create this container: /usr/share/lxc/templates/lxc-download
         2  # Parameters passed to the template: --dist alpine --release 3.17 --arch amd64
         3  # For additional config options, please look at lxc.container.conf(5)
         4
         5  # Uncomment the following line to support nesting containers:
         6  #lxc.include = /usr/share/lxc/config/nesting.conf
         7  # (Be aware this has security implications)
         8
         9
        10  # Distribution configuration
        11  lxc.include = /usr/share/lxc/config/common.conf
        12  lxc.include = /usr/share/lxc/config/userns.conf
        13  lxc.arch = linux64
        14
        15  # Container specific configuration
        16  lxc.include = /etc/lxc/default.conf
        17  lxc.idmap = u 0 1000000000 65536
        18  lxc.idmap = g 0 1000000000 65536
        19  lxc.rootfs.path = dir:/home/notoles/.local/share/lxc/alpine/rootfs
        20  lxc.uts.name = alpine
        21
        22  # Network configuration
        23  lxc.net.0.ipv4.address = 192.168.188.10/24
        24  lxc.net.0.ipv4.gateway = auto
        25  lxc.net.0.ipv6.address = 2602:fba1:999:1c00:10::/64
        26  lxc.net.0.ipv6.gateway = auto
    fmt:~$ lxc-stop -n alpine
    fmt:~$ lxc-start -n alpine
    fmt:~$ lxc-attach -n alpine
    / # ping -4 -c 2 google.com
    PING google.com (142.251.32.46): 56 data bytes
    ping: sendto: Network unreachable
    / # ping -6 -c 2 google.com
    PING google.com (2607:f8b0:4005:811::200e): 56 data bytes
    64 bytes from 2607:f8b0:4005:811::200e: seq=0 ttl=119 time=1.602 ms
    64 bytes from 2607:f8b0:4005:811::200e: seq=1 ttl=119 time=1.561 ms
    
    --- google.com ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 1.561/1.581/1.602 ms
    / # / # ip link show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    2: eth0@if35: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP qlen 1000
        link/ether 00:16:3e:24:60:3e brd ff:ff:ff:ff:ff:ff
    / # ip address show
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host 
           valid_lft forever preferred_lft forever
    2: eth0@if35: <BROADCAST,MULTICAST,UP,LOWER_UP,M-DOWN> mtu 1500 qdisc noqueue state UP qlen 1000
        link/ether 00:16:3e:24:60:3e brd ff:ff:ff:ff:ff:ff
        inet6 2602:fba1:999:1c00:10::/64 scope global 
           valid_lft forever preferred_lft forever
        inet6 fe80::216:3eff:fe24:603e/64 scope link 
           valid_lft forever preferred_lft forever
    / # ip address add 192.168.188.10/24 dev eth0
    / # ip route add 192.168.188.1 dev eth0
    / # ip route add default via 192.168.188.1 dev eth0
    / # ping -4 -c 2 google.com
    PING google.com (142.251.46.238): 56 data bytes
    64 bytes from 142.251.46.238: seq=0 ttl=119 time=1.552 ms
    64 bytes from 142.251.46.238: seq=1 ttl=119 time=1.534 ms
    
    --- google.com ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 1.534/1.543/1.552 ms
    / # wget -qO- ipv4.icanhazip.com
    23.134.88.227
    / # vi ipv4-up.sh
    / # cat -n ipv4-up.sh 
         1  ip address add 192.168.188.10/24 dev eth0
         2  ip route add 192.168.188.1 dev eth0
         3  ip route add default via 192.168.188.1 dev eth0
    / # 
    
  • @terrorgen said:
    Does the lack of systemd in Alpine contribute to this?

    Yes, systemd won't start in LXC container due to lack of cgroups.

    See my test report:
    https://lowendspirit.com/discussion/comment/125271/#Comment_125271
    Look at lxc.init.cmd line under "these are typed by user".

    We accept Karma donations for the last flan. 🍮 affbrr

  • @yoursunny said:

    @terrorgen said:
    Does the lack of systemd in Alpine contribute to this?

    Yes, systemd won't start in LXC container due to lack of cgroups.

    See my test report:
    https://lowendspirit.com/discussion/comment/125271/#Comment_125271
    Look at lxc.init.cmd line under "these are typed by user".

    Hi @yoursunny! We were talking about setting your container quantity in /etc/lxc/lxc-usernet. Is it time to raise your quantity now? I forget how many you wanted, so can you remind me, please? Thanks!

  • @terrorgen said: I tried downloading a standard debian and Ubuntu templates but was unsuccessful as well.

    Sorry to hear. I should try these as well. Do you have any info about what went wrong? Any error messages? Thanks!

  • @Not_Oles said: There are some small differences between my procedure and @subenhon's procedure. In particular, I don't understand why @subenhon seemed to get working autoconfigured IPv4 out of the box and I perhaps didn't.

    @Not_Oles I change the network type from dhcp to manual when attach to the container , maybe you missed this part.

    ~ $# change container root password and network setting from dhcp to manual
    ~ $ lxc-attach -n alpine
    / # passwd
    Changing password for root
    New password:
    Retype password:
    passwd: password for root changed by root

    alpine:~# cat /etc/network/interfaces
    auto eth0
    iface eth0 inet manual
    hostname $(hostname)
    
  • edited February 2023

    @yoursunny said:

    @terrorgen said:
    Does the lack of systemd in Alpine contribute to this?

    Yes, systemd won't start in LXC container due to lack of cgroups.

    According to https://wiki.alpinelinux.org/wiki/LXC, cgroup can be enabled with rc-update add cgroups

    Worth a try, @Not_Oles?

    DM us for private tracker invite.

  • Hi again! Here are some shenanigans with Debian. :)

    fmt:~$ pwd
    /home/notoles
    fmt:~$ whoami
    notoles
    fmt:~$ lxc-create -n debian -f $HOME/.config/lxc/default.conf -t download -- --dist debia
    n --release sid --arch amd64
    ../src/lxc/cmd/lxc_usernsexec.c: 64: opentty - Permission denied - Failed to open tty
    ../src/lxc/cmd/lxc_usernsexec.c: 64: opentty - Permission denied - Failed to open tty
    ../src/lxc/cmd/lxc_usernsexec.c: 64: opentty - Permission denied - Failed to open tty
    Downloading the image index
    Downloading the rootfs
    Downloading the metadata
    The image cache is now ready
    Unpacking the rootfs
    
    ---
    You just created a Debian sid amd64 (20230220_05:24) container.
    
    To enable SSH, run: apt install openssh-server
    No default root or user password are set by LXC.
    fmt:~$ echo -e "lxc.net.0.ipv4.address = 192.168.188.11/24\nlxc.net.0.ipv4.gateway = auto
    > " >> $HOME/.local/share/lxc/debian/config
    fmt:~$ echo -e "lxc.net.0.ipv6.address = 2602:fba1:999:1c00:11::/64\nlxc.net.0.ipv6.gatew
    > ay = auto" >> $HOME/.local/share/lxc/debian/config
    fmt:~$ cat -n $HOME/.local/share/lxc/debian/config
         1  # Template used to create this container: /usr/share/lxc/templates/lxc-download
         2  # Parameters passed to the template: --dist debian --release sid --arch amd64
         3  # For additional config options, please look at lxc.container.conf(5)
         4
         5  # Uncomment the following line to support nesting containers:
         6  #lxc.include = /usr/share/lxc/config/nesting.conf
         7  # (Be aware this has security implications)
         8
         9
        10  # Distribution configuration
        11  lxc.include = /usr/share/lxc/config/common.conf
        12  lxc.include = /usr/share/lxc/config/userns.conf
        13  lxc.arch = linux64
        14
        15  # Container specific configuration
        16  lxc.include = /etc/lxc/default.conf
        17  lxc.idmap = u 0 1000000000 65536
        18  lxc.idmap = g 0 1000000000 65536
        19  lxc.rootfs.path = dir:/home/notoles/.local/share/lxc/debian/rootfs
        20  lxc.uts.name = debian
        21
        22  # Network configuration
        23  lxc.net.0.ipv4.address = 192.168.188.11/24
        24  lxc.net.0.ipv4.gateway = 192.168.188.1
        25
        26  lxc.net.0.ipv6.address = 2602:fba1:999:1c00:11::/64
        27  lxc.net.0.ipv6.gateway = 2602:fba1:999:1c00:11::
    fmt:~$ lxc-start -F -n debian
    Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...
    fmt:~$ # https://lowendspirit.com/discussion/comment/125271/#Comment_125271
    fmt:~/.local/share/lxc/debian$ echo lxc.init.cmd = /bin/bash >> config 
    fmt:~/.local/share/lxc/debian$ cd
    fmt:~$ lxc-start -F debian
    root@debian:/# cat /etc/resolv.conf
    cat: /etc/resolv.conf: No such file or directory
    root@debian:/# ping -c 2 google.com
    ping: google.com: Temporary failure in name resolution
    root@debian:/# cd etc
    root@debian:/etc# ls -l 
    total 392
      [ . . . ]
    lrwxrwxrwx 1 root root      37 Feb 20 05:29 resolv.conf -> /run/systemd/resolve/stub-resolv.conf
      [ . . . ]
    root@debian:/etc# rm resolv.conf 
    root@debian:/etc# echo -e "nameserver 1.1.1.1\nnameserver 2001:470:20::2\n" >> /etc/resolv.conf
    root@debian:/etc# cd /root
    root@debian:/root# ping -c 2 google.com
    PING google.com(sfo03s32-in-x0e.1e100.net (2607:f8b0:4005:814::200e)) 56 data bytes
    64 bytes from sfo03s32-in-x0e.1e100.net (2607:f8b0:4005:814::200e): icmp_seq=1 ttl=117 time=66.0 ms
    64 bytes from sfo03s32-in-x0e.1e100.net (2607:f8b0:4005:814::200e): icmp_seq=2 ttl=117 time=1.82 ms
    
    --- google.com ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1002ms
    rtt min/avg/max/mdev = 1.816/33.907/65.998/32.091 ms
    root@debian:/root# ping -4 -c 2 google.com
    PING  (142.251.32.46) 56(84) bytes of data.
    64 bytes from sfo03s26-in-f14.1e100.net (142.251.32.46): icmp_seq=1 ttl=119 time=1.64 ms
    64 bytes from sfo03s26-in-f14.1e100.net (142.251.32.46): icmp_seq=2 ttl=119 time=1.32 ms
    
    ---  ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1001ms
    rtt min/avg/max/mdev = 1.318/1.478/1.638/0.160 ms
    root@debian:/root# exit
    exit
    fmt:~$ lxc-stop -n debian
    lxc-stop: debian: ../src/lxc/tools/lxc_stop.c: main: 168 debian is not running
    fmt:~$ 
    
  • Hi @terrorgen!

    @terrorgen said: According to https://wiki.alpinelinux.org/wiki/LXC, cgroup can be enabled with rc-update add cgroups

    Worth a try, @Not_Oles?

    Already done, I think. Please take a look at the seond to last entry under Default runlevel.

    fmt:~$ rc-status -a 
    Runlevel: nonetwork
    Runlevel: sysinit
     devfs                                                                      [  started  ]
     dmesg                                                                      [  started  ]
     mdev                                                                       [  started  ]
     hwdrivers                                                                  [  started  ]
    Runlevel: default
     vnstatd                                                                    [  started  ]
     nix-daemon                                                                 [  started  ]
     acpid                                                                      [  started  ]
     crond                                                                      [  started  ]
     sshd                                                                       [  started  ]
     cgroups                                                                    [  started  ]    <== Here! 
     chronyd                                                                    [  started  ]
    Runlevel: boot
     modules                                                                    [  started  ]
     hwclock                                                                    [  started  ]
     swap                                                                       [  started  ]
     utmp-prepare                                                               [  started  ]
     sysctl                                                                     [  started  ]
     bootmisc                                                                   [  started  ]
     utmpd                                                                      [  started  ]
     seedrng                                                                    [  started  ]
     btmpd                                                                      [  started  ]
     loadkmap                                                                   [  started  ]
     wtmpd                                                                      [  started  ]
     utmp-init                                                                  [  started  ]
     hostname                                                                   [  started  ]
     syslog                                                                     [  started  ]
     networking                                                                 [  started  ]
    Runlevel: shutdown
     killprocs                                                                  [  stopped  ]
     savecache                                                                  [  stopped  ]
     mount-ro                                                                   [  stopped  ]
    Dynamic Runlevel: hotplugged
    Dynamic Runlevel: needed/wanted
     sysfs                                                                      [  started  ]
     fsck                                                                       [  started  ]
     root                                                                       [  started  ]
     localmount                                                                 [  started  ]
    Dynamic Runlevel: manual
    fmt:~$ 
    
  • Not_OlesNot_Oles Provider
    edited February 2023

    It looks like I can get a persistent Debian container by using tmux.

    fmt:~$ tmux
    fmt:~$ lxc-start -F -n debian
    root@debian:/# 
    

    Inside the container, enter Ctrl-b followed by d to detach from the container and return to the host while leaving the container running.

    On the host, enter "tmux attach" to reattach to the container which is still running inside tmux.

    To stop the container from inside the container (which is inside tmux), enter "exit." To close tmux, enter "exit" again.

  • Looks like bash is PID1 in your container?

    DM us for private tracker invite.

  • Btw, FMT not pingable from my end.

    DM us for private tracker invite.

  • @subenhon said: @Not_Oles I change the network type from dhcp to manual when attach to the container , maybe you missed this part.

    Yup. Thanks for the reminder! Much appreciated! <3

  • @terrorgen said:
    Btw, FMT not pingable from my end.

    Yeah, work in the datacenter. Downtime was not expected. But it nevertheless seems to have arrived.

    You can check

  • @terrorgen said:
    Looks like bash is PID1 in your container?

    Yeah, I think so, as a way to fix certain errors noted above which are, for easy reference, repeated here:

    fmt:~$ lxc-start -F -n debian
    Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...
    fmt:~$ # https://lowendspirit.com/discussion/comment/125271/#Comment_125271
    fmt:~/.local/share/lxc/debian$ echo lxc.init.cmd = /bin/bash >> config 
    fmt:~/.local/share/lxc/debian$ cd
    fmt:~$ lxc-start -F -n debian
    root@debian:/# 
    

    Now the questions are (1) why did the errors happen, and (2) can we find a configuration that prevents them from happening?

  • @Not_Oles said:
    Hi @yoursunny! We were talking about setting your container quantity in /etc/lxc/lxc-usernet. Is it time to raise your quantity now? I forget how many you wanted, so can you remind me, please? Thanks!

    I typically configure "100" in lxc-usernet so it's never a limitation.
    There's really no need to place a limit here, because a user can have practically any number of containers by making creating nested containers that isn't subject to this limit.

    We accept Karma donations for the last flan. 🍮 affbrr

  • edited February 2023

    @Not_Oles said:

    @terrorgen said:
    Looks like bash is PID1 in your container?

    Yeah, I think so, as a way to fix certain errors noted above which are, for easy reference, repeated here:

    fmt:~$ lxc-start -F -n debian
    Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...
    fmt:~$ # https://lowendspirit.com/discussion/comment/125271/#Comment_125271
    fmt:~/.local/share/lxc/debian$ echo lxc.init.cmd = /bin/bash >> config 
    fmt:~/.local/share/lxc/debian$ cd
    fmt:~$ lxc-start -F -n debian
    root@debian:/# 
    

    Now the questions are (1) why did the errors happen, and (2) can we find a configuration that prevents them from happening?

    I got similar errors on my NixOS container about autofs and cgroup and PID1 refusing to proceed further. Looks like a systemd issue now.

    DM us for private tracker invite.

  • Oh just found this from https://wiki.alpinelinux.org/wiki/LXD:

    If you plan to run systemd based Linux distributions (Debian, Ubuntu, etc.), add this to /etc/conf.d/lxc:

    systemd_container=yes
    and enable both lxc and lxd to start at boot:

     rc-update add lxc
     rc-update add lxd
     rc-update add lxcfs
    

    If you have problems, try to enable dbus:

    rc-update add dbus
    Reboot and lxd should be working.

    DM us for private tracker invite.

  • HI! The server seems to be back up, and services are restarted. If anybody has any issues, please let me know. Thanks! :)

    root@debian:/# date -u                                                                  
    Tue Feb 21 22:23:21 UTC 2023
    root@debian:/# ping6 -c 2 google.com
    PING google.com(nuq04s43-in-x0e.1e100.net (2607:f8b0:4005:810::200e)) 56 data bytes
    64 bytes from nuq04s43-in-x0e.1e100.net (2607:f8b0:4005:810::200e): icmp_seq=1 ttl=119 time=59.7 ms
    64 bytes from nuq04s43-in-x0e.1e100.net (2607:f8b0:4005:810::200e): icmp_seq=2 ttl=119 time=1.76 ms
    
    --- google.com ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1001ms
    rtt min/avg/max/mdev = 1.757/30.729/59.702/28.972 ms
    root@debian:/# ping -4 -c 2 google.com
    PING  (142.251.46.238) 56(84) bytes of data.
    64 bytes from sfo03s27-in-f14.1e100.net (142.251.46.238): icmp_seq=1 ttl=119 time=1.53 ms
    64 bytes from sfo03s27-in-f14.1e100.net (142.251.46.238): icmp_seq=2 ttl=119 time=1.61 ms
    
    ---  ping statistics ---
    2 packets transmitted, 2 received, 0% packet loss, time 1002ms
    rtt min/avg/max/mdev = 1.534/1.572/1.610/0.038 ms
    root@debian:/# 
    
  • Inside LXC Container Described Above

    root@debian:/# curl -sL yabs.sh | bash
    # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
    #              Yet-Another-Bench-Script              #
    #                     v2022-12-29                    #
    # https://github.com/masonr/yet-another-bench-script #
    # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
    
    Tue Feb 21 22:43:59 UTC 2023
    
    Basic System Information:
    ---------------------------------
    Uptime     : 0 days, 9 hours, 44 minutes
    Processor  : Intel(R) Xeon(R) CPU E5-2630L v2 @ 2.40GHz
    CPU cores  : 24 @ 1837.301 MHz
    AES-NI     : ✔ Enabled
    VM-x/AMD-V : ✔ Enabled
    RAM        : 62.8 GiB
    Swap       : 4.0 GiB
    Disk       : 453.3 GiB
    Distro     : Debian GNU/Linux bookworm/sid
    Kernel     : 6.1.12-0-lts
    
    fio Disk Speed Tests (Mixed R/W 50/50):
    ---------------------------------
    Block Size | 4k            (IOPS) | 64k           (IOPS)
      ------   | ---            ----  | ----           ---- 
    Read       | 71.81 MB/s   (17.9k) | 119.56 MB/s   (1.8k)
    Write      | 72.00 MB/s   (18.0k) | 120.19 MB/s   (1.8k)
    Total      | 143.82 MB/s  (35.9k) | 239.75 MB/s   (3.7k)
               |                      |                     
    Block Size | 512k          (IOPS) | 1m            (IOPS)
      ------   | ---            ----  | ----           ---- 
    Read       | 119.06 MB/s    (232) | 129.29 MB/s    (126)
    Write      | 125.39 MB/s    (244) | 137.90 MB/s    (134)
    Total      | 244.46 MB/s    (476) | 267.20 MB/s    (260)
    
    iperf3 Network Speed Tests (IPv4):
    ---------------------------------
    Provider        | Location (Link)           | Send Speed      | Recv Speed      | Ping           
    -----           | -----                     | ----            | ----            | ----           
    Clouvider       | London, UK (10G)          | 854 Mbits/sec   | 210 Mbits/sec   | 143 ms         
    Scaleway        | Paris, FR (10G)           | busy            | busy            | 142 ms         
    NovoServe       | North Holland, NL (40G)   | 651 Mbits/sec   | 544 Mbits/sec   | 137 ms         
    Uztelecom       | Tashkent, UZ (10G)        | busy            | 43.2 Mbits/sec  | 244 ms         
    Clouvider       | NYC, NY, US (10G)         | 713 Mbits/sec   | 124 Mbits/sec   | 70.4 ms        
    Clouvider       | Dallas, TX, US (10G)      | 627 Mbits/sec   | 633 Mbits/sec   | 41.8 ms        
    Clouvider       | Los Angeles, CA, US (10G) | 785 Mbits/sec   | 645 Mbits/sec   | 26.9 ms        
    
    iperf3 Network Speed Tests (IPv6):
    ---------------------------------
    Provider        | Location (Link)           | Send Speed      | Recv Speed      | Ping           
    -----           | -----                     | ----            | ----            | ----           
    Clouvider       | London, UK (10G)          | 845 Mbits/sec   | 297 Mbits/sec   | 130 ms         
    Scaleway        | Paris, FR (10G)           | busy            | busy            | 141 ms         
    NovoServe       | North Holland, NL (40G)   | 836 Mbits/sec   | 586 Mbits/sec   | 136 ms         
    Uztelecom       | Tashkent, UZ (10G)        | 722 Mbits/sec   | 242 Mbits/sec   | 220 ms         
    Clouvider       | NYC, NY, US (10G)         | 888 Mbits/sec   | 613 Mbits/sec   | 69.9 ms        
    Clouvider       | Dallas, TX, US (10G)      | 920 Mbits/sec   | 795 Mbits/sec   | 41.9 ms        
    Clouvider       | Los Angeles, CA, US (10G) | 933 Mbits/sec   | 902 Mbits/sec   | 11.1 ms  
    
    Geekbench 5 Benchmark Test:
    ---------------------------------
    Test            | Value                         
                    |                               
    Single Core     | 561                           
    Multi Core      | 7252                          
    Full Test       | https://browser.geekbench.com/v5/cpu/20708994
    
    YABS completed in 12 min 37 sec
    root@debian:/# 
    

    On The Bare Metal Server Node

    fmt:~# curl -sL yabs.sh | bash
    # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
    #              Yet-Another-Bench-Script              #
    #                     v2022-12-29                    #
    # https://github.com/masonr/yet-another-bench-script #
    # ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## ## #
    
    Tue Feb 21 23:00:46 UTC 2023
    bash: line 29: locale: command not found
    
    Warning: locale 'C' not detected. Test outputs may not be parsed correctly.
    
    Basic System Information:
    ---------------------------------
    Uptime     : 0 days, 10 hours, 1 minutes
    Processor  : Intel(R) Xeon(R) CPU E5-2630L v2 @ 2.40GHz
    CPU cores  : 24 @ 1800.000 MHz
    AES-NI     : ✔ Enabled
    VM-x/AMD-V : ✔ Enabled
    RAM        : 62.8 GiB
    Swap       : 4.0 GiB
    Disk       : 
    Distro     : Alpine Linux edge
    Kernel     : 6.1.12-0-lts
    
    fio Disk Speed Tests (Mixed R/W 50/50):
    ---------------------------------
    Block Size | 4k            (IOPS) | 64k           (IOPS)
      ------   | ---            ----  | ----           ---- 
    Read       | 71.90 MB/s   (17.9k) | 119.49 MB/s   (1.8k)
    Write      | 72.09 MB/s   (18.0k) | 120.12 MB/s   (1.8k)
    Total      | 143.99 MB/s  (35.9k) | 239.61 MB/s   (3.7k)
               |                      |                     
    Block Size | 512k          (IOPS) | 1m            (IOPS)
      ------   | ---            ----  | ----           ---- 
    Read       | 119.04 MB/s    (232) | 129.66 MB/s    (126)
    Write      | 125.37 MB/s    (244) | 138.29 MB/s    (135)
    Total      | 244.42 MB/s    (476) | 267.95 MB/s    (261)
    
    iperf3 Network Speed Tests (IPv4):
    ---------------------------------
    Provider        | Location (Link)           | Send Speed      | Recv Speed      | Ping           
    -----           | -----                     | ----            | ----            | ----           
    Clouvider       | London, UK (10G)          | 333 Mbits/sec   | 188 Mbits/sec   | 131.566 ms     
    Scaleway        | Paris, FR (10G)           | busy            | 446 Mbits/sec   | 142.122 ms     
    NovoServe       | North Holland, NL (40G)   | 231 Mbits/sec   | 554 Mbits/sec   | 136.405 ms     
    Uztelecom       | Tashkent, UZ (10G)        | 698 Mbits/sec   | 149 Mbits/sec   | 220.116 ms     
    Clouvider       | NYC, NY, US (10G)         | 327 Mbits/sec   | 266 Mbits/sec   | 70.053 ms      
    Clouvider       | Dallas, TX, US (10G)      | busy            | 613 Mbits/sec   | 41.824 ms      
    Clouvider       | Los Angeles, CA, US (10G) | 672 Mbits/sec   | 793 Mbits/sec   | 11.033 ms      
    
    iperf3 Network Speed Tests (IPv6):
    ---------------------------------
    Provider        | Location (Link)           | Send Speed      | Recv Speed      | Ping           
    -----           | -----                     | ----            | ----            | ----           
    Clouvider       | London, UK (10G)          | 829 Mbits/sec   | 309 Mbits/sec   | 131.664 ms     
    Scaleway        | Paris, FR (10G)           | 838 Mbits/sec   | 307 Mbits/sec   | 136.759 ms     
    NovoServe       | North Holland, NL (40G)   | 837 Mbits/sec   | 585 Mbits/sec   | 136.204 ms     
    Uztelecom       | Tashkent, UZ (10G)        | 644 Mbits/sec   | 276 Mbits/sec   | 219.915 ms     
    Clouvider       | NYC, NY, US (10G)         | 888 Mbits/sec   | 681 Mbits/sec   | 69.913 ms      
    Clouvider       | Dallas, TX, US (10G)      | 907 Mbits/sec   | 709 Mbits/sec   | 41.799 ms      
    Clouvider       | Los Angeles, CA, US (10G) | 831 Mbits/sec   | 922 Mbits/sec   | 11.090 ms      
    
    Geekbench 5 test failed. Run manually to determine cause.
    
    YABS completed in 7 min 35 sec
    fmt:~# 
    
    fmt:~/Geekbench-5.4.6-Linux# ./geekbench_x86_64 
    Geekbench 5.4.6 Tryout : https://www.geekbench.com/
      [ . . . ]
    Running Gathering system information
    Segmentation fault
    fmt:~/Geekbench-5.4.6-Linux# 
    
  • I would also love to try one of the accounts. Thank you!!

  • Hi @superyuluo!

    Welcome to LES! I hope you enjoy your time here!

    Since you have a new account, I am sure that everyone here would enjoy meeting you. Would you please introduce yourself? Please tell us

    • who and where you are,

    • about your Linux experience, and

    • what you plan to do on the server.

    Also, to give you an account, we need your ed25519 ssh public key. Would you please post your key or a link to it?

    I am looking forward to having you join us on the server!

    Best!

    Tom

  • edited February 2023

    Looks like I am still not able to start my container.

    @terrorgen said:
    Oh just found this from https://wiki.alpinelinux.org/wiki/LXD:

    If you plan to run systemd based Linux distributions (Debian, Ubuntu, etc.), add this to /etc/conf.d/lxc:

    systemd_container=yes
    and enable both lxc and lxd to start at boot:

     rc-update add lxc
     rc-update add lxd
     rc-update add lxcfs
    

    If you have problems, try to enable dbus:

    rc-update add dbus
    Reboot and lxd should be working.

    @Not_Oles you'll have to do this ☺️

    DM us for private tracker invite.

  • Not_OlesNot_Oles Provider
    edited February 2023

    Edited. . . .

  • @terrorgen Please note 12, 13, and 14.

    fmt:~# apk update
    fetch http://mirror.fcix.net/alpine/edge/main/x86_64/APKINDEX.tar.gz
    fetch http://mirror.fcix.net/alpine/edge/community/x86_64/APKINDEX.tar.gz
    fetch http://mirror.fcix.net/alpine/edge/testing/x86_64/APKINDEX.tar.gz
    v20230208-1191-g04298fc7839 [http://mirror.fcix.net/alpine/edge/main]
    v20230208-1191-g04298fc7839 [http://mirror.fcix.net/alpine/edge/community]
    v20230208-1191-g04298fc7839 [http://mirror.fcix.net/alpine/edge/testing]
    OK: 25150 distinct packages available
    fmt:~# apk upgrade
    (1/21) Upgrading ncurses-terminfo-base (6.4_p20230211-r0 -> 6.4_p20230218-r3)
    (2/21) Installing libncursesw (6.4_p20230218-r3)
    (3/21) Upgrading libcurl (7.88.0-r1 -> 7.88.1-r1)
    (4/21) Upgrading curl (7.88.0-r1 -> 7.88.1-r1)
    (5/21) Upgrading curl-doc (7.88.0-r1 -> 7.88.1-r1)
    (6/21) Upgrading device-mapper-libs (2.03.18-r0 -> 2.03.19-r0)
    (7/21) Installing libpanelw (6.4_p20230218-r3)
    (8/21) Upgrading gdb (12.1-r4 -> 13.1-r2)
    (9/21) Upgrading gdb-doc (12.1-r4 -> 13.1-r2)
    (10/21) Upgrading linux-headers (6.1.11-r0 -> 6.2-r0)
    (11/21) Upgrading tar (1.34-r1 -> 1.34-r2)
    (12/21) Upgrading nix (2.12.0-r0 -> 2.13.2-r0)
    (13/21) Upgrading nix-openrc (2.12.0-r0 -> 2.13.2-r0)
    (14/21) Upgrading nix-doc (2.12.0-r0 -> 2.13.2-r0)
    (15/21) Upgrading tar-doc (1.34-r1 -> 1.34-r2)
    (16/21) Upgrading keyutils-libs (1.6.3-r1 -> 1.6.3-r2)
    (17/21) Upgrading xxd (9.0.1313-r1 -> 9.0.1337-r0)
    (18/21) Upgrading vim (9.0.1313-r1 -> 9.0.1337-r0)
    (19/21) Upgrading vim-doc (9.0.1313-r1 -> 9.0.1337-r0)
    (20/21) Upgrading harfbuzz (7.0.0-r1 -> 7.0.1-r0)
    (21/21) Purging ncurses-libs (6.4_p20230211-r0)
    Executing busybox-1.36.0-r4.trigger
    Executing mandoc-apropos-1.14.6-r6.trigger
    OK: 1332 MiB in 360 packages
    fmt:~# 
    
  • Not_OlesNot_Oles Provider
    edited February 2023

    @terrorgen said:
    Looks like I am still not able to start my container.

    @terrorgen said:
    Oh just found this from https://wiki.alpinelinux.org/wiki/LXD:

    If you plan to run systemd based Linux distributions (Debian, Ubuntu, etc.), add this to /etc/conf.d/lxc:

    systemd_container=yes
    and enable both lxc and lxd to start at boot:

     rc-update add lxc
     rc-update add lxd
     rc-update add lxcfs
    

    If you have problems, try to enable dbus:

    rc-update add dbus
    Reboot and lxd should be working.

    @Not_Oles you'll have to do this ☺️

    I'm not sure this is right, because we don't even have installed either the LXD package or the lxc command (which is part of LXD and not part of LXC). We do have the lxc and lxcfs packages installed, but they do not include the lxc command.

    fmt:~# apk info lxd
    lxd-5.0.2-r3 description:
    A container hypervisor and a new user experience for LXC - 'LTS' release channel
    
    lxd-5.0.2-r3 webpage:
    https://linuxcontainers.org/lxd/
    
    lxd-5.0.2-r3 installed size:
    43 MiB
    
    fmt:~# apk -e info lxd 
    fmt:~#                                # No output here means it's not installed.
    

    I tried commenting out bash and adding a line about systemd to my /home/notoles Debian LXC config.

    ~/.local/share/lxc/debian $ cat config
    # Template used to create this container: /usr/share/lxc/templates/lxc-download
    # Parameters passed to the template: --dist debian --release sid --arch amd64
    # 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.include = /usr/share/lxc/config/userns.conf
    lxc.arch = linux64
    
    # Container specific configuration
    lxc.include = /etc/lxc/default.conf
    lxc.idmap = u 0 1000000000 65536
    lxc.idmap = g 0 1000000000 65536
    lxc.rootfs.path = dir:/home/notoles/.local/share/lxc/debian/rootfs
    lxc.uts.name = debian
    
    # Network configuration
    lxc.net.0.ipv4.address = 192.168.188.11/24
    lxc.net.0.ipv4.gateway = 192.168.188.1
    
    lxc.net.0.ipv6.address = 2602:fba1:999:1c00:11::/64
    lxc.net.0.ipv6.gateway = 2602:fba1:999:1c00::
    # lxc.init.cmd = /bin/bash
    systemd_container=yes
    ~/.local/share/lxc/debian $ 
    

    The result was these errors:

    fmt:~$ lxc-start -F -n debian
    Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...
    fmt:~$ 
    

    If there is no way to get Alpine's LXC without LXD to run an unprivileged container for a systemd OS, then, yes, maybe we should install LXD.

    I looked at https://wiki.alpinelinux.org/wiki/LXC. This page suggests stopping and disabling systemd-networkd inside a privileged container:

    lxc-attach -n bullseye
    systemctl stop systemd-networkd
    systemctl disable systemd-networkd
    reboot
    

    I will check to see if starting the unprivileged container with bash and then stopping/disabling systemd-networkd is enough to get an unprivileged Debian container to start in the usual way, without setting PID 1 as bash.

    By the way, where / how did you get your nix LXC image? Nix doesn't seem to be on the linuxcontainers.org image server.

  • @yoursunny seems pretty sure that systemd won't work inside the LXC containers:

    @yoursunny said: systemd in the container will not work, so the entry process is changed to bash.

    @terrorgen Did you try changing the entry process to bash for your nix container?

    Do you guys understand how/why making unprivileged containers with LXD as explained in https://wiki.alpinelinux.org/wiki/LXD could enable systemd to work inside those containers when getting systemd working might not be possible inside unprivileged containers made with lxc-create? What's the difference between LXD's lxc command and LXC's lxc-create command that allows systemd to work with unprivileged LXD containers but not with unprivileged LXC containers?

  • edited February 2023

    @Not_Oles said: I'm not sure this is right, because we don't even have installed either the LXD package or the lxc command (which is part of LXD and not part of LXC). We do have the lxc and lxcfs packages installed, but they do not include the lxc command.

    But /etc/conf.d/lxc does exist, so it may not have to do with LXD.

    @Not_Oles said: @terrorgen Did you try changing the entry process to bash for your nix container?

    That won't work. NixOS is heavily dependant on systemd to get things working. Also, LXC "boots" the container by starting /sbin/init inside the container. In a NixOS container this is actually a generated bash script, which among other things contains the system configuration that will be activated at "boot". My init script is throwing errors because it cannot find a proper sys mount.

    @Not_Oles said: What's the difference between LXD's lxc command and LXC's lxc-create

    My understanding is, LXD's lxc command is a higher level management tool that abstracts away the lower level configuration of lxc-*. It can also manage VMs. I don't claim to be an expert for either, though.

    @Not_Oles said: By the way, where / how did you get your nix LXC image?

    Found a guide that downloads the rootfs tarball from NixOS's own repository. NixOS developers decided against publishing them to linuxcontainers.org because it seems counterintuitive.

    I personally have a NixOS LXC container running in my homelab Proxmox server, so I know it can be done.

    DM us for private tracker invite.

  • So it just clicked that most of my problems (besides cgroup delegation) is permissions:

    ❯ lxc-start nixos -F
    lxc-start: nixos: ../src/lxc/utils.c: safe_mount: 1220 Resource busy - Failed to mount "sys" onto "/usr/lib/lxc/rootfs/dev/.lxc/sys"
    
    <<< NixOS Stage 2 >>>
    
    install: cannot change permissions of '/tmp': Operation not permitted
    running activation script...
    ln: failed to create symbolic link '/bin/.sh.tmp': Permission denied
    mv: cannot stat '/bin/.sh.tmp': No such file or directory
    Activation script snippet 'binsh' failed (1)
    install: cannot change permissions of '/root': Operation not permitted
    mkdir /var/lib: Permission denied at /nix/store/snb4523ghvw9917q15j401fz26d5plh3-update-users-groups.pl line 17.
    Activation script snippet 'users' failed (13)
    setting up /etc...
    Died at /nix/store/rg5rf512szdxmnj9qal3wfdnpfsx38qi-setup-etc.pl line 27.
    Activation script snippet 'etc' failed (13)
    /nix/store/8ndxpvlgfjbbas506vqrad69rzjzxwsp-nixos-system-nixos-23.05pre452927.6ccc4a59c3f/activate: line 129: /etc/shadow: No such file or directory
    Activation script snippet 'hashes' failed (1)
    ln: failed to create symbolic link '/sbin/init': Permission denied
    Activation script snippet 'installInitScript' failed (1)
    install: cannot create directory '/nix/var': Permission denied
    install: cannot create directory '/nix/var': Permission denied
    /nix/store/8ndxpvlgfjbbas506vqrad69rzjzxwsp-nixos-system-nixos-23.05pre452927.6ccc4a59c3f/activate: line 167: /root/.nix-channels: Permission denied
    Activation script snippet 'nix' failed (1)
    mkdir: cannot create directory '/usr/bin': Permission denied
    ln: failed to create symbolic link '/usr/bin/.env.tmp': No such file or directory
    mv: cannot stat '/usr/bin/.env.tmp': No such file or directory
    Activation script snippet 'usrbinenv' failed (1)
    mkdir: cannot create directory '/var/tmp': Permission denied
    mkdir: cannot create directory '/var/empty': Permission denied
    find: '/var/empty': No such file or directory
    chmod: cannot access '/var/empty': No such file or directory
    chown: invalid user: 'root:root'
    Activation script snippet 'var' failed (1)
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:messagebus'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    chown: invalid user: 'root:root'
    Activation script snippet 'wrappers' failed (1)
    mkdir: cannot create directory '/nix/var': Permission denied
    ln: failed to create symbolic link '/nix/var/nix/gcroots/current-system': No such file or directory
    cp: cannot create regular file '/etc/nixos/configuration.nix': Permission denied
    terminate called after throwing an instance of 'nix::Error'
      what():  error: cannot determine user's home directory
    /nix/store/l411104qj58cq7f1gg2wiryi0lzly5jk-local-cmds: line 17:   132 Aborted                 /nix/store/nnznavnhyli08264apz6lanbjza48si1-nix-2.13.2/bin/nix-store --load-db < /nix-path-registration
    terminate called after throwing an instance of 'nix::Error'
      what():  error: cannot determine user's home directory
    /nix/store/l411104qj58cq7f1gg2wiryi0lzly5jk-local-cmds: line 20:   133 Aborted                 /nix/store/nnznavnhyli08264apz6lanbjza48si1-nix-2.13.2/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
    unpacking the NixOS/Nixpkgs sources...
    mkdir: cannot create directory '/nix/var': Permission denied
    terminate called after throwing an instance of 'nix::Error'
      what():  error: cannot determine user's home directory
    /nix/store/l411104qj58cq7f1gg2wiryi0lzly5jk-local-cmds: line 32:   135 Aborted                 /nix/store/nnznavnhyli08264apz6lanbjza48si1-nix-2.13.2/bin/nix-env -p /nix/var/nix/profiles/per-user/root/channels -i /nix/store/70hcm36cm9v6wwvl224w2zvxvshrh1ff-nixos-23.05pre452927.6ccc4a59c3f --quiet --option build-use-substitutes false
    mkdir: cannot create directory '/root/.nix-defexpr': Permission denied
    ln: failed to create symbolic link '/root/.nix-defexpr/channels': No such file or directory
    mkdir: cannot create directory '/var/lib': Permission denied
    touch: cannot touch '/var/lib/nixos/did-channel-init': No such file or directory
    /sbin/init: line 130: /etc/machine-id: Permission denied
    starting systemd...
    Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...
    

    Comparing notes between my homelab NixOS container vs MetalVPS's...

    rootfs permission in my homelab is set to uid:100000 and gid:100000, which maps to root:root in the container.

    Whereas my rootfs' permission in MetalVPS is set to my uid:gid.
    so I did a tweak in my config file:

    lxc.idmap = u 0 1015 1
    lxc.idmap = g 0 1015 1
    lxc.idmap = u 1 1015000000 65535
    lxc.idmap = g 1 1015000000 65535
    

    so the container root is myself in MetalVPS.

    solved most of the permission issues above.

    now this is how it looks like:

    ❯ lxc-start nixos -F
    lxc-start: nixos: ../src/lxc/utils.c: safe_mount: 1220 Resource busy - Failed to mount "sys" onto "/usr/lib/lxc/rootfs/dev/.lxc/sys"
    
    <<< NixOS Stage 2 >>>
    
    running activation script...
    setting up /etc...
    starting systemd...
    Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...
    

    DM us for private tracker invite.

  • @terrorgen said: So it just clicked that most of my problems (besides cgroup delegation) is permissions

    I did a tweak in my config file:

    lxc.idmap = u 0 1015 1
    lxc.idmap = g 0 1015 1
    lxc.idmap = u 1 1015000000 65535
    lxc.idmap = g 1 1015000000 65535
    so the container root is myself in MetalVPS.

    Congrats on figuring out the permissions issues!

    @terrorgen said: Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...

    Looks just like the errors I am seeing when starting a Debian container:

    @Not_Oles said:
    fmt:~$ lxc-start -F -n debian
    Failed to find module 'autofs4'
    Failed to mount cgroup at /sys/fs/cgroup/systemd: Operation not permitted
    [!!!!!!] Failed to mount API filesystems.
    Exiting PID 1...
    fmt:~$

    @terrorgen I will look at this some more, including your suggested changes to the node configuration and raising the number of containers permission limit.

    Now that you fixed your user permissions, might starting with bash as PID 1 work? And be helpful?

  • @Not_Oles said: Now that you fixed your user permissions, might starting with bash as PID 1 work?

    it may boot successfully but because systemd is heavily relied upon by NixOS, it won't be any useful.

    @Not_Oles said: And be helpful?

    I am sorry if I am not being helpful.

    DM us for private tracker invite.

  • @terrorgen said: @Not_Oles said: And be helpful?

    I am sorry if I am not being helpful.

    You are always very helpful!

    I meant: "Now that you fixed your user permissions, might starting with bash as PID 1 work? And be helpful to you?" :)

  • @terrorgen said:
    Oh just found this from https://wiki.alpinelinux.org/wiki/LXD:

    If you plan to run systemd based Linux distributions (Debian, Ubuntu, etc.), add this to /etc/conf.d/lxc:

    systemd_container=yes
    and enable both lxc and lxd to start at boot:

     rc-update add lxc
     rc-update add lxd
     rc-update add lxcfs
    

    If you have problems, try to enable dbus:

    rc-update add dbus
    Reboot and lxd should be working.

    fmt:~# date 
    Thu Feb 23 00:35:42 UTC 2023
    fmt:~# cat /etc/conf.d/lxc
    # Configuration for /etc/init.d/lxc[.*]
    
    # Enable cgroup for systemd-based containers.
    #systemd_container=no
    systemd_container=yes
    
    # autostart groups (comma separated)
    #lxc_group="onboot"
    
    # Directory for containers' logs (used for symlinked runscripts lxc.*).
    #logdir="/var/log/lxc"
    fmt:~# 
    
    fmt:~# rc-update add lxc
     * service lxc added to runlevel default
    fmt:~# rc-update add lxd
     * rc-update: service `lxd' does not exist
    fmt:~# rc-update add lxcfs
     * service lxcfs added to runlevel default
    fmt:~# rc-update add dbus
     * rc-update: service `dbus' does not exist
    fmt:~# 
    

    Do we need to apk add lxd and apk add dbus plus enable both before rebooting, or is it worth while to try just adding lxc and lxcfs to runlevel default?

  • Not_OlesNot_Oles Provider
    edited February 2023

    Okay, at the link you posted @stgraber says:

    Basically you’d need root to crate you a /sys/fs/cgroup/user.doskanoness cgroup or something similar, then chown it over to you and move your shell’s PID into it.

    At that point, lxc-start should be able to detect that and since you now own that cgroup, will be able to create its own entries in there for the container.

    I'd want to read about making cgroups, but it looks like we could do it. Do you want to go ahead with cgroups, or stay awhile longer on the present path? Should we (1) go ahead and reboot, (2) add lxd and dbus and then reboot, (3) revert the changes I just made to /etc/conf.d/lxc and the rc scripts, (4) work on the cgroups, or (5) some combination? :)

  • Cgroup comparison between fmt (Alpine) and ex100 (Debian sid):

    fmt:/sys/fs/cgroup# ls
    blkio       cpuacct     devices     hugetlb     net_cls     openrc      pids
    cpu         cpuset      freezer     memory      net_prio    perf_event  unified
    fmt:/sys/fs/cgroup# 
    
    root@sid /sys/fs/cgroup # ls
    cgroup.controllers      cpu.pressure           io.cost.qos       proc-sys-fs-binfmt_misc.mount
    cgroup.max.depth        cpuset.cpus.effective  io.pressure       sys-fs-fuse-connections.mount
    cgroup.max.descendants  cpuset.mems.effective  io.stat           sys-kernel-config.mount
    cgroup.pressure         cpu.stat               memory.numa_stat  sys-kernel-debug.mount
    cgroup.procs            dev-hugepages.mount    memory.pressure   sys-kernel-tracing.mount
    cgroup.stat             dev-mqueue.mount       memory.reclaim    system.slice
    cgroup.subtree_control  init.scope             memory.stat       user.slice
    cgroup.threads          io.cost.model          misc.capacity
    root@sid /sys/fs/cgroup # 
    
  • Let's go ahead and reboot and see if it works! If it doesn't after the reboot, we'll try something else :)

    DM us for private tracker invite.

  • Hi @terrorgen!

    Reboot:

    fmt:~# date | tee reboot-time
    Thu Feb 23 16:53:45 UTC 2023
    fmt:~# reboot
    

    Following the reboot:

    fmt:~$ lxc-start -n debian -F
    Failed to find module 'autofs4'
    systemd 252.5-2 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
    Detected virtualization lxc.
    Detected architecture x86-64.
    
    Welcome to Debian GNU/Linux bookworm/sid!
    
    Initializing machine ID from random generator.
    Failed to create /init.scope control group: Permission denied
    Failed to allocate manager object: Permission denied
    [!!!!!!] Failed to allocate manager object.
    Exiting PID 1...
    fmt:~$ 
    
  • We got progress!
    same error message here.

    ~ terrorgen@fmt
    ❯ lxc-start nixos -F
    lxc-start: nixos: ../src/lxc/utils.c: safe_mount: 1220 Resource busy - Failed to mount "sys" onto "/usr/lib/lxc/rootfs/dev/.lxc/sys"
    
    <<< NixOS Stage 2 >>>
    
    running activation script...
    setting up /etc...
    starting systemd...
    Failed to find module 'autofs4'
    systemd 252.4 running in system mode (+PAM +AUDIT -SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT -QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD +BPF_FRAMEWORK -XKBCOMMON +UTMP -SYSVINIT default-hierarchy=unified)
    Detected virtualization lxc.
    Detected architecture x86-64.
    
    Welcome to NixOS 23.05 (Stoat)!
    
    Failed to create /init.scope control group: Permission denied
    Failed to allocate manager object: Permission denied
    [!!!!!!] Failed to allocate manager object.
    Exiting PID 1...
    
    ~ terrorgen@fmt
    ❯
    

    DM us for private tracker invite.

  • Welp, for whatever it's worth:

    Unpriviliged container wont start - Failed to allocate manager object

    Same errors in Arch Linux:

    Failed to create /init.scope control group: Permission denied
    Failed to allocate manager object: Permission denied
    [!!!!!!] Failed to allocate manager object.
    Exiting PID 1...
    

    Solution proposed as:

    OK - I figured it out after stepping away from it and trying fresh this morning. I had an issue in my /etc/pam.d/system-login file. I fixed the cgfs line to read like this:

    session optional pam_cgfs.so -c freezer,memory,name=systemd,unified

    Here is our /etc/pam.d/system-login:

    fmt:~# cat -n /etc/pam.d/system-login
         1  #%PAM-1.0
         2
         3  auth       required   pam_faillock.so      preauth
         4  auth       required   pam_shells.so
         5  auth       requisite  pam_nologin.so
         6  auth       include    base-auth
         7  auth       [default=die] pam_faillock.so   authfail
         8  auth       required   pam_faillock.so      authsucc
         9
        10
        11  account    required   pam_access.so
        12  account    required   pam_nologin.so
        13  account    include    base-auth
        14
        15  password   include    base-auth
        16
        17  session    include    base-auth
        18  session    include    base-session
        19  session    optional   pam_loginuid.so
        20  session    optional   pam_motd.so          motd=/etc/motd
        21  session    optional   pam_mail.so          dir=/var/mail standard quiet
        22  -session   optional   pam_ck_connector.so  nox11
        23  session    required   pam_env.so
    fmt:~# 
    

    We don't have a pam_cgfs line in our /etc/pam.d/system-login.

    I found a Debian libpam-cgfs package and a Github repo for pam_cgfs.c which seems to be part of LXC. Apparently, Alpine might not have the separate package.

    fmt:~# apk search libpam-cgfs
    fmt:~# 
    

    Maybe I could try adding the suggested pam_cgfs line, but I don't understand it enough yet. Ideas?

  • Worth a shot.

    DM us for private tracker invite.

  • @terrorgen said:
    Worth a shot.

    I tried adding the suggested line to /etc/pam.d/system-login and then rebooting.

    That addition produced these errors, which seem to be the same:

    fmt:~$ lxc-start -n debian -F
    Failed to find module 'autofs4'
    systemd 252.5-2 running in system mode (+PAM +AUDIT +SELINUX +APPARMOR +IMA +SMACK +SECCOMP +GCRYPT -GNUTLS +OPENSSL +ACL +BLKID +CURL +ELFUTILS +FIDO2 +IDN2 -IDN +IPTC +KMOD +LIBCRYPTSETUP +LIBFDISK +PCRE2 -PWQUALITY +P11KIT +QRENCODE +TPM2 +BZIP2 +LZ4 +XZ +ZLIB +ZSTD -BPF_FRAMEWORK -XKBCOMMON +UTMP +SYSVINIT default-hierarchy=unified)
    Detected virtualization lxc.
    Detected architecture x86-64.
    
    Welcome to Debian GNU/Linux bookworm/sid!
    
    Failed to create /init.scope control group: Permission denied
    Failed to allocate manager object: Permission denied
    [!!!!!!] Failed to allocate manager object.
    Exiting PID 1...
    fmt:~$ 
    

    So I reverted the change and rebooted. Restarted the networking and ndpresponder. :)

  • I logged in and nobody was around. So. . . . :)

    fmt:~# apk update
    fetch http://mirror.fcix.net/alpine/edge/main/x86_64/APKINDEX.tar.gz
    fetch http://mirror.fcix.net/alpine/edge/community/x86_64/APKINDEX.tar.gz
    fetch http://mirror.fcix.net/alpine/edge/testing/x86_64/APKINDEX.tar.gz
    v20230208-1434-g480cc47561e [http://mirror.fcix.net/alpine/edge/main]
    v20230208-1455-g29db802ccd8 [http://mirror.fcix.net/alpine/edge/community]
    v20230208-1454-ge4e3135b82a [http://mirror.fcix.net/alpine/edge/testing]
    OK: 25183 distinct packages available
    fmt:~# apk upgrade
    (1/15) Upgrading libmagic (5.44-r0 -> 5.44-r2)
    (2/15) Upgrading file (5.44-r0 -> 5.44-r2)
    (3/15) Upgrading libblkid (2.38.1-r4 -> 2.38.1-r5)
    (4/15) Upgrading libuuid (2.38.1-r4 -> 2.38.1-r5)
    (5/15) Upgrading file-doc (5.44-r0 -> 5.44-r2)
    (6/15) Upgrading sqlite-libs (3.40.1-r0 -> 3.41.0-r0)
    (7/15) Upgrading linux-lts (6.1.12-r0 -> 6.1.13-r0)
    (8/15) Upgrading linux-lts-doc (6.1.12-r0 -> 6.1.13-r0)
    (9/15) Upgrading shadow-libs (4.13-r1 -> 4.13-r2)
    (10/15) Upgrading shadow-subids (4.13-r1 -> 4.13-r2)
    (11/15) Upgrading nasm (2.16.01-r0 -> 2.16.01-r1)
    (12/15) Upgrading nasm-doc (2.16.01-r0 -> 2.16.01-r1)
    (13/15) Upgrading blkid (2.38.1-r4 -> 2.38.1-r5)
    (14/15) Upgrading libmount (2.38.1-r4 -> 2.38.1-r5)
    (15/15) Upgrading glib (2.74.5-r0 -> 2.74.6-r0)
    Executing busybox-1.36.0-r4.trigger
    Executing kmod-30-r1.trigger
    Executing mkinitfs-3.7.0-r3.trigger
    ==> initramfs: creating /boot/initramfs-lts
    Executing mandoc-apropos-1.14.6-r6.trigger
    Executing syslinux-6.04_pre1-r11.trigger
    /boot is device /dev/sdc1
    OK: 1332 MiB in 360 packages
    fmt:~# uname -r
    6.1.12-0-lts
    fmt:~# reboot
    
    fmt:~# date -u
    Sat Feb 25 02:19:33 UTC 2023
    fmt:~# uname -r
    6.1.13-0-lts
    fmt:~# 
    
    fmt:~$ lxc-start -n alpine
    fmt:~$ lxc-attach -n alpine
    / # ping -c 2 -4 icanhazip.com
    PING icanhazip.com (104.18.114.97): 56 data bytes
    64 bytes from 104.18.114.97: seq=0 ttl=59 time=1.653 ms
    64 bytes from 104.18.114.97: seq=1 ttl=59 time=1.680 ms
    
    --- icanhazip.com ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 1.653/1.666/1.680 ms
    / # ping -c 2 -6 icanhazip.com
    PING icanhazip.com (2606:4700::6812:7361): 56 data bytes
    64 bytes from 2606:4700::6812:7361: seq=0 ttl=59 time=1.268 ms
    64 bytes from 2606:4700::6812:7361: seq=1 ttl=59 time=1.304 ms
    
    --- icanhazip.com ping statistics ---
    2 packets transmitted, 2 packets received, 0% packet loss
    round-trip min/avg/max = 1.268/1.286/1.304 ms
    / # 
    
Sign In or Register to comment.