Category: Linux

  • Proxmox Host backup

    Backup the following folders/files:

    /var/lib/pve-cluster/config.db
    /etc/corosync/*
    /etc/network/interfaces
    /etc/hostname
    /etc/hosts

  • KPN / XS4ALL / pfSense IPTV

    (This article is in dutch language because it is only applicable on dutch TV providers)

    Hierbij mijn werkende configuratie voor IPTV met pfSense als router.
    Hierbij is op glasvezelaansluiting een NTU gemonteerd die het optische signaal omzet naar koper/UTP.

    Ik maak gebruik van een Qotom computer die voorzien is van 6 netwerk interfaces (Intell chipset). Daardoor heb ik interfaces Igb0 t/m Igb5 tot mijn beschikking. Daarbij heb ik gekozen om mijn interne IPTV via een apart VLAN te laten lopen. Dit is NIET noodzakelijk. Dit kan namelijk ook gewoon via LAN.
    Als je dat wil doen, zorg dan dat je de firewall rules uit IPTV_LAN overneemt (incl. ip options!) naar je LAN firewall rules.

    Hieronder een reeks screenshots zoals ik het geconfigureerd heb.
    Voor vragen kun je me altijd benaderen via comments onder aan deze pagina. (registreren noodzakelijk i.v.m. spam)

    Interface Assignments

    In mijn configuratie zijn onderstaande aansluitingen van belang:
    Igb0 = WAN (verbonden via UTP-kabel aan de NTU)
    Igb1 = LAN
    Igb3 = IPTV_LAN

    wan Interface details
    lan Interface details
    iptv_wan Interface details
    iptv_lan Interface details
    FiREWALL RULES LAN
    FIRewall rules iptv_Wan

    Let op! Bij de bovenste regel is via Advanced options ‘Allow IP options’ aangevinkt’

    FIRewall rules iptv_LAn

    Let op! Bij de bovenste 2 regels is via Advanced options ‘Allow IP options’ aangevinkt’

    IGMP PROXY
    NAT OUTBOUND

    Set Outbound Nat mode op ‘Hybrid mode’.
    Zorg dat je onderstaande mapping toevoegd. Er zullen ook automatische rules aangemaakt worden.

    EXTRA AANDACHT VOOR:

    • Als je de Settopbox rechtstreeks aansluit op een netwerkaansluiting van pfsense, raakt de pfsense interface disconnected tijdens her-/opstart van de settopbox. De IGMP-Proxy crasht daardoor. Het via een switch aansluiten van van de settop box loste dit probleem op.
  • Proxmox backup already exists

    When you run into this error:

    “TASK ERROR: zfs error: cannot create ‘rpool/vm-302-state-update’: dataset already exists”

    Try this solution:

    zfs destroy rpool/vm-302-state-update
    
  • Proxmox ZFS replace drive

    1: have a look what is there:

    ls -alh /dev/disk/by-id/
    zpool status
    zpool list -v

    2: set the hard drive you want to change offline:

    zpool offline "POOLNAME"  "HARD-DRIVE-ID or the whole path"
    ## example:
    zpool offline rpool wwn-0x50014ee25ba1a5e4

    3: change the hard drives physically
    shutdown and replace the disk (no hot-swap)

    4: create an empty GPT Partition Table on the new hdd with parted:

    parted /dev/new-disk
    (parted)# print
    (parted)# mklabel GPT
    (parted)# Yes
    (parted)# q

    5: replace them in the ZFS Pool:

    zpool replace "POOLNAME" "HARD-DRIVE-ID or the whole path old hard drive"  "HARD-DRIVE-ID or the whole path NEW hard drive"
    ## example:
    zpool replace rpool wwn-0x50014ee25ba1a5e4 wwn-0x5000cca27edf438f

    6: have a look what’s going on:

    zpool status
    ....
    resilver in progress since Sat Feb 29 11:43:52 2020
    328G scanned at 3,77G/s, 75,5G issued at 888M/s, 328G total
      8,83G resilvered, 23,01% done, 0 days 00:04:51 to go
    ....
  • Remove Proxmox 6.x/5.1+ Subscription Notice

    (source: https://johnscs.com/remove-proxmox51-subscription-notice/)

    With the release of Proxmox 5.1 and newer (including 6.2) you’ll find the code related to the no subscription message that pops up on login has changed and prior instructions for removing it wont work.

    To remove “You do not have a valid subscription for this server” run the command bellow. You will need to SSH to your Proxmox machine or use the node console through the PVE web interface.

    If you update your Proxmox server and the update includes a new version of the file we are about to edit then you’ll need to run the command again.

    Run the following one line command and then clear your browser cache (depending on the browser you may need to open a new tab or restart the browser):

    sed -i.bak "s/data.status !== 'Active'/false/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service

    Here are alternative step by step instructions so you can understand what the above command is doing:

    1. Change to working directory
      cd /usr/share/javascript/proxmox-widget-toolkit
    2. Make backup of file
      cp proxmoxlib.js proxmoxlib.js.bak
    3. Edit the file
      nano proxmoxlib.js
    4. Locate this line of code inside the file (use ctrl+w in nano)
      if (data.status !== 'Active') {
    5. Replace it with this
      if (false) {
    6. Restart the Proxmox service (also be sure to clear your browser cache, depending on the browser you may need to open a new tab or restart the browser)
      systemctl restart pveproxy.service
  • How to upgrade kernel to latest version on Ubuntu 20.04 Focal Fossa Linux

    (source: https://linuxconfig.org/how-to-upgrade-kernel-to-latest-version-on-ubuntu-20-04-focal-fossa-linux)

    In this tutorial you will learn:

    • How to install kernel upgrade script utility
    • How to to upgrade kernel to latest version
    • How to uninstall previously installed PPA kernels

    Upgrade kernel to latest version on Ubuntu 20.04 Focal Fossa Linux

    Software Requirements and Conventions Used

    CategoryRequirements, Conventions or Software Version Used
    SystemInstalled Ubuntu 20.04 or upgraded Ubuntu 20.04 Focal Fossa
    Softwareubuntu-mainline-kernel.sh
    OtherPrivileged access to your Linux system as root or via the sudo command.
    Conventions# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
    $ – requires given linux commands to be executed as a regular non-privileged user

    Upgrade kernel to latest version on Ubuntu 20.04 step by step instructions

    1. First step is to download the ubuntu-mainline-kernel.sh Bash script utility. Open up your terminal and enter:
      $ wget https://raw.githubusercontent.com/pimlie/ubuntu-mainline-kernel.sh/master/ubuntu-mainline-kernel.sh
    2. Next, step is to install the previously downloaded script into our executable path:
      $ sudo install ubuntu-mainline-kernel.sh /usr/local/bin/
    3. All is ready to upgrade the Ubuntu kernel to the latest version. To do so run do following command:
      $ ubuntu-mainline-kernel.sh -i

      Finding latest version available on kernel.ubuntu.com Latest version is: v5.4.3, continue? (y/N) The above command will search for the latest kernel version available. To continue with the kernel installation answer y.
    4. Reboot your Ubuntu system and check for the loaded Kernel version:
      $ uname -rs Latest Kernel version upgrade
    5. To uninstall the PPA kernel version execute the following command and follow to wizard:
      $ ubuntu-mainline-kernel.sh -u
  • Install Odoo v13 docker container

    Step by step installation instructions.
    (Thnx to: https://www.cybrosys.com/blog/how-to-install-odoo-13-using-docker)

    Install Ubuntu server 18.04 and run all updates.

    Install docker(Ubuntu 18.04)
    First of all, we have to make sure that every required package is properly installed in the system in order to run the docker:
    # sudo apt install apt-transport-https ca-certificates curl software-properties-common

    Get a GPG key for better maintenance and security:
    # curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

    Get a stable version of the Docker repository:
    # sudo add-apt-repository deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable

    Update the system packages:
    # sudo apt update

    Install Docker(Here, we are installing the community edition)
    # sudo apt install docker-ce

    Add a user to the docker group
    # sudo usermod -aG docker $USER

    Once every mentioned step is complete, you can check whether the Docker is installed properly or not by using a simple hello world command.
    # docker run hello-world

    Install Odoo on docker
    We have successfully installed  Docker on the system. Now we have to install the Odoo image on the docker. A running PostgreSQL should be there in order to run the Odoo image on the docker. So, before going to Odoo image, we have to make sure that a Postgres image runs properly on the docker environment.

    Install Postgres image

    # docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name db postgres:10

    Install Odoo image
    # docker run -p 8069:8069 --name odoo --link db:db -t odoo

    Odoo tries to find the name ‘db’ of the Postgres container. So in order to connect the Odoo with PostgreSQL, the alias of the Postgres container should be ‘db’.You can use your custom conf file in the Odoo container.
    # docker run -v /custom/conf/path:/etc/odoo -p 8069:8069 --name odoo --link db:db -t odoo

    While starting, Odoo will find the custom conf file from the /custom/conf/path.
    # docker run -v /path/to/addons:/mnt/extra-addons -p 8069:8069 --name odoo --link db:db -t odoo

    If you want to include custom addons, use the /mnt/extra-addons volume.
    Set-up a docker-compose.ymlCreate a docker-compose.yml file which contains all the basic information about the Odoo-container and the database container. Here is the simplest one.

    version: '2'
    services:
      web:
        image: odoo:12.0
        depends_on:
          - db
        ports:
          - "8069:8069"
      db:
        image: postgres:10
        environment:
          - POSTGRES_DB=postgres
          - POSTGRES_PASSWORD=odoo
          - POSTGRES_USER=odoo

    You can change the configuration to make as your requirement:* web/image: Version of the Odoo* The default port will be 8069:8069, By changing the first port, you will be able to have multiple Odoo instances simultaneously.* db/image: Version of the Postgres image.

    In case server has been rebooted,
    Restart database, next start docker container
    # docker start /db
    # docker start odoo

    Useful commands:

    Start docker container
    # docker start (container_name)

    Restart docker container
    # docker restart (container_name)

    Stop docker with a container
    # docker stop (container_name)

    To start an Odoo instance. The directory should be the same where the docker-compose.yml file exists
    # docker-compose up -d 
    # docker run -p 8070:8069 --name odoo1 --link db:db -t odoo

    To start multiple Odoo instances at a time, make sure that the PostgreSQL container’s alias name is db. Otherwise, Odoo won’t consider the command. You can have any number of Odoo instances at a time by changing its port.
    # docker run -p 8071:8069 --name odoo2 --link db:db -t odoo

  • Auto reboot after kernel panic

    Auto reboot after kernel panic

    By default after a kernel panic, Linux kernel just waits there for a system administrator to hit the restart or powercycle button.  This is because of the value set on “kernel.panic” parameter.

    [root@linux23 ~]# cat /proc/sys/kernel/panic 
    0
    [root@linux23 ~]# sysctl -a | grep kernel.panic
    kernel.panic = 0

    To disable this and make the Linux OS reboot after a kernel panic, we have to set an integer N greater than zero to the parameter “kernel.panic”, where “N” is the number of seconds to wait before a automatic reboot.

    For example , if you set N = 10 , then the system waits for 10 seconds before automatic reboot. To make this permanent, edit /etc/sysctl.conf and set it.

    [root@linux23 ~]# echo 10 > /proc/sys/kernel/panic
    0
    [root@linux23 ~]# grep kernel.panic /etc/sysctl.conf kernel.panic = 10

    This helps in preventing manual intervention after a kernel panic. Setup some kernel dump or netdump to capture the kernel crash debug information.

  • pfSense – Update Realtek driver v1.95

    Download driver:
    https://forum.netgate.com/assets/uploads/files/1537813753467-if_re.zip
    jselec mirror: http://jselec.nl/wp-content/uploads/2019/01/if_re.zip

    Unzip & Place “if_re.ko” file at “/boot/kernel

    Change ownership and permissions on the if_re.ko file

    chown root:wheel if_re.ko
    chmod 0555 if_re.ko

    Then edit “/boot/loader.conf” to add this line:

    if_re_load="YES"

    Reboot.

    Then go to diagnostics > command prompt in the WebGUI

    Run the command

    kldstat

    If you did everything properly you’ll see “if_re.ko” in the list that comes up. If not, the driver isn’t loaded.

    (i didn’t get it loaded myself. Added the line of code to /boot/defaults/loader.conf Then it worked for me)

  • Proxmox – Add external usb drive to LXC container

    Proxmox – Add external usb drive to LXC container

    How to mount an external USB(3) drive to a LXC container

    In this example we make use of a Western Digital 1TB external USB3 drive.
    This device is NTFS formatted, which is easy to handle in Windows.

    Our container is used for samba services and has ID 102.

    At the host system (Proxmox)

    – Check which device the drive has been given on the host.
    lsblk (in this case ‘sdg’, partition ‘sdg1’)

    – Add a mounting location
    mkdir /mnt/ext-usb

    – Install the ntfs-3g package
    apt-get update && apt-get install ntfs-3g

    – Mount the disk to the mountlocation
    mount -t ntfs-3g /dev/sdg1 /mnt/ext-usb

    AT LXC client (container)

    – Add a mount location inside the LXC container
    mkdir /mnt/ext-usb

    At the host

    – Mount the drive to the container in this example we use mp1 (check if mp1 is not allready used!)
    pct set 102 -mp1 /mnt/ext-usb,mp=/mnt/ext-usb