.. ========================================================================== = = File: build_ubuntu_static_setup.rst = Date: 6-May-2010 = Author: Hugh Secker-Walker = Description: Steps for creating an Ubuntu system = = This file is part of Onyx http://onyxtools.sourceforge.net = = Copyright 2010 The Johns Hopkins University = = Licensed under the Apache License, Version 2.0 (the "License"). = You may not use this file except in compliance with the License. = You may obtain a copy of the License at = http://www.apache.org/licenses/LICENSE-2.0 = = Unless required by applicable law or agreed to in writing, software = distributed under the License is distributed on an "AS IS" BASIS, = WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or = implied. See the License for the specific language governing = permissions and limitations under the License. = ========================================================================== Static configuration of the Ubuntu system ========================================= Once the Ubuntu system is running we make a few, one-time changes to the configuration in order to make it easier to access and to make sure the tools we install later will be available to the users of the system. Make sure the Ubuntu machine is booted. VMware may alert you to the fact that VMware Tools is not installed on the virtual machine. We'll install those tools later. The console should display the login prompt:: Ubuntu 10.04 LTS OnyxUbuntu32 tty OnyxUbuntu32 login: Click on the console window, and then login to the administrative account with the password you used during the installation:: OnyxUbuntu32 login: onyxadm Password: onyxadmin (this one time we're showing our recommended password) You should get a screenful of licensing etc. info, and then a shell prompt:: onyxadm@OnyxUbuntu32:~$ _ Setup SSH access ---------------- The console window is very constrained as far as UI (cut and paste) and command-line usage is concerned. We install an SSH server on the Ubuntu machine to allow access from any terminal window running on the host. **On the guest console** Install the openssh-server so that you can login from a terminal window on the host machine:: onyxadm@OnyxUbuntu32:~$ sudo apt-get install openssh-server [sudo] password for onyxadm: It will print out info and recommendations and ask if you want to continue; the default is Yes, so just hit *Return*. It will download packages, configure SSH, and start the SSH server. Once SSH is installed and running, use **ifconfig** to get the Ubuntu machine's IP address:: onyxadm@OnyxUbuntu32:~$ ifconfig This should show IP configuration info for two interfaces: **eth0** and **lo**. The address we want is the **inet addr:** for eth0, e.g. ``172.16.166.130``, usually found on the second line of the output from ifconfig. **On the host machine** On the host machien, switch to a terminal application, and use SSH to connect to the virtual machine. Note that you may have to accept an RSA fingerprint (or even edit your known_hosts file if the virtual machine's IP address has been used before):: $ ssh onyxadm@172.16.166.130 The authenticity of host '172.16.166.130 (172.16.166.130)' can't be established. RSA key fingerprint is 88:cd:8b:1f:18:79:3f:77:24:d9:b1:6a:2f:23:cf:85. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added '172.16.166.130' (RSA) to the list of known hosts. onyxadm@172.16.166.130's password: Linux OnyxUbuntu32 2.6.32-22-generic #33-Ubuntu SMP Wed Apr 28 13:27:30 UTC 2010 i686 GNU/Linux Ubuntu 10.04 LTS Welcome to Ubuntu! * Documentation: https://help.ubuntu.com/ The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Thu May 6 18:12:19 2010 onyxadm@OnyxUbuntu32:~$ Other changes to the Ubuntu configuration ----------------------------------------- For the remainder of the steps to configure the Ubunut system, we will assume you are using the terminal on the host machine with SSH access to the Ubuntu machine, and that you can paste text from the clipboard into the terminal. **Become root** In general we recommend using **sudo** on a command-by-command basis for doing adminstrative work; but, because we have a bunch of changes to make we will be come **root** for the remainder of this document. In the terminal, become superuser:: onyxadm@OnyxUbuntu32:~$ sudo su - [sudo] password for onyxadm: root@OnyxUbuntu32:~# Tools for administrative work ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Configuration work on the Ubuntu system involves using the command line and editing files. For editing, the **vi** editor is already available. If you prefer other tools, now is the time to install them. We prefer Emacs, so we install it now:: root@OnyxUbuntu32:~# apt-get install emacs23-nox Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: emacs23-bin-common emacs23-common emacsen-common libasound2 libpython2.6 Suggested packages: emacs23-el libasound2-plugins The following NEW packages will be installed: emacs23-bin-common emacs23-common emacs23-nox emacsen-common libasound2 libpython2.6 0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded. Need to get 24.9MB of archives. After this operation, 77.0MB of additional disk space will be used. Do you want to continue [Y/n]? ... (many pages of output) Processing triggers for libc-bin ... ldconfig deferred processing now taking place root@OnyxUbuntu32:~# .. note:: When you paste text into configuration files, be sure to **add final newline** after the last line of the pasted text. Changes related to networking ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default, the Ubuntu system uses **udev** to maintain a persistent mapping from the MAC address of the virtual NIC card to the interface name. This is a problem because VMware defaults to assigning a new MAC address to the virtual machine whenever the virtual machine is moved or renamed on the host system, resulting in a new interface name for network access, e.g. ``eth1``. We prevent the Ubunutu machine from using a persistent mapping; by doing so we ensure that ``eth0`` will always be the interface name. See `this issue tracker thread `_ for more insight. Also, to simplify the SSH access, we will cause the IP address of the virtual machine to be displayed on the console. **To prevent persistence of the MAC address mapping** delete the existing rules file:: root@OnyxUbuntu32:~# rm /etc/udev/rules.d/70-persistent-net.rules And then edit ``/lib/udev/rules.d/75-persistent-net-generator.rules``. Insert the following lines after the line that reads the MAC address: ``ENV{MATCHADDR}="$attr{address}"``:: # ignore VMware virtual interfaces ATTR{address}=="00:0c:29:*", GOTO="persistent_net_generator_end" ATTR{address}=="00:50:56:*", GOTO="persistent_net_generator_end" **Make the console display the system's IP address** First, move the original ``/etc/issue`` file:: mv /etc/issue /etc/issue.orig Then edit ``/etc/rc.local`` to have it figure out the IP address on eth0 and create the ``/etc/issue`` file at boot time. Insert the following prior to the ``exit 0`` statement:: # customize the console login prompt to show our IP address sleep 8 ip_addr=`ifconfig -a eth0|fgrep 'inet addr:'|cut -d: -f 2|cut '-d ' -f 1` echo > /etc/issue echo >> /etc/issue echo '\\n -- Ubuntu 32-bit Server -- IP address:' ${ip_addr:-unavailable} >> /etc/issue echo >> /etc/issue Then run ``/etc/rc.local`` and see what's in ``/etc/issue``:: root@OnyxUbuntu32:~# /etc/rc.local root@OnyxUbuntu32:~# cat /etc/issue \n -- Ubuntu 32-bit Server -- IP address: 172.16.166.130 To check that it's really working, switch back to the Ubunut console and logout. The new login banner should display the IP address. Other changes to system files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ **Make the CD reader easy to mount.** In a shell:: root@OnyxUbuntu32:~# cd /media root@OnyxUbuntu32:/media# mkdir cdrom0 root@OnyxUbuntu32:/media# ln -s cdrom0 cdrom Edit ``/etc/fstab`` and add the following line at the bottom:: /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 **Add files to default configuration for new users.** Create the file ``/etc/skel/.bash_aliases`` with the following contents:: # ~/.bash_aliases: sourced by ~/.bashrc # work around broken colors in emacs shell alias ls='ls --color=none' # enable quick PYTHONPATH in top directory of Onyx-based tools alias pypa='export PYTHONPATH=`pwd`/py' Create the file ``/etc/skel/.emacs`` with the following contents:: (display-time) (setq-default fill-column 80) (shell) ;; Font-Lock Mode Flags and syntax colors (progn (global-font-lock-mode t) (setq font-lock-maximum-decoration t) (set-face-background 'modeline "black") (set-face-foreground 'modeline "white") ; font-lock-builtin-face (set-face-foreground font-lock-builtin-face "blue") ; font-lock-keyword-face (set-face-foreground font-lock-keyword-face "blue") ; font-lock-comment-delimiter-face (set-face-foreground font-lock-comment-delimiter-face "red") ; font-lock-comment-face (set-face-foreground font-lock-comment-face "red") ; font-lock-constant-face (set-face-foreground font-lock-constant-face "red") (make-face-bold font-lock-constant-face) ; font-lock-doc-face (set-face-foreground font-lock-doc-face "grey") ; font-lock-function-name-face (set-face-foreground font-lock-function-name-face "red") (make-face-bold font-lock-function-name-face) ; font-lock-keyword-face (set-face-foreground font-lock-keyword-face "blue") (make-face-unbold font-lock-keyword-face) ; font-lock-string-face (set-face-foreground font-lock-string-face "red") ; font-lock-type-face (set-face-foreground font-lock-type-face "red") (make-face-bold font-lock-type-face) ; font-lock-variable-name-face (set-face-foreground font-lock-variable-name-face "black") ; font-lock-warning-face (set-face-foreground font-lock-warning-face "black") ; font-lock-negation-char-face ; font-lock-preprocessor-face ; font-lock-regexp-grouping-backslash-face ; font-lock-regexp-grouping-construct-face ) ;; Python stuff (setq comment-style 'plain) (setq auto-mode-alist (cons '("\\.py$" . python-mode) auto-mode-alist)) (setq interpreter-mode-alist (cons '("python" . python-mode) interpreter-mode-alist)) ; in a shell buffer: grab the shell's PYTHONPATH into emacs (fset 'pypa "\C-[xshell-copy-environment-variable\C-mPYTHONPATH\C-m") That's it for static changes to system files. Next we have to update and install packages.