Dpkg, the Debian package manger is no doubt one of the most versatile and efficient package managers around, but installing a huge software with slow internet connection or in many offline machines is a real pain.
You can't simply copy the software and double click on the installer file. This is possible with some third party tools like APTonCD etc. etc . But here we are going to do this very easily without any third party tool.
This tutorial is specially for those who want to save every bits of their valuable internet connection or leaving in a slow speed internet area. Also useful to save time and avoid re-downloading packages while installing same software in multiple machines.
KNOW THE RISK
Never try to mix-up packages from different distributions, i.e. install packages from a Ubuntu 12.04 machine in a Ubuntu 14.04 machine, this could very easily break your current installation and recovery from this point is very tedious.
1. make apt-get update more bandwidth efficient
This step is optional, but saves a lot of data during apt-get update, it simply avoids downloading package translation files without any significant loss. It will amazingly speed up the apt-get update process.
Create a text file at
/etc/apt/apt.conf.d/ named 99translations with your favorite text editor,
sudo nano /etc/apt/apt.conf.d/99translations
put the line bellow there
save and exit , now update the repository with apt-get update.
sudo apt-get update
2. Install all the required software
Freshly install nay Debian based distribution of your choice in the online machine, after thet install all the requires software in that machine, with apt-get install , example
sudo apt-get install google-chrome-stable
3. backup the all downloaded deb files
All downloaded package archives i.e. deb files are stored under the /var/cache/apt/archives/ folder, now copy them to an easily removable and portable storage like an external hard drive or a USB pen drive. Copy them manually or use the commands bellow. Suppose a USB pen drive is mounted at /media/usb_drive/ .
cp -r /var/cache/apt/archives/*.deb /media/usb_drive/
4. install the softwares on the offline machines
To install all the softwares on other machines, insert the USB pen drive on that machine, mount it with a file manager or with command line, install them with dpkg. Suppose the USB drive is mounted at /media/usb_drive/ on the offline machine.
sudo apt-get update update cd /media/usb_drive/ sudo dpkg -i *.deb sudo apt-get install -f
No need of any other command dpkg will handle them, if there is any dependency problem it will be resolved by the sudo apt-get install -f command at last.
note: This will install all the software installed on the first PC, If you want install softwares selectively continue reading .
5. create a backup ISO file
Save the script bellow as deb_backup.sh, make it executable with chmod +x deb_backup.sh and run the script, you are done. You'll get an ISO file named deb_backup_ISO.iso in your home directory, this script will act like aptonCD, i.e. it will backup every thing.
# This script will act like aptonCD, i.e. it will backup every thing # from /var/cache/apt/archives to a folder (in user's home directory '~') and then make an .ISO file # containing the backup files. by:~ https://www.pcsuggest.com #!/bin/bash cd ~ sudo cp -r -u /var/cache/apt/archives/. ~/deb_backup_ISO #copy every thing from the archives folder sudo chown -R $USER:$USER deb_backup_ISO/. genisoimage -o deb_backup_ISO.iso -R -J ~/deb_backup_ISO/ mv -u ./deb_backup_ISO.iso ~/ sudo apt-get clean #cleans the /var/cache/apt/archives directory.
6. restore the backup on other machines
To restore the backup on other machines, copy the generated ISO file to that machine's /home/$USER/ directory i.e. to the home folder, save the script bellow as deb_restore.sh , make it executable with chmod +x deb_restore.sh and run the script.
# This script will load every thing that you have backed up, # in the '/var/cache/apt/archives' folder. by:~ https://www.pcsuggest.com #!/bin/bash cd ~ #taking you in the home directory. sudo mkdir /mnt/load_iso sudo mount -o loop deb_backup_ISO.iso /mnt/load_iso # mounts the iso file. cd /mnt/load_iso # taking you in the mounted directory. sudo cp -r -n ./. /var/cache/apt/archives cd ~ sudo umount /mnt/load_iso # unmount the mounted iso archive. sudo rmdir /mnt/load_iso # deletes the mount point load_iso.
Now update the repository with apt-get update and install any software which was installed before without downloading it again.
sudo apt-get update sudo apt-get install goolge-chrome-stable # example
Hope you now cold save enough data, use this guide to share your previously downloaded packages with your friends and enjoy a faster software installation process. If you need any further assistance, just drop a comment. Feel free to share this tutorial with your friends.