Preparation

Prior to installing the VM you need to do the following:

On Windows

  1. Install VMPlayer - http://www.vmware.com/products/player/

Known Problems On Windows Vista

  1. If you have two network adaptors (e.g. ethernet and wireless) you may find that the VM binds to one while Vista is using the other for traffic. This will result in the VM seeing the outside network but the host OS (Vista) not being able to connect e.g. via putty.

On OSX (Mac)

  1. You need VMFusion, speak to Simon to get a free copy

On Linux

  1. Install VMPlayer - http://www.vmware.com/products/player/

Known problems

The network adaptors can be confused. This results in your VM not being able to access the network. The symptom of this is that the VM's IP address isn't listed when running myip and eth0 network adaptor isn't listed in when running ifconfig.

First of all make sure that the VMWare networking is set to Host-only. Then try to restart the networking:

service networking restart

If that doesn't bring the network back (still nothing from ifconfig for eth0) run ifconfig -a. This may show you a second network interface (eth1). If it's doing that the VM has bound the networking twice - very wrong. You can remedy this by doing:

sudo mv /etc/udev/rules.d/70-persistent-net.rules /etc/udev/rules.d/70-persistent-net.rules_bak
sudo reboot

More info: http://muffinresearch.co.uk/archives/2008/07/13/vmware-siocsifaddr-no-such-device-eth0-after-cloning/

CompPhys VM

Installing the VM

  1. Download the VM image
  2. Unzip it (more here...)
  3. Open in VMPlayer/WMFusion
    • When opening the VM in VMPlayer/WMFusion you will be asked if you have "moved" or "copied" the VM - choose "moved"
    • You will probably see a warning about a missing file the first time you start the VM, don't worry about this.

Restarting the VM

If you keep the VM on the network drive (U:) or use it on different machines when you reload the VM it's likely to get confused. You should restart it as follows:

sudo reboot

This will let the VM reconfigure itself for the machine you have moved it to.

Symptoms of this are:

  • 'Read only' file system
  • No network (running ifconfig does nothing)

VM Contents

Your VM should be loaded with:
  1. Ubuntu OS
  2. Python v2.6
    • numpy
    • matplotlib
  3. gcc v4.3.3
  4. gnuplot

Using your own computer

Moving the VM around

If you are moving the VM from home or your laptop onto the lab machines you will need to turn the VM off before moving it between machines. To do this run the following command:

sudo shutdown -h now

This will turn the VM off safely and close the VMWare app.

Putting files onto your VM

From a computer in 1.14

Your U: drive is mounted into the VM. You have access to all your files in U: via /mnt/hgfs/your_shared_area. You should probably make a directory under U: for the course (for example compphys) and then make a link through to the VM's home area using the following commands:

cd   #check you're in the home directory
ln -s /mnt/hgfs/your_shared_area/compphys .

Any files you put into your U: drive will be accessible from the VM, so write your code in Windows (using Notepad), save into U:/compphys and then run/compile in the VM.

From your own laptop

Using your own laptop is a bit more convenient for some people, but does mean you can't mount your U: drive into the VM. Here's how to get files in and out of your VM on your own laptop.

Windows

  1. Download and install the following program:
  2. Start the VM up and log in
  3. Run myip at the prompt, this should print out a number (the VM's IP address) like 172.16.17.128
  4. Open the WinSCP program
  5. In hostname put the number the myip program returned, username is student, password is student123. Click Save, then click Login
    • this should bring up a two panel window with the files on your computer on the left, and the files on the VM on the right. You can drag files into the right hand pane to transfer them into the VM and drag them from the right hand pane to copy them onto your laptop.

You may find the VMWare player interface a bit annoying - no scrolling, copy and paste doesn't work. If you do:

  1. Download and install the following program:
  2. Open putty up, connect it to the VM in the same way as WinSCP (use the IP address of the VM as host name etc.)
    • this should bring up a black prompt window, this is another view into the VM which is a bit more usable (you can copy/paste, you don't have to press Ctrl+Alt to switch out of the VM etc.)

Mac OSX and Linux

As OSX and Linux are both derivatives of Unix you don't need to install additional programs to interact with the VM. Here's how you can connect to it from OSX/Linux:
  1. Start the VM up and log in
  2. Run myip at the prompt, this should print out a number (the VM's IP address) like 172.16.17.128
  3. Start the terminal application (on OSX this is in Applications/Utilities/Terminal, Linux you probably know where it is already...)
  4. To log into the VM via the Terminal (handy if you have a non-UK keyboard layout, supports copy/paste) run ssh student@172NOSPAMPLEASE.16.17.128 (replacing 172.16.17.128 with the IP address myip returns), this will give you a prompt like the VM
  5. To copy files from your laptop into the VM run scp -r /path/on/laptop/to/the/file student@172NOSPAMPLEASE.16.17.128:~/path/on/the/vm
  6. To copy files from the VM into your laptop run scp -r student@172NOSPAMPLEASE.16.17.128:~/path/on/the/vm /path/on/laptop/to/the/file

From the web

Linux has a tool to fetch URL's from the web called wget, you can use it like so:
wget http://www.google.com

Plotting

We provide a basic plotting script called cp_plot. It generates 2d plots and takes a list of data files as it's input to create the plot. Use it as follows:

cp_plot --title 'my cool plot' datafile.txt

This will make a file called my_cool_plot.png in your working directory.

If you have multiple data series call the script as follows:

cp_plot --title 'my cool plot' datafile1.txt datafile2.txt datafile3.txt

The contents of your data files should look like:

x (t), y (m/s) 
1, 10
2, 15
3, 30
4, 17
5, 12

Note that the first line are the labels for the x and y axes. Each column is separated by a comma.

If you decide you want to create more complicated plots you are on your own. The matplotlib gallery may be useful...

Using it from a script

You can reuse the code directly from a script as follows:

from cp_plot import Plotter

plotter = Plotter()
plotter.plot(x=[1,2,3,4,5], y=[10, 15, 30, 17, 12], x_label='x (t)', y_label='y (m/s)', plot_title='my cool plot')

This will make a file called my_cool_plot.png in your working directory.

Simple Linux commands

Linux commands generally behave as follows; they have a name (for instance wget) followed by options (for instance --no-check-certificate) followed by the thing the command runs on (e.g. the URL above).

Moving around the file system

Some basic commands follow:

ls
list contents of the current directory
cd
change directory to
<dirname>
, if no
<dirname>
it'll take you back to your home directory
mkdir
create the directory
<dirname>
rm thing
delete thing - be careful there's no Recycling Bin, you run rm and the file is gone!

Output redirection

Linux lets you channel the output of one program into another or into a file. This is useful when you want to easily store the results from your programs. It's done like so:

my_program >> my_file

This will put all the output of my_program into my_file. Be careful, this will overwrite my_file without asking you first. If your program asks for input it will not work as the request for input may go into the file, and you'll not be able to provide input.

Moving around on the prompt

ctrl + a
go to the beginning of the line
ctrl + e
go to the end of the line
ctrl + w
delete a word

Tab completion

  • type the first letter of the file you want/program to run
  • press tab - this will list all the things that begin with that letter, or add more letters until there's a choice (e.g. c -> ca if there'd car and cat)
  • repeat until the filename you want is there

FAQ

I have no network access, what do I do?
You need to delete the VM and start again from the zip file, make sure you click "move" when asked if you have copied or moved the VM. Make sure you have a copy of your work before deleting the VM. If this doesn't help ask a demonstrator.
Edit | Attach | Watch | Print version | History: r31 < r30 < r29 < r28 < r27 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r31 - 2010-11-30 - SimonMetson
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Main All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback