我要评分
获取效率
正确性
完整性
易理解

Preparations

The Kbox cloud phone container supports kernel source code compilation on Ubuntu 20.04.3 (kernel 5.4.0-81-generic). Before the compilation, configure the network environment, software source, and system time of the server for downloading the related compilation dependencies.

  1. During the compilation, use the root user to log in and perform operations.
  2. Disable the warning "your kernel does not support swap memory limit..."
    1. Open the /etc/default/grub file.
      1
      vim /etc/default/grub
      
    2. Press i to enter the insert mode and change the value of GRUB_CMDLINE_LINUX in the file as follows:
      GRUB_CMDLINE_LINUX="cgroup_enable=memory swapaccount=1"
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  3. Disable SELinux.
    1. Open the /etc/selinux/config file. If the file does not exist, create one and open it.
      1
      vim /etc/selinux/config
      
    2. Press i to enter the insert mode and change the value of SELINUX to disabled.
      SELINUX=disabled
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. When multiple Kbox containers are started, the file access workload is heavy on the host. In this case, adjust the maximum number of inotify instances that can be created.
    1. Open the /etc/sysctl.conf file.
      1
      vim /etc/sysctl.conf
      
    2. Press i to enter the insert mode and specify the value of fs.inotify.max_user_instances.
      fs.inotify.max_user_instances=8192
    3. Press Esc, type :wq!, and press Enter to save the file and exit.
  5. Update boot settings and reboot the OS for the settings to take effect.
    1
    2
    update-grub2
    reboot
    

    You can perform this step after operations in Compiling and Installing the Kernel are completed to make all settings take effect.

  6. Install base dependencies.
    1
    apt install -y build-essential dpkg dpkg-dev libncurses5-dev openssl libssl-dev libpciaccess0 pkg-config bison flex libelf-dev libdrm-amdgpu1 xserver-xorg-video-amdgpu lxc
    

    If a package fails to be obtained during the installation, manually obtain the package based on the address provided in the message and install it. After the installation is successful, continue to install the remaining dependency packages.

  7. Install Docker. If you have installed Docker in customized mode, skip this step.

    Download the Docker static installation package using the link provided in Software Environment. The following uses docker-19.03.15.tgz as an example.

    1. Upload the installation package to the server, for example, to the /root directory of the server, and decompress the package.
      1
      2
      cd ~ 
      tar xvpf docker-19.03.15.tgz
      
    2. After the decompression is complete, a docker folder is generated in the root directory. Copy all the content in the docker folder to the /usr/bin folder.
      1
      cp -p docker/* /usr/bin
      
    3. Run the following commands to configure the docker.service file.
       1
       2
       3
       4
       5
       6
       7
       8
       9
      10
      11
      12
      13
      14
      15
      16
      17
      18
      19
      20
      21
      22
      23
      24
      25
      26
      27
      28
      cat >/usr/lib/systemd/system/docker.service <<EOF
      [Unit]
      Description=Docker Application Container Engine
      Documentation=http://docs.docker.com
      After=network.target docker.socket
      [Service]
      Type=notify
      EnvironmentFile=-/run/flannel/docker
      WorkingDirectory=/usr/local/bin
      ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:4243 -H unix:///var/run/docker.sock --selinux-enabled=false --log-opt max-size=1g
      ExecReload=/bin/kill -s HUP $MAINPID
      # Having non-zero Limit*s causes performance problems due to accounting overhead
      # in the kernel. We recommend using cgroups to do container-local accounting.
      LimitNOFILE=infinity
      LimitNPROC=infinity
      LimitCORE=infinity
      # Uncomment TasksMax if your systemd version supports it.
      # Only systemd 226 and above support this version.
      #TasksMax=infinity
      TimeoutStartSec=0
      # set delegate yes so that systemd does not reset the cgroups of docker containers
      Delegate=yes
      # kill only the docker process, not all processes in the cgroup
      KillMode=process
      Restart=on-failure
      [Install]
      WantedBy=multi-user.target
      EOF
      

      Pay attention to the format of the code copied to the terminal. The following is an example:

    4. Start the Docker service and configure it to start upon system startup.
      1
      2
      3
      systemctl daemon-reload
      systemctl restart docker
      systemctl enable docker
      

      If Docker fails to automatically start upon the server restart, run the preceding commands.

  8. Upgrade linux-firmware. If the firmware has been upgraded, skip this step.

    Download the linux-firmware-20210919.tar.gz package using the link provided in Software Environment.

    Upload the installation package to the server, for example, to the /root directory of the server, and decompress the package.
    1
    2
    cd ~ 
    tar -xvpf linux-firmware-20210919.tar.gz
    
    After the decompression, the linux-firmware-20210919 folder is generated in the root directory. Copy the firmware file to the standard Linux firmware directory.
    1
    cp -ar linux-firmware-20210919/*gpu    /usr/lib/firmware/