project 0: linux & virtual machine dabbling
DESCRIPTION
Project 0: Linux & Virtual Machine Dabbling. CS-502, Operating Systems. In this project, we will …. Install our virtual machines and learn how to use them This is the place you will work during this course! Build and install the Linux kernel With your name on it! - PowerPoint PPT PresentationTRANSCRIPT
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 1
Project 0: Linux & Virtual Machine Dabbling
CS-502, Operating Systems
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 2
In this project, we will …
• Install our virtual machines and learn how to use them– This is the place you will work during this course!
• Build and install the Linux kernel– With your name on it!
• Follow Linux naming & numbering conventions
• Turn in the project using web-based Turnin
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 3
In this project, we won’t …
• … try to change anything in the kernel yet• This is for next project
• … try to support more than one machine architecture
• However, 32-bit and 64-bit architectures are different at the kernel level!
• Your virtual machine is not portable from one to the other
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 4
Installing your Virtual Machine – Options
• Install from DVD using VMware Player or any other VMware product
• Needs 8 gigabytes of disk, 1-2 gigabytes of RAM, fast Pentium CPU (dual core would be very nice!)
• Use VMware Server on csopt4.wpi.edu• Needs VMware client on your PC
• GUI interface to virtual machine
• Use Parallels on Macintosh (or other)• See instructor
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 5
Installing from DVD
• See instructions on-line• .doc, .html
• Download and install VMware Player• Or other VMware product
• Unzip your virtual machine to new directory
• …
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 6
Installing from DVD (continued)
• Choose type of networking• Bridged vs. NAT (Network Address Translation)
• Start your virtual machine• Fix up MAC address for network• Boot OpenSUSE 10.2• Login is as student, password = CS-502
• Open YaST, the SUSE administration tool• Fix and test networking• Create new user identity for yourself• Log out, log in as new identity, delete student
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 7
Using VMware Server on csopt4
• See instructions• .doc, .html
• Get CS Department user ID and password• Download and install VMware client• Log onto csopt4, make new directory on /xtra_space drive
• Unzip the following file to your new directory– /xtra_space/CS-502/CS-502_Fall-07_x86_64.zip
• …
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 8
Using VMware Server on csopt4 (continued)
• Start VMware client, log into csopt4
• Browse to and open your virtual machine• Rename it to something unique (your user ID)
• Set permissions
• Start your virtual machine
• Follow instructions for distributed version– Networking, user identity, etc.
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 9
Setting OpenSUSE Linux 10.2 on Parallels
• See instructor
• Will install OpenSUSE Linux 10.2 directly to disk partition– Be sure to get on-line updates
• Best to create a separate partition for /home directory
• Need to move /usr/src to /home/src– Create link /usr/src /home/src
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 10
Questions?
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 11
To get started with kernel
• Find kernel sources in /usr/src, i.e., a link to /home/src
linux-2.6.18.2-34linux-2.6.18.8-0.5
• Clone kernel source tree by linked copy: –– In a terminal window, docp –al /usr/src/linux-2.6.18.8-0.5 kernelSrc
– Creates a linked copy of original tree in new directory called kernelSrc
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 12
Digression on Unix/Linux Hard Links
• Directory entries point directly to files• Two entries may point to same file!
• Same or different directories• Same or different name• Permissions attached to file, not directory• Called hard links (as opposed to symbolic links)
• Modifications to file seen via all hard links
• mv and rm commands change directories, not files!• File goes away when all directory entries (i.e., hard
links) to that file are deleted.
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 13
Cloned Source Tree
• All directories are copied
• All directory entries in copy are hard-linked back to files in original source tree
• I.e., only one copy of each file exists
• To modify a file:–• Unlink it (via mv or rm)
• Replace it with modified copy in your directory
• Original is preserved intact in original directory
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 14
To Modify a File
• mv file.c file.c~
• Edit file.c~ in your favorite editor• Save as file.c• (Eventually) delete file.c~
• EMACS and patch do this automatically
• Most other editors require you to do it manually
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 15
To Build Linux Kernel
• Make configuration step– As ordinary user
• Build kernel files and modules– As ordinary user
• Install modules, boot file, etc.– Need root privileges
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 16
To Build Linux Kernel (continued)
• Always build to a separate destination treemkdir ~/kernelDstmake O=~/kernelDst …
• Reason– Making the configuration generates a lot of
include files and other sources– If you don’t specify a destination, it fills up
your source tree– Your patch files grow to > 1 megabyte!
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 17
Make configuration
• In a command shell– cd kernelSrc
• Do one of:–– make O=~/kernelDst config
• Very long and tedious– make O=~/kernelDst menuconfig
• Still somewhat long and tedious; also hokey– make O=~/kernelDst xconfig
• Nice; a GUI with very small print– make O=~/kernelDst gconfig
• Really nice; a better GUI; highly recommended
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 18
Make configuration (continued)
• Edit “General Setup” to name your “Local version”
• No other edits necessary for this project.• Save and quit
• If need to rebuild, use•make O=~/kernelDst oldconfig
to reuse same configuration
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 19
To Build Kernel
• In a terminal window (i.e., a shell), do: – – cd kernelSrc– make O=~/kernelDst
• Takes• 20 minutes on dual-core 2.4 GHz Pentium, 2 GByte
• 40 minutes on csopt4 (last year)
• Almost two hours on 3 gigahertz Pentium, 1 GByte
• Rebuilds after small edits are much faster
• Changing .h files can cause longer rebuilds
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 20
One little glitch …
• File include2/asm/asm-offsets.h not generated by make config
• Build crashes within about 2-3 minutes• Link file from
• ~/kernelDst/include/asm-i386/ or• ~/kernelDst/include/asm-x86_64
to• ~kernelDst/include2/asm
• Run make O=~/kernelDst again• Without trying to remake the config• Build “should” complete without further errors
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 21
For Project Submission
• Redirect build output to a file
• Submit that file (this project only)
• Note that there are lots of warnings in the Linux kernel
• Not your problem!
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 22
To Build Kernel on a Dual Processor
• Generally faster to do – cd kernelSrc– make –j2 O=~/kernelDst
• Sometimes, this is even faster– make –j4 O=~/kernelDst
• SUSE advice– 2 number of processors
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 23
To Install Kernel
• Requires root privileges– sudo make modules_install install
– Note order of arguments!
• Puts kernel, initrd file, symbols in /boot– Changes links for vmlinuz, initrd
• Adds entries to /boot/grub/menu.lst– So your kernel shows up on boot screen– So you can select which kernel to boot
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 24
Running Your Kernel
• Restart your virtual machine
• Click in boot window
• Use arrow keys to select desired kernel or system
• To determine which kernel is running:–– uname -a
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 25
Submitting your Project
• From within your virtual machine, visit– http://turnin.cs.wpi.edu:8088/servlets/turnin.ss
• Log in
• Submit output of your build as Project 0
• This is to test the ability to submit projects from the virtual machine!
Project 0: Linux & VM Dabbling
CS-502, Fall 2007 26
Questions?