Although it may be easier to download a Linux virtual appliance, it can be fun to create linux virtual machines yourself. In particular, we may be interested in creating small footprint Linux virtual machines -- it would be easy to put it on a USB drive or let other people to download it. This post documents the process that I use to create Ubuntu 14.04 (Trusty) Linux virtual machines and reduce the image size of the virtual machines. The key idea is (1) to remove non-essential packages as much as possible; (2) to increase the compression of virtual machine images by zeroing virtual disks; and (3) to compact and compress the virtual machine image.
- Download 32-bit Ubuntu 14.04 (Trusty) ISO file and install it as a guest operating system under VMware Player or VirtualBox.
- To make copy & paste instructions easier, install VMware Tools.
- Install Linux headers and the build essential packages
sudo apt-get install linux-headers-generic build-essential
- Then install VMware Tools
- Restart the virtual machine.
- By default, Ubuntu 14.04 runs the Ubuntu Unity desktop environment. It prevents us from entering the VMware Unity mode. I now get rid of the Ubuntu Unity desktop environment. I learned the command from this post.
sudo apt-get purge \
unity unity-common unity-services \
unity-lens-\* unity-scope-\* unity-webapps-\* \
gnome-control-center-unity \
hud libunity-core-6\* libunity-misc4 \
libunity-webapps\* appmenu-gtk \
appmenu-gtk3 appmenu-qt\* overlay-scrollbar\* \
activity-log-manager-control-center \
firefox-globalmenu thunderbird-globalmenu \
libufe-xidgetter0 xul-ext-unity \
xul-ext-webaccounts webaccounts-extension-common \
xul-ext-websites-integration \
gnome-control-center gnome-session
- Then, install GNOME 3.
sudo apt-get install gnome-session-fallback
-
Now, remove the default games.
sudo apt-get game\* purge ace-of-penguins gnome-mahjongg gnome-mines \
berusky biniax2 gnurobbo groundhog gtkballs hitori \
four-in-a-row gnect gbrainy gnome-sudoku chess\* \
nibbles\* solitaire\* iagno\* klotski\* tetravex\* \
drascula gtkboard oneisenough openyahtzee ri-li \
scribble swell-foop quadrapassel\* lightsoff \
five-or-more gnome-robots gtali
-
Remove a few network applications.
sudo apt-get purge webbrowser-app thunderbird\*
-
Remove Libre Office. This can save a few hundred megabytes.
sudo apt-get purge libreoffice\*
-
Now get rid of the "Ubuntu Software Center".
sudo apt-get purge software-center\*
-
The
/var/cache
directory can easily have a few hundred megabytes data. We can trim it down.
sudo apt-get clean
- Do an
automove
,
sudo apt-get autoremove
-
Now remove GNOME and Ubuntu documentation.
sudo apt-get purge yelp\*
- Now, you can install whatever important software you want to include in the virtual machine, e.g., I am installing Octave,
sudo apt-get install octave
- We would probably want to compress the virtual machine image before we pass it to someone. We need to replace every byte of free space on the disk by 0's.
dd if=/dev/zero of=zerofile; \
sleep 5; sync; \
sleep 5; sync; \
sleep 5; sync; \
rm -f zerofile;
-
I am using VMware Player. Using it, I do a "defragment" and then "compact" the virtual disk. The guest system must be off before you can do it. Of course, you can do the same using VirtualBox.
- Finally, I compress the folder of the virtual machine. The zip archieve file is about 1 GB.
In addition, you may save a few megabytes, by removing all log and temporary files. The tool
bleachbit can help. Before you zero the hard disk, install and run the tool.
sudo apt-get install bleachbit; sudo bleachbit
Thanks for sharing & Its Great information. And Look on right now!
ReplyDeleteCan help you BlogSpot Blog, Sbcglobal email not working on iPhone/Mac/Phone, and Sbcglobal.net not sending and receiving emails| How to Reset My Spotify Password? How to Recover My Spotify Password?