🖤1356 days
🩶839 days
  • ollama + open-webui docker compose

    ❯ cat docker-compose.yaml
    services:
      ollama:
        image: ollama/ollama:latest
        container_name: ollama
        restart: always
        ports:
          - "11434:11434"
        environment:
          - "OLLAMA_HOST=0.0.0.0"
          - "OLLAMA_KEEP_ALIVE=120"
        volumes:
          - ollama-local:/root/.ollama
        deploy:
          resources:
            reservations:
              devices:
                - driver: nvidia
                  count: 1
                  capabilities: [gpu]
    
      openWebUI:
        image: ghcr.io/open-webui/open-webui:main
        container_name: open-webui
        restart: always
        depends_on:
          - ollama
        ports:
          - "8080:8080"
        environment:
          - "OLLAMA_BASE_URL=http://ollama:11434"
          - "WEBUI_AUTH=false"
        extra_hosts:
          - "host.docker.internal:host-gateway"
        volumes:
          - open-webui-local:/app/backend/data
    
    
    volumes:
      ollama-local:
        external: true
      open-webui-local:
        external: true
    
    ❯ docker volume create open-webui-local
    ❯ docker volume create ollama-local
    ❯ docker compose up -d

  • sharing zram via NFS

    Apparently, 16GB memory is not enough to compile Firefox using clang with LTO. Since my mini PC has plenty of memory, I decided to create a zram device and share it via NFS.

    ## Fedora - NFS server, 192.168.1.2
    ### create a zram device and format it with ext4 without journaling
    $ cat /etc/mke2fs.conf 
    ... output omitted ...
    [fs_types]
    	ext4 = {
    		features = has_journal,extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file
    	}
    	ext4withoutjournal = {
            	features = extent,huge_file,flex_bg,metadata_csum,metadata_csum_seed,64bit,dir_nlink,extra_isize,orphan_file
    	}
    ... output omitted ...
    
    ### setting zram size as 16Gig
    $ cat /etc/systemd/zram-generator.conf  
    [zram0]
    zram-size = min(ram, 16384)
    compression-algorithm = zstd
    mount-point = /mnt/zram
    
    fs-type = ext4withoutjournal
    options = rw,nosuid,nodev,discard,X-mount.mode=1777
    
    $ sudo ln -s /usr/sbin/mke2fs /usr/sbin/mkfs.ext4withoutjournal
    
    $ ls -alF /usr/sbin/mkfs.ext4withoutjournal 
    lrwxrwxrwx. 1 root root 6 Aug 31 21:33 /usr/sbin/mkfs.ext4withoutjournal -> mke2fs*
    
    ### reboot will disable the default zram swap and /dev/zram0 will now be mounted under /mnt/zram
    
    ### check zram is mounted
    $ mount | grep zram
    /dev/zram0 on /mnt/zram type ext4 (rw,nosuid,nodev,relatime,seclabel,discard)
    
    ### no_root_squash is required for root to write on nfs
    $ cat /etc/exports
    /mnt/zram 192.168.1.0/24(rw,sync,no_root_squash)
    
    ## Gentoo - NFS client, 192.168.1.100
    ### emerge nfs-utils
    $ sudo emerge net-fs/nfs-utils
    
    ### create a mount point and mount the zram
    $ sudo mkdir /mnt/nfs/zram
    $ sudo mount -t nfs 192.168.1.2:/mnt/zram /mnt/nfs/zram
    
    ### check zram is mounted
    $ sudo mount | grep zram
    /dev/zram2 on /var/tmp type ext4 (rw,relatime,discard)
    192.168.1.2:/mnt/zram on /mnt/nfs/zram type nfs4 (rw,relatime,vers=4.2,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.1.100,local_lock=none,addr=192.168.1.2)
    
    ### create a 8Gig swapfile
    $ sudo fallocate -l 8Gib /mnt/nfs/zram/swapfile
    $ sudo chmod 600 /mnt/nfs/zram/swapfile
    
    ### check swapfile is created
    $ ls -alFh /mnt/nfs/zram/swapfile 
    -rw------- 1 root root 8.0G Aug 31 23:48 /mnt/nfs/zram/swapfile
    
    $ sudo mkswap /mnt/nfs/zram/swapfile
    Setting up swapspace version 1, size = 8 GiB (8589930496 bytes)
    no label, UUID=f910bbdf-1ff2-4c20-9bdb-f5f92bd37156
    $ sudo swapon -p 100 /mnt/nfs/zram/swapfile
    
    ### verify swap
    $ sudo swapon --show
    NAME                   TYPE      SIZE   USED PRIO
    /dev/nvme0n1p6         partition   4G 404.9M   -2
    /mnt/nfs/zram/swapfile file        8G     0B  100
    
    ### you can also use /mnt/nfs/zram as portage tmpfs by setting PORTAGE_TMPDIR to utilize the remaining space
    PORTAGE_TMPDIR="/mnt/nfs/zram"

    References:
    https://wiki.gentoo.org/wiki/Zram
    https://www.redhat.com/sysadmin/configure-nfs-linux

  • bash shortcuts

    My favorite bash tips found from stack overflow:

    !^      first argument
    !$      last argument
    !*      all arguments
    !:2     second argument
    
    !:2-3   second to third arguments
    !:2-$   second to last arguments
    !:2*    second to last arguments
    !:2-    second to next to last arguments
    
    !:0     the command
    !!      repeat the previous line

    Examples:

    $ echo a b c d e 
    a b c d e
    $ echo !^
    echo a
    a
    
    $ echo a b c d e 
    a b c d e
    $ echo !:1
    echo a
    a
  • Start Jupyter Notebook on boot

    Simple systemd user unit file for Jupyter notebook

    ❯ cat ~/.config/systemd/user/jupyter-notebook.service 
    [Unit]
    Description=Jupyter Notebook
    
    [Service]
    Type=simple
    PIDFile=/run/jupyter.pid
    ExecStart=/home/user/Notebook/bin/jupyter-notebook
    
    [Install]
    WantedBy=default.target
    
    ❯ systemctl --user enable jupyter-notebook.service 
    Created symlink /home/user/.config/systemd/user/default.target.wants/jupyter-notebook.service → /home/user/.config/systemd/user/jupyter-notebook.service.
    
    ❯ loginctl enable-linger

    Note: Lingering is required to start systemd user sessions on boot

  • Certbot

    Renewing letsencrypt cert using a dns record

    [root@localhost ~]# certbot -d nicewarm.coffee --manual --preferred-challenges dns certonly
    Saving debug log to /var/log/letsencrypt/letsencrypt.log
    Renewing an existing certificate for nicewarm.coffee
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Please deploy a DNS TXT record under the name:
    
    _acme-challenge.nicewarm.coffee.
    
    with the following value:
    
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    
    Before continuing, verify the TXT record has been deployed. Depending on the DNS
    provider, this may take some time, from a few seconds to multiple minutes. You can
    check if it has finished deploying with aid of online tools, such as the Google
    Admin Toolbox: https://toolbox.googleapps.com/apps/dig/#TXT/_acme-challenge.nicewarm.coffee.
    Look for one or more bolded line(s) below the line ';ANSWER'. It should show the
    value(s) you've just added.
    
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    Press Enter to Continue
    
    Successfully received certificate.