I recently found myself in a similar situation. I needed a way to get xorg (just xorg, not the full ubuntu-desktop) onto an offline Ubuntu Server. I figured, “Hey, Ubuntu Desktop has it, it must be on the DVD.” Sadly, it turns out the common suggestion to use apt-cdrom
to install packages offline from the Desktop Edition DVD is a bit outdated, or at least unfortunately unspecific. Supposedly (“supposedly” because I haven’t confirmed this for myself yet…) the procedure only works with the Alternate Desktop Edition DVDs (i.e. Kubuntu/Lubuntu/Xubuntu — see here for more information) and not the official Ubuntu Desktop Edition DVD. From what I can gather, the official Desktop DVD images have had the on-disc software repository severely stripped down to reduce filesize since around version 10.04 (or possibly even earlier):
$ sudo mount /dev/cdrom /media/cdrom # ubuntu-14.04.4-server-amd64.iso
$ du -ach /media/cdrom/pool
[…]
461M total
$ sudo umount /dev/cdrom
$ sudo mount /dev/cdrom /media/cdrom # ubuntu-14.04.4-desktop-amd64.iso
$ du -ach /media/cdrom/pool
[…]
5.0M total
Don’t worry, though. If you’re in an area with a limited interenet connection and all you have to work with are the official Desktop and Server DVDs, you are not without recourse. And no, you don’t have to start from a Desktop install and work your way backwards by stripping things out that you don’t need from Desktop and installing stuff you do need from Server. That method works, but it’s quite time consuming. It would be better to start from a Server install and only add those things from the Desktop DVD which you know you need. To do that, you’ll have to rebuild the software repository from the compressed filesystem on the Desktop DVD. Once done, though, you’ll have a fully offline software repository containing most things present in the Desktop Edition of the OS, and should be able to install anything from the Desktop Edition that you might need:
# Comment out everything in sources.list
# For an offline system, it's not needed
$ cp -v /etc/apt/sources.list ./sources.list.orig
$ awk '{print "# " $0}' sources.list.orig >sources.list
# Get dpkg-repack from the Server DVD
# Might as well get build-essential too, while you're at it
$ sudo mount /dev/cdrom /media/cdrom # ubuntu-14.04.4-server-amd64.iso
$ sudo cp -v sources.list /etc/apt/
$ sudo apt-cdrom -d /media/cdrom -m -a --no-auto-detect add
$ sudo apt-get update
$ sudo apt-get -y install build-essential dpkg-repack
$ sudo umount /dev/cdrom
# Mount the compressed filesystem from the Desktop DVD
$ sudo mount /dev/cdrom /media/cdrom # ubuntu-14.04.4-desktop-amd64.iso
$ sudo mkdir /mnt/fs.sfs
$ sudo mount /media/cdrom/casper/filesystem.squashfs /mnt/fs.sfs \
> -t squashfs -o loop
# Create an offline repository from the Desktop DVD
# NOTE: this will take about 30 minutes to complete
$ cd /var/cache/apt/archives
$ sudo chroot /mnt/fs.sfs dpkg --get-selections | awk '{print $1}' | \
> while IFS="" read -r pkg; do
> sudo dpkg-repack --root /mnt/fs.sfs "$pkg"
> done
$ cd -
# Create the offline repository from the collection of DEBs and update apt
$ dpkg-scanpackages /var/cache/apt/archives | gzip -9c >Packages.gz
$ sudo mv -v Packages.gz /var/cache/apt/archives/
$ echo "deb file:/var/cache/apt/archives ./" >>sources.list
$ sudo mv -v sources.list* /etc/apt/
$ sudo apt-get update
Once all that’s done, you should be good-to-go:
$ suto apt-get install xorg
(Replace xorg
with ubuntu-desktop
or whatever else you might need.)
If you ever get internet access later on and want to update any packages, just restore /etc/apt/sources.list.orig
and run apt-get update
to get apt back into an online mode of operation.
Obligatory “A GUI on a Server is Almost Always a Bad Idea™” Warning
Conventional wisdom states that in most cases it is better to not install a GUI on a production server. Several preferable user interface alternatives for managing servers are presented.
— ServerGUI page on the Ubuntu Community Help Wiki
There are some legitimate use-cases for having a GUI on a server, but they’re usually few and far between. Still, depending upon the server, the environment, the intended use-case for the server, etc., it usually does pose an increased security risk (especially if you’re installing outdated stuff from the DVDs rather than using the latest stuff from the online repositories) so it’s good to be aware of the negative consequences to such a configuration. The above link has some good information on the topic, and as the larger discussion is out of the scope of the actual question, I’ll now leave to the reader both the task of doing the proper research, and also the responsibility of making an informed decision one way or the other.
ubuntu-desktop
package would not be present on a server installation. To add it, see the link terdon posted. – fooot Mar 25 '14 at 16:33apt-get update
to refresh the list of available sourced after adding the new CD. – terdon Mar 25 '14 at 19:53sources.list
files so we don't reinvent the wheel – terdon Mar 25 '14 at 20:10