Skip to main content

Say Goodbye to Offline Installation Nightmares: Advantech Unlocks the Mysterious Power of Ubuntu Package Management

· loading
Author
Advantech ESS

Imagine being in an industrial site, a remote location, or a production line with extremely high-security requirements, where there’s no internet connection. When you need to install a new application or update existing software on a device running Ubuntu, you discover that essential packages (dependencies) are missing… Doesn’t this sound like a digital world version of “a clever housewife cannot cook without rice”?

In the field of Industrial PCs (IPC), deploying equipment in isolated production environments is commonplace, and network connectivity is often a luxury. In such situations, what do you do if you want to install an application in this environment, and it depends on packages not present in the system?

You might think of using a CD-ROM for installation, but CDs have limited capacity and cannot contain all packages, and many modern IPCs don’t even have CD drives anymore. Alternatively, you could download packages from a computer with internet access and then copy them over one by one. But here’s the problem: which packages do you need? What are their complex dependency relationships? Handling these manually is simply a nightmare!

Don’t worry! Advantech’s engineers also encountered this challenge and, leveraging their ingenuity, found a solution that is both clever and practical!

Our Source of Inspiration: Turning an ISO File into Your “Portable Package Library”!

Modern Linux systems (including Ubuntu) have a great feature: they can mount an ISO image file as a local folder. This gave us an idea: if that’s the case, can we package all the necessary packages into an ISO file, and then mount this ISO file on an offline host, making the system’s package management tools (apt or apt-get) think it’s a “local network package repository”?

The answer is: Yes! And our experiments have proven that this method is very effective!

Next, let’s take a look at how Advantech engineers implemented this “offline package management magic” step by step!

Advantech Lab Revealed: The Birth Journey of the Offline Package Repository

The entire process can be divided into several main stages: Preparation, Creation, Deployment, Usage, and Cleanup. Sounds a bit like a carefully planned mission, right?

Quick Tip: ✍️ If you encounter permission issues when executing commands, remember to add sudo before the command. ✍️ Although relative paths are used in the examples, it is recommended to use absolute paths in actual operations to avoid errors!

Stage One: Prepare Your “Package Collection Station”

First, we need an environment with internet access to collect all the packages that the target host might need. The “cleaner” this environment is, the better, because the resulting ISO file will be smaller. The best practice is to start building from a fresh system. Remember one principle: the cleaner the environment, the smaller the ISO file!

Stage Two: Create Your Exclusive “Offline Package Repository ISO”

This is the most critical step in the entire process! In this environment with internet access, we will “fetch” the required packages and create a special ISO image file.

If you encounter commands not found or errors when executing commands, please install the relevant packages first.

Here are the command steps for creating the ISO:

mkdir -p my-ISO

cd my-ISO
dpkg --get-selections | grep 'install' | awk '{ print $1; }' | xargs apt download
dpkg-scanpackages . | gzip -9c > Packages.gz

mkdir .disk
echo "My Dependencies - $(lsb_release -is) - $(lsb_release -rs)" > .disk/info

mkisofs -V MyDependencies -o MyDependencies.iso -r -J .
  • Line 1: Create an empty folder named my-ISO to store all the packages we collect. The folder name can be decided by yourself.
  • Line 3: Enter the my-ISO folder as our working directory.
  • Line 4: Query all installed packages in the current system and download them to the current folder.
  • Line 5: Generate a special compressed file named Packages.gz. This file is the basis for creating the ISO image file; it contains package index information. The file name can also be decided by yourself.
  • Line 7: Create a folder named .disk (note the dot at the beginning). This folder name is defined by the specification; please do not change it.
  • Line 8: Create an information file named info under the .disk folder. This file name is also defined by the specification; please do not change it.
  • Line 10: Create the final ISO image file, named MyDependencies.iso.
    • -V: Specify the Volume ID (disk volume name or label), which you can name yourself.
    • -o: Specify the output file name, which you can name yourself.
    • -r: Set file permissions and modes to more practical values.
    • -J: In addition to standard ISO9660 filenames, also generate Joliet directory records to support longer filenames.

Stage Three: Migrate the ISO File to the Offline Host

This step is simple: use your familiar method (e.g., USB flash drive, internal network transfer, etc.) to copy the MyDependencies.iso file you just created to the target offline host.

