Skip to content

Instantly share code, notes, and snippets.

@valyakuttan
Last active September 7, 2025 14:47
Show Gist options
  • Save valyakuttan/51ed5301242c138bcfad6fc062e357cf to your computer and use it in GitHub Desktop.
Save valyakuttan/51ed5301242c138bcfad6fc062e357cf to your computer and use it in GitHub Desktop.
Configure OneDrive Linux client as a Podman Container in Fedora Silverblue

Configure OneDrive Linux client in Fedora Silverblue

This is a slightly edited version of the original OneDrive Linux client
Podman Container documentation
, adapted to suit the needs of Fedora Atomic desktops.

  1. Create Podman Volumes

    • Prepare the 'config' Volume

    podman volume create onedrive_conf
    
    • Create a config directory for OneDrive

    mkdir -p $HOME/.config/onedrive
    
    cd $HOME/.config/onedrive
    
    • Create a config file in that directory with desired configuration

    # sync_dir
    sync_dir = "/onedrive/data"
    
    # skip_dir configuration
    #
    # skip_dir for rust cargo build
    skip_dir = "target"
    #
    # skip_dir for mdbook
    skip_dir = "book"
    #
    # skip_dir for python cache
    skip_dir = "__pycache__"
    
    
    # skip_file configuaration
    #
    # Default skip items
    skip_file = "~*|.~*|*.tmp|*.swp|*.partial"
    #
    # skip genererated python objects
    skip_file = "*.pyc|*.pyo|*.pyd|*.pyz"
    #
    # skip python class objects
    skip_file = "*$py.class"
    
    • Prepare the 'data' Volume

    podman volume create onedrive_data
    

    This is where your data from Microsoft OneDrive will be stored.

    • The owner of this specified folder must not be root.

    • Podman will attempt to change the permissions of the volume to the user the container is configured to run as.

  2. Run the Container and Perform Authorisation

    • Create the File onedrive.sh, with the Following Contents

    #!/bin/bash
    
    # The root of  OneDrive sync directory can be changed by setting
    # the ONEDRIVE_DATA_DIR variable. Make sure the path exists.
    
    export ONEDRIVE_DATA_DIR="${HOME}/OneDrive"
    
    export ONEDRIVE_CONFIG_DIR="${HOME}/.config/onedrive"
    export ONEDRIVE_CONFIG_FILE="${ONEDRIVE_CONFIG_DIR}/config"
    
    # Useful Podman Environment Variables
    #  --env ONEDRIVE_DRYRUN=1
    #  --env ONEDRIVE_DEBUG=1
    #  --env ONEDRIVE_RESYNC=1
    #  --env ONEDRIVE_DOWNLOADONLY=1
    
    podman run --rm -it \
    --name onedrive \
    --userns=keep-id \
    --volume onedrive_conf:/onedrive/conf:U,Z \
    --volume "${ONEDRIVE_CONFIG_FILE}":/onedrive/conf/config:U,Z \
    --volume "${ONEDRIVE_DATA_DIR}:/onedrive/data:U,Z" \
    --env PODMAN=1 \
    --env ONEDRIVE_VERBOSE=1 \
    --env ONEDRIVE_DISPLAY_CONFIG=1 \
    --env ONEDRIVE_DOWNLOADONLY=1 \
    --env ONEDRIVE_SYNC_ONCE=1 \
    --label "io.containers.autoupdate=registry" \
    docker.io/driveone/onedrive:edge-fedora
    
    • Run the Script and Complete Authorisation by Following the Prompt

    source onedrive.sh
    
  3. Create Quadlets to Manage as a systemd Service

    • Create the directory for quadlets

    mkdir -p $HOME/.config/containers/systemd/onedrive
    
    cd $HOME/.config/containers/systemd/onedrive
    
    • Create the Volume Quadlet onedrive_conf.volume

    [Unit]
    Description=OneDrive Conf Volume
    
    [Volume]
    VolumeName=onedrive_conf
    
    [Install]
    RequiredBy=onedrive.service
    
    • Create the Volume Quadlet onedrive_data.volume

    [Unit]
    Description=OneDrive Data Volume
    
    [Volume]
    VolumeName=onedrive_data
    
    [Install]
    RequiredBy=onedrive.service
    
    • Create the Container Quadlet onedrive.container

    [Unit]
    Description=OneDrive Container
    
    [Container]
    Image=docker.io/driveone/onedrive:edge-fedora
    Volume=onedrive_conf.volume:/onedrive/conf:U,Z
    Volume=${HOME}/.config/onedrive/config:/onedrive/conf/config:U,Z
    Volume=${HOME}/OneDrive:/onedrive/data:U,Z
    Environment=PODMAN=1
    Environment=ONEDRIVE_SYNC_ONCE=1
    AutoUpdate=registry
    UserNS=keep-id
    
    • Check Errors in Generated systemd Unit Files using quadlet

    /usr/libexec/podman/quadlet -user -dryrun
    
  4. Create a systemd timer unit to activate the service

    • Create the systemd user directory if not exists

    mkdir -p $HOME/.config/systemd/user
     
    cd $HOME/.config/systemd/user
    • Create onedrive.timer unit file

    [Unit]
    Description=Run OneDrive Backup Daily
    
    [Timer]
    OnCalendar=daily
    Persistent=true
    RandomizedDelaySec=1h
    
    [Install]
    WantedBy=timers.target
    • Reload the systemd Daemon

    systemctl --user daemon-reload
    
    • Start the systemd timer Unit

    systemctl --user start onedrive.timer
    
    • Check the systemd Unit's status

    systemctl --user status onedrive.timer onedrive.service
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment