Ubuntu – How to install packages from Ubuntu installation media offline

aptsoftware installation

Ubuntu 18.04 installation media contains dkms and its dependencies in pool directory. But apt doesn't recognize USB flash as a package source.

How can I tell apt to pull packages with dependencies from an installation media connected to a USB port without copying files to cache or manually installing them using dpkg?

Best Answer

  • Offline install of dkms. Not network, install media on USB Stick

    With Bionic Desktop install media, usb stick on /dev/sdb1

    1. Backup /etc/apt/sources.list Mount USB key and create new /etc/apt/sources.list
    2. Install dkms
    3. Revert changes on /etc/apt/sources.list

    Backup sources.list and prepare new source

    sudo cp /etc/apt/sources.list /etc/apt/sources.list.BCK
    sudo touch /etc/apt/sources.list
    if [ ! -d /media/apt ]; then sudo mkdir /media/apt; fi
    sudo mount /dev/sdb1 /media/apt
    sudo apt-cdrom add --cdrom=/media/apt
    sudo apt-get update


    sudo apt-get install dkms

    Revert changes on /etc/apt/sources.list

    sudo umount /dev/sdb2
    sudo rm /etc/apt/sources.list
    sudo mv /etc/apt/sources.list.BCK /etc/apt/sources.list