Stage Four: Mount the ISO Image File

Now, on the offline host, we need to “activate” this ISO file so that the system can read its contents.

mkdir -p my-mount-point
mount -o loop MyDependencies.iso my-mount-point
cp -rf my-mount-point my-repo
  • Line 1: Create an empty folder to serve as the mount point for the ISO image file. The folder name my-mount-point can be decided by yourself.
  • Line 2: Mount the MyDependencies.iso image file to the mount point folder just created.
  • Line 3: Copy the entire contents of the mount point folder to a new folder my-repo. Why copy? Because ISO files are usually mounted read-only, and as a local package source repository, we need it to be writable. You can change the target folder name.

Stage Five: Add the Local Folder as a Package Source

Next, we need to tell the system’s package management tool apt where to find our “portable package library”.

First, to be safe, back up the system’s original package source configuration file:

mv -f /etc/apt/sources.list /etc/apt/sources.list.BAK

Then, create a new configuration file pointing to our local package repository:

echo "deb [trusted=yes] file:/full/path/to/my-repo ./" > /etc/apt/sources.list

Please note that /full/path/to/my-repo here needs to be replaced with the full path to the folder where you actually copied the package repository.

Stage Six: Update the System Package Source List

Execute this command to make the system refresh the package source information and recognize our local package repository:

apt update

Stage Seven: Start Installing the Packages You Need!

The moment of truth has arrived! Now, you can use the apt or apt-get command to install all the packages you need, just like in an environment with internet access! The system will automatically search for and resolve all dependencies from the local package repository you just configured, and then complete the installation. If your target application itself can handle dependencies, you can even install the application itself directly, completing the process in one go!

Stage Eight: Cleanup

After the task is completed, it is recommended to restore the system to its original state, remove the local package source configuration we added, and unmount the ISO image file.

mv -f /etc/apt/sources.list.BAK /etc/apt/sources.list
umount my-mount-point
rm -rf my-mount-point
rm -rf my-repo
apt update
  • Line 1: Restore the system’s original package source configuration file.
  • Line 2: Unmount the ISO image file from the operating system.
  • Line 3 and Line 4: Remove the intermediate folders we created.
  • Line 5: Update the system package source list again.

Experimental Results and Application Value

Through this method, we successfully achieved automated package installation and dependency resolution in a completely offline Ubuntu environment. This means:

  • Significantly Simplifies Offline Deployment: No more manual downloading and tracking of complex package dependencies.
  • Improves Efficiency and Reliability: Use apt just like online, making the installation process smoother with fewer errors.
  • Applicable to Various Offline Scenarios: Whether it’s factory automation, energy monitoring, transportation, or any edge computing application with limited network access, software deployment and update needs can be easily met.
  • Showcases Advantech’s Innovation: This is an effective solution independently researched and validated by Advantech engineers to address actual pain points in industrial applications.

Compared to traditional manual methods, this approach not only saves significant time and labor but, more importantly, provides a standardized, reliable process for offline software deployment.

Conclusion and Future Outlook

This experiment successfully demonstrated that even in harsh environments without internet access, we can still leverage clever technical means to make Ubuntu’s package management tools work. This is just a microcosm of Advantech’s efforts in solving Industrial IoT challenges.

We deeply understand that the needs of industrial sites are constantly changing, and technical challenges are endless. Advantech is always committed to deeply understanding customers’ actual application scenarios and investing in continuous R&D to find innovative and reliable solutions. This offline package management method is a testament to our active exploration and continuous progress.

In the future, we will continue to optimize this process and even consider integrating it into our software tools or services, allowing customers to more easily deploy and manage their Advantech equipment and applications in various complex environments.

If you encounter any challenges with software deployment or package management in offline environments, or are interested in this technology, please feel free to contact your Advantech AE or sales representative. We are happy to share more experience and provide professional support!

Related

Bid Farewell to Boot Threats! Advantech Takes You Deep into Secure Boot and the Latest Cybersecurity Protection Technologies
· loading
When the System Blue Screens, How Do Advantech Engineers Find the Truth? A Deep Dive into the Secrets of Memory Dump!
· loading
Data Security Showdown: How Advantech Builds a Solid RAID1 Defense Line on Kylin OS?
· loading