---------------- Installing Linux ---------------- - Ian! D. Allen - idallen@idallen.ca - www.idallen.com You can install Linux natively onto an empty partition on your hard disk caddy, and you can also use VMware to create and install Linux into a virtual machine. I recommend getting experience doing both. To practice installing Linux into a real partition on your caddy, make sure you shrink or reconfigure the data portion of your disk to allow space for a Linux partition (3GB-8GB) and a swap partition (200MB-2000MB), before you fill up your disk caddy with VMware images. A basic Ubuntu installation will just fit into a 3GB partition. Installing Linux natively on a partition ---------------------------------------- When you install Linux directly onto your disk caddy, the installation process will detect the hardware that you have at the time of installation and set up Linux to use that exact hardware (video card, monitor, ethernet card, sound card, etc.). If you move your caddy to a machine that has different hardware, the Linux image may not even boot properly due to the change in hardware. Or, the boot process may cause Linux to reconfigure for some of the new hardware, resulting in an image that won't work when you move the caddy drive back to the original hardware. Some distributions even install processor-specific optimizations at install time, meaning that your caddy can't be moved between Intel and AMD processors! Unless you specifically use a version of Linux that reconfigures itself for new hardware every time you boot it (e.g. a Knoppix live CD), a Linux system installed natively on a partition should always be booted with the same hardware attached. Normal Linux hard-disk installations don't expect to have big hardware changes between reboots. If you run Linux in console mode (no X11 GUI), you can usually boot Linux on any hardware; however, you may have work to do getting the rest of the new hardware to function properly (e.g. getting networking to use different network hardware). Once Linux is installed on disk, it doesn't like to be moved to new hardware. Installing Linux into VMware ---------------------------- When you use VMware Workstation to install Linux into a VMware virtual machine, you can move that virtual machine to another computer that runs VMware (either Workstation or Player) and run your Linux virtual machine in that VMware environment without modifications. The identical VMware virtual environment allows your virtual Linux machine to work anywhere. The VMware virtual Linux machine install is the method described here. We may have time to do a real hard-disk partition Linux install later in the course. Make sure you re-partition or reconfigure the data portion of your disk to allow space for future Linux partitions, before you fill up your disk with VMware images. You also can do the repartitioning later. Prepare: Update and Upgrade --------------------------- 1. Update your "host" O/S: If you are going to use VMware under Windows, first install all the essential Windows O/S updates and patches (e.g. via Microsoft Update). Update your Microsoft Windows O/S system first. If you are going to use VMware under some other host O/S (e.g. Mac or some other version of Linux), also make sure that host O/S is fully patched. 2. Update VMware itself: After updating your host O/S, start VMware Workstation and use the "Help" menu item to "Check for Update". If necessary, download and update to the latest version of VMware Workstation. The only VMware-approved way to do this is to connect and download directly from the www.vmware.com download site. For a faster download if you are on-campus at Algonquin, a more recent (but possibly not the most recent) copy of VMware Workstation may be available locally under this FTP directory: ftp://10.50.14.200/idallen/ This FTP site is temporary and may or may not always be available. It is only useful on-campus at Algonquin College. Start: Fetch the Ubuntu installation CD --------------------------------------- Fetch the Ubuntu 7.10 (gutsy gibbon) Desktop install CD ISO image onto your local disk. The image takes 725MB. At Algonquin, you can usually fetch a local copy of the ISO from one of these local locations: http://10.50.254.148/distributions/Ubuntu/ubuntu-7.10-desktop-i386.iso ftp://10.50.14.200/idallen/ubuntu-7.10-desktop-i386.iso If you use FTP, make sure your FTP transfer is done in BINARY mode, not TEXT mode! Verify the MD5 checksum of the image: d2334dbba7313e9abc8c7c072d2af09c ubuntu-7.10-desktop-i386.iso Put the ISO image somewhere that it can stay for the duration of the course. You may need to re-use the image to re-image your system if things go wrong. Creating the Ubuntu Virtual Machine ----------------------------------- Start the latest version of VMware Workstation 6.0.2. (You did update VMware to the 6.0.2 version, didn't you?) Select File | New | Virtual Machine (CTRL-N) Select Next Select Typical Select Next Select Linux Select Ubuntu Select Next Type a Name: ubuntu01 Type a Location: - your WinXP caddy already points to the data partition at D:\VM's\ Select Next Network type: NAT or Bridged ---------------------------- Before chosing a network type, read the Class Notes file: vmware_networking.txt Select Use bridged networking (preferred) -OR- Use network address translation (NAT) and then Select: Next. You can always change the networking type later. Virtual Disk Size ----------------- Choose the maximum size for your virtual disk. 8GB is fine. - the minimal space needed for a small Ubuntu install is 4GB. Decide whether to create the whole disk at once (improves performance). Decide whether to chop the disk into 2GB segments (not necessary). Select Finish. Success ------- VMware should say "Virtual Machine Created Successfully". Read the "Virtual Machine Created" screen carefully; make notes on what you have to do next. Skim the Guest Operating System Installation Guide for Ubuntu 7.x. Select Close. Edit Settings ------------- Select: Edit virtual machine settings Select: Device: Memory - Increase the Memory from 512MB if you have enough memory installed. Don't go above the blue triangle. In the T108 Lab, the machines have 3GB of RAM, so you can go up to 2GB if you want all the memory allocated to one virtual machine. If you want to run more than one virtual machine at the same time, keep each machine's memory use low. Make sure you don't use so much memory that WinXP starts to swap. Select: +Add... - Select DVD/CD-ROM Drive - Select Next - Select Use ISO image - Select Next - Type: the path to your Ubuntu Desktop ISO image that you downloaded above - or use the Browse button to find and open the Ubuntu Desktop ISO image that you downloaded, above - Select Finish. We don't want the CDROM ISO image to be the first CDROM (0:0); we want the *real* CDROM drive to be first. We must modify the CDROM ISO to be the last CDROM (1:1) so that it is only chosen if all the previous devices fail to boot properly. Thus, the first time we boot, it should be from the Ubuntu Desktop CDROM ISO. Modify the CDROM ISO as follows: Select: Device: CD-ROM (IDE 0:0) Using file ... - Select Advanced - Select IDE: 1:1 (was 0:0) - Select OK. Select Save/OK to save the edited virtual machine settings. Verify the virtual machine settings under the "Devices" heading of the "Summary" page, or select "VM | Settings (CTRL-D)" to bring up a list: Memory 512MB (or more) Processors 1 Hard Disk (SCSI 0:0) 8.0GB CD-ROM (IDE 1:0) Auto detect CD-ROM (IDE 1:1) Using file ... Floppy Auto detect Ethernet NAT or Bridged USB Controller Present Sound Adapter Auto detect Display Auto detect Make sure the *real* CD-ROM is listed before the Ubuntu ISO file. Installing Ubuntu from the ISO into the Virtual Machine ------------------------------------------------------- Power on the newly created virtual machine: - You may get a warning that you don't have a floppy disk drive; that's okay. - you can configure VMware to start the floppy as "disconnected", if you like - Make sure the virtual machine starts up without network errors. If you have network errors, see the Network Errors section below If all goes well, you should see the Ubuntu install menu (booting from the ISO image) and a timer will be counting down from 30 seconds. If you don't do anything, Ubuntu will automatically start installing when the timer hits zero. Before the timer runs out, use the arrow keys to select: - Select: Check CD for defects - make sure it runs OK without errors - Select: Start or install Ubuntu - wait (and wait) until you get a textured brown desktop with two icons: Examples and Install When you see the Examples and Install icons on the Ubuntu desktop: - Select: System | Preferences | Screen Resolution and choose a resolution that fits the Ubuntu desktop inside your WinXP desktop size without scroll bars. You may want to increase your WinXP desktop resolution above the default 1024x768 - a WinXP resolution of 1280x1024 with a Ubuntu resolution of 1024x768 works. - Select the Desktop icon "Install" and run it. In the Install Welcome dialog box, select "Release Notes". If this doesn't open a working web browser open to the Release Notes, your networking is broken. See the Network Errors section below. Skim over the Release Notes and then close the web browser. In the Install Welcome dialog box, select your language and then Forward. In "Where are you?" select Montreal and Forward. In "Keyboard layout" select (keep) U.S. English and Forward. In "Prepare disk space" select (keep) Guided/SCSI and Forward. In "Who are you?" type: - type your full name - type your login userid (letters and digits only, 8 characters or less) - if you use your Algonquin userid, you will find logins to the Algonquin VPN and to the Course Linux server easier - you can create other account names later using "adduser" or the GUI - type your password (remember this!) - type the name of your computer: - use your userid followed by ubuntu01, e.g. abcd0001-ubuntu01 - Select Forward/Next Wait (and wait) for the install to complete. Reboot when asked to "Restart now". You don't need to "remove the CD"; since, the system will now choose to boot from the hard disk before it chooses the Ubuntu CDROM. (If you accidentally get the Ubuntu Install CDROM ISO install menu again, simply choose the menu entry "boot from hard disk".) Booting the Installed Ubuntu ---------------------------- As the virtual machine boots from the hard disk, you will see a "Grub" menu quickly followed by the Ubuntu splash screen, followed by the Ubuntu login screen. Log in using your Algonquin userid that you created earlier (similar to "abcd0001"). The brown textured Ubuntu desktop should appear, with the Ubuntu 7.10 DVD-ROM mounted as an icon on the desktop. - Select: System | Preferences | Screen Resolution and choose a resolution that fits the Ubuntu desktop inside your WinXP desktop size without scroll bars. You may want to increase your WinXP desktop resolution above the default 1024x768 - a WinXP resolution of 1280x1024 with a Ubuntu resolution of 1024x768 works. Open the Applications | Accessories menu and drag the "Terminal" icon from the menu up to a free space on the main Ubuntu title bar at the top of the screen. Use the new Terminal icon to start up a Terminal. In the Terminal, use sudo to set a root password (remember it): $ sudo passwd root The "sudo" command first requires you to type *your* password, then it runs the given passwd command as root. This root password will be needed if you shut down to single-user "maintenance mode". Select Software Sources ----------------------- Before you check for updates, configure the Software Sources for your system. Software Sources are the allowed places where Ubuntu will look for updates and new software. These places are stored in the file /etc/apt/sources.list and are maintained by the GUI through the System | Administration | Software Sources menu. If you use the GUI, these are the setting you should check: System | Administration | Software Sources: Ubuntu Software Tab: Downloadable from the Internet - check all boxes Download from: Server for Canada (or your choice) Installable from CD-ROM/DVD - check the Gutsy Gibbon official Cdrom Third-Party Software Tab: - check both "partner" archives Updates Tab: Ubuntu updates - check two of four: check "important" and "recommended" - do *not* check the other two updates boxes Automatic updates - Check for updates: Daily - Only notify about available updates (or your choice) When you are done, the /etc/apt/sources.list file must contain a list of 16 entries, similar to the list given below. The exact archive sources host names will depend on from where you elected to receive updates: $ grep '^deb' /etc/apt/sources.list deb cdrom:[Ubuntu 7.10 _Gutsy Gibbon_ - Release i386 (20071016)]/ gutsy main restricted deb-src http://archive.ubuntu.com/ubuntu/ gutsy main restricted #Added by software-properties deb http://ca.archive.ubuntu.com/ubuntu/ gutsy main restricted deb-src http://ca.archive.ubuntu.com/ubuntu/ gutsy restricted main multiverse universe #Added by software-properties deb http://ca.archive.ubuntu.com/ubuntu/ gutsy-updates main restricted deb-src http://ca.archive.ubuntu.com/ubuntu/ gutsy-updates restricted main multiverse universe #Added by software-properties deb http://ca.archive.ubuntu.com/ubuntu/ gutsy universe deb http://ca.archive.ubuntu.com/ubuntu/ gutsy-updates universe deb http://ca.archive.ubuntu.com/ubuntu/ gutsy multiverse deb http://ca.archive.ubuntu.com/ubuntu/ gutsy-updates multiverse deb http://archive.canonical.com/ubuntu gutsy partner deb-src http://archive.canonical.com/ubuntu gutsy partner deb http://security.ubuntu.com/ubuntu gutsy-security main restricted deb-src http://security.ubuntu.com/ubuntu gutsy-security restricted main multiverse universe #Added by software-properties deb http://security.ubuntu.com/ubuntu gutsy-security universe deb http://security.ubuntu.com/ubuntu gutsy-security multiverse Make sure you have all 16 software sources before you ask for updates. Install Ubuntu Software Updates ------------------------------- After you have configured all your Software Sources (above), check for software updates using the Update Manager. (The system may check for you already and tell you by flashing an orange icon on the top menu bar in your desktop.) Start the System | Administration | Update Manager (or by clicking on the orange icon near the upper right of the Desktop title bar: the "Update manager"). The Update Manager will require your password to become root (via a hidden sudo) to run. When the Update Manager is fully open, select "Check" to check for new updates using the Software Sources you defined earlier. As of February 2008, there are over 150 updates ready for Ubuntu 7.10 Gutsy Gibbon. (If you don't get a list that large, your Software Sources are incorrect. Go back and fix them.) This update may take 15-60 minutes to complete, depending on your network connection and the archive source you have chosen. If the data rate is very slow, you can select another, faster update site using the Software Sources menu (above). After "Check" select "Install Updates". You can proceed with the VMware Tools installation, below, in parallel with the software updates. When the software updates are finally done, close the Update Manager. Most software updates don't require a reboot; however, for some updates to kernel data structures or central programs, you may be required to reboot your (virtual) machine. VMware Tools Extraction ----------------------- Installing the VMware Tools will improve the responsiveness of your Ubuntu virtual machine, and will allow your mouse to move seamlessly from the virtual machine back to the host machine without needing to use the CTRL+ALT keys to "free" it from the virtual machine window. Make sure you have put your two CD-ROM devices in the correct order, as given above under "Edit Settings". Choose "VM" from your master VMware menu bar. Select "Install VMware Tools". A new "VMware Tools" DVD-ROM icon will appear on your desktop, and the File Browser will open to this directory. In the File Browser, select and open the compressed "tar" archive (the file ending in ".tar.gz"). The archive manager will open a window showing you the contents of this compressed tar archive. In the archive manager window, select "Extract". The archive manager will open a dialog box named "Extract" that will ask you to where you want the files in the archive extracted: - Select "Desktop". - Select "All files". - Select "Re-create folders". - Select "Overwrite existing files" - Select Extract. Eventually, a new folder icon will appear on your Desktop named "vmware-tools-distrib". You now have an extracted copy of the VMware tools archive. Close all the file browser and archive manager windows. Right-click on the "VMware Tools" DVD-ROM icon on the Desktop and select "Eject". After the DVD-ROM icon disappears, select the master VMware menu item "VM" and select "Cancel VMware Tools Install". Patch the Tools --------------- The VMware Tools you just extracted have not been updated to work with the Ubuntu 7.10 distribution. A Google search reveals the problem. Open up a browser window and read (but do not do) these edit patches needed to fix one line in the VMware tools source for the latest version of Ubuntu (version 7.10 gutsy gibbon): http://www.debuntu.org/how-to-vmware-tools-hgfs-module-on-ubuntu-gutsy-gibbon-7.10 http://ubuntuforums.org/showthread.php?t=595348 Start a terminal window. In the terminal, change directories to the vmware-tools-distrib directory (the same directory that is visible on your Ubuntu desktop). This directory is located under the Desktop directory in your home directory: $ cd Desktop/vmware-tools-distrib From the terminal window in the vmware-tools-distrib directory, follow the following command-line steps taken from the above patch descriptions. The patch below changes one source line containing "<" to "<=" in one file: *** You must first start a terminal in the Desktop/vmware-tools-distrib *** directory before you can follow the directions below. Do not *** proceed with any step unless the previous step completes without errors. $ cd lib/modules/source $ cp -p vmhgfs.tar vmhgfs.tar.old $ tar xvf vmhgfs.tar $ cd vmhgfs-only $ chmod 644 compat_slab.h $ vi compat_slab.h Search-> #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22) || defined(VMW_KMEMCR_HAS_DTOR) Fix-> #if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 22) || defined(VMW_KMEMCR_HAS_DTOR) Save the above one-line change and exit the VI editor. $ chmod 444 compat_slab.h $ cd .. $ rm -f vmhgfs.tar $ tar cvf vmhgfs.tar vmhgfs-only $ rm -rf vmhgfs-only After you have patched that one line in the VMware Tools source, return to the vmware-tools-distrib directory again and execute the VMware tools installation script in that directory as root - change to the Desktop directory containing the vmware-tools-distrib software (use your own userid, not "abcd0001"): $ cd ../../.. -OR- cd ~abcd0001/Desktop/vmware-tools-distrib $ sudo ./vmware-install.pl Use the default answers (yes/no/etc.) for all the questions asked by the install script. Make sure all the modules build and load correctly. After the build completes, shut down and reboot the machine (as root) either by using the Power On/Off icon in the top right of the Desktop or by issuing the command line command: $ sudo shutdown -r now When the machine reboots, log in with your userid again and start another Terminal window. Verify that the eth0 device is visible and has an IP address: $ ifconfig If you are *not* at Algonquin College, try to ping Google: $ ping google.ca Start up a browser and verify that the network is working. Welcome to Ubuntu Linux! Debian-style Package Management ------------------------------- You will need to know how to install/remove/list packages in this Ubuntu system, which is based on the Debian distribution system. Ubuntu is based on the Debian Linux distribution. In addition to the "synaptic" GUI package manager (under System | Administration | Synaptic Package Manager), Ubuntu has many other Debian command-line package-management tools that are often much faster than waiting for "synaptic" to load: How to know which packages are installed: $ dpkg -l | less $ dpkg -l | grep openssh How to search for a string in the list of known package names (both installed and not installed): $ apt-cache search openssh How to install packages by name (to be done as root): $ sudo apt-get install openssh-server How to install all your updates without waiting for the Update Manager: $ sudo apt-get update # this gets the list of updates $ sudo apt-get upgrade # this downloads and installs them Mandatory Upgrades and Installations ------------------------------------ Once your Ubuntu system is runnning and has all the Software Sources configured and the Ubuntu upgrade patches installed, here are some further upgrades to make: * Enable non-free software packages: -EITHER: From the GUI: System | Administration | Software Sources Enable the Third-Party Software partner repositories. -OR: Edit the sources.list file directly from the command line: Edit the file /etc/apt/sources.list and un-comment the "deb" and "deb-src" lines for the partner repositories. * Upgrade from "vim-tiny" to the full vim installation with help files: $ sudo apt-get install vim vim-doc ctags * Install the SSH server so you can log in to your virtual machine: $ sudo apt-get install openssh-server If you are using NAT networking (not bridged networking), you will not be able to connect from your host O/S or your local network into your virtual machine across NAT. With NAT, you can only connect from your virtual machine out to the host O/S, not the other way around. If you want to be able to use ssh to log into your virtual machine, you need to use VMware's "Bridged Networking" and give your virtual machine its own IP address. (Actually, if you can adjust the routing tables on your host O/S machine, you can set up special routing to allow ssh logins from the host O/S to the virtual guest even if the guest is using NAT networking.) * Install the Apache web server and documentation: $ sudo apt-get install apache2 apache2-doc Start up a web browser and try the URL: http://localhost/ You won't be able to connect from off-machine to any web server or other network services on your virtual machine if you are using NAT networking on your virtual machine. Use "Bridged Networking" and a separate IP address if you want to access network services on your virtual machine from other machines. Optional Enhancements --------------------- These are optional, useful things I highly recommend. You decide. * VMware Workstation: Edit | Preferences Workspace Tab: Software Updates: Check for upgrades Daily Input Tab: Grab keyboard and mouse input on mouse click Grab keyboard and mouse input on key press Display Tab: Autofit window or guest? Try none, one, or both. * Turn off your screen saver in your virtual machine: The last think you need is a backgrounded virtual machine using up your valuable CPU to display pretty pictures on a virtual desktop that nobody is watching. Turn it off: System | Preferences | Screensaver * Enable "focus follows mouse": Go to System | Preferences | Windows and turn on "Select windows when the mouse moves over them". No more need to "click to type"! * Ensure your scroll-wheel mouse works: Do this edit if your scroll wheel doesn't work on your mouse. You can check the operation of the wheel using the "xev" program: Run "xev" from the command line, move the mouse into the xev window, and use the scroll wheel. If you don't see "button 4" and "button 5" events as you move the wheel, you need the following fix: As root, make a backup of the X11 configuration file /etc/X11/xorg.conf. Edit xorg.conf. Find the "InputDevice" with Identifier "Configured Mouse" device Option "Protocol". Change the protocol from "ps/2" or "IMPS/2" to be "auto", and make sure the Option "ZAxisMapping" is set to "4 5": Option "Protocol" "auto" Option "ZAxisMapping" "4 5" Save the edited file. Log out of all windows and type CTRL-ALT-BACKSPACE to kill (and restart) the current X11 server. Log back in and use "xev" to check that the mouse wheel now works. * Turn the Caps Lock key into another Control key: Do this if you want to get rid of the useless Caps Lock key and make it operate as a second, better-placed CTRL key: In your xorg.conf file add the option selection line below to the "InputDevice" with Identifier "Generic Keyboard": # Turn the left CapsLock key into another Control key: Option "XkbOptions" "ctrl:nocaps" You have many preconfigured keyboard modifications that you can select with options in the /etc/X11/xorg.conf file. The many options are listed here: /etc/X11/xkb/rules/base.lst . =============================================================================== Network Errors at Power On? --------------------------- You may have network errors when you power on a virtual machine if you have selected a type of networking for the virtual machine that is not supported by your host VMware installation. You may need to re-configure or re-install VMware on your host machine to have the type of networking (e.g. virtual NAT) that your virtual machine requires. If you have network issues that need to be fixed at power on, you can "Suspend" your virtual machine, shut down VMware, re-configure or re-install VMware, restart VMware, "Resume" your suspended machine, and re-enable the disabled networking. If at Resume time, the network icon in the bottom right still shows an "X" (disconnected), click on the icon and select "Connected" in the Device Status section. Select Save. Make sure you have no network errors before continuing. All the device icons in the lower-right should be active and none disabled.