Making a repository DVD in Ubuntu

In order to take the backup of all the packages I installed in my Ubuntu system, I wanted to make a portable DVD that I can use as a repository having all the packages I downloaded. After reinstalling Ubuntu, I should only insert that CD-ROM and issue the command :

sudo apt-cdrom add

This will automatically install all the packages from the CD-ROM Repository into the system and the best part – It will take care of all the dependencies by itself !! [:)]. But if you try to manually burn all the packages right from where they are stored /var/cache/apt/archives into the removable media, then when you’re reinstalling those packages , it will push you into the dependencies hell, where you will be irritated to death !

So after much googling, I was able to find out the proper way of making a Repository CD in Ubuntu. So here it goes :

1) The first thing you have to do is to become root, because all the below steps will require you to have root privileges.

To become root for this session, issue the following command :

sudo -s -H

2) Next step is to install the package apt-move. It is available in the Universe Repository. Since you’re root already, you won’t have to use sudo anymore. If you are connected to internet, run :

install apt-get apt-move

3) Now change the setting in the configuration file of apt-move located in /etc/apt-move.conf . Open it and look for COPYONLY=no and make it to COPYONLY=yes. You can change more settings in the file as you want it, but in most cases, that won’t be necessary. This change was important because if you miss to do so, then while creating the CD-Repo , it will delete all the packages from /var/cache/apt/archives. And that is not you want. NOTE : Making the above changes will require you to have root privileges. You can use vim or nano from the shell itself.

4) Now this is the time to select all the packages you want to put into your own RepoCD.By default, if you don’t do anything, all the packages inside the folder /var/cache/apt/archives will be archived. But if you want to exclude some of them, then simply delete them from the folder /var/cache/apt/archives . Don’t worry, you can safely delete them. Its just a cache of all the packages. They’re not important anymore as their binaries have already been integrated with your system.

5) Now issue the following commands just as they are :

rm -rf /mirrors/debian

apt-move -d dapper update

cd /mirrors/debian

apt-ftparchive packages pool/main/ | gzip -9c > dists/dapper/main/binary-i386/Packages.gz

apt-ftparchive packages pool/restricted/ | gzip -9c > dists/dapper/restricted/binary-i386/Packages.gz

Now after you’re done with these commands, a folder will be created in your root directory named as mirrors. The copy of the Repo we are going to create will be stored at /mirrors/debian. By issuing the above commands, you have already copied all the packages inside the folder /var/cache/apt/archives into Packages.gz file, stored deep inside the /mirrors/debian .

6) Now its time to make the Release file. To do this, you’ve to make a configuration file named myapt.conf in the /root folder. To do this simply create the file using your existing shell :

touch ~/myapt.conf

Now, put the following contents into the file exactly as it appears :

APT::FTPArchive::Release {

Origin “APT-Move”;

Label “APT-Move”;

Suite “dapper”;

Codename “dapper”;

Architectures “i386”;

Components “main restricted”;

Description “Ubuntu Updates CD”;

};

Now run the following commands :

rm dists/dapper/Release
apt-ftparchive -c ~/myapt.conf release dists/dapper/ > Release
mv Release dists/dapper/

7) Now we need your GPG Key. If you already have your GPG Key set, then SKIP this step and go to next one. For others, follow on.

GPG Key is like a Digital Signature of your own. You can use it to sign whatever you want, like your emails, your transactions,etc. You can later compare the GPG Key and make sure whether the file belongs to you or not. Its like signing a document over the internet digitally. First make sure you have the package ubuntu-keyring installed. If not, then install it.

apt-get install ubuntu-keyring

Now, issue the following command :

gpg –gen-key

Now do as I say it :

Enter 1.

Enter 1024.

Enter 0.

Press y.

Enter your real name.

Enter your real email-address.

Enter any comment.

Enter O.

Enter a Password. (SOMETHING WHICH YOU’LL NEVER FORGET)

Your key will be generated. It will ask you to do something to generate entropy for the random-number-generator. So simply, type anything on keyboard, move your mouse, create & delete a file or folder. Never give your passphrase to anyone. You have 2 type of keys , your secret keys and your public keys. Issue the following commands to list them:

gpg –list-keys

gpg –list-secret-keys

8) Now you have your own GPG Key. Now we need to make the Release.gpg file which is signed by you. Run :

gpg -bao dists/dapper/Release.gpg dists/dapper/Release

rm -rf .apt-move

mkdir .disk

echo Ubuntu-Updates `date +%Y-%m-%d` > .disk/info

gpg –export -a “Your Name” > public.key

exit

Change “Your Name” to your real name. It’s done !

9) Now use any CD Burning software and burn the contents of /mirrors/debian/ into the CD.

10) Now before you can use the CD, you have to issue this command as a root user. Insert the CD and run :

sudo apt-key add /cdrom/public.key

11) Now run the following command to automatically install all the packages :

sudo apt-cdrom add

Thats it folks ! Now you have your own portable Repository CD/DVD having the packages that you downloaded yourself. And you can carry it along and install into whichever Ubuntu system you want. Cheers! 🙂

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s