User Mode Linux® By Dike Jeff Publisher: Prentice Hall Pub Date: April 12, 2006 Print ISBN-10: 0-13-186505-6 Print ISBN-13: 978-0-13-186505-1 Pages: 352 Table of Contents | Index With User Mode Linux you can create virtual Linux machines within a Linux computer and use them to safely test and debug applications, network services, and even kernels You can try out new distributions, experiment with buggy software, and even test security Now, for the first time, the creator and maintainer of User Mode Linux shows how to put it to work hands-on Jeff Dike covers everything from getting started through running enterprise-class User Mode Linux servers You'll find authoritative advice on bootup, compilation, administration, specialized configurations, and much more Coverage includes What User Mode Linux is, how it works, and its uses in Linux networks Key applications, including server consolidation, development, and disaster recovery Booting and exploration: logins, consoles, swap space, partitioned disks, and more Copy-On-Write (COW): UML's efficient approach to storing filesystem changes In-depth discussion of User Mode Linux networking and security Centrally managing User Mode Linux instances, and controlling their hardware resources Implementing clusters and other specialized configurations Setting up User Mode Linux servers, step-by-step: small-scale and large-scale examples The future of virtualization and User Mode Linux Whether you're a netadmin, sysadmin, teacher, student, or programmer, User Mode Linux® the technology and this book is indispensable User Mode Linux® By Dike Jeff Publisher: Prentice Hall Pub Date: April 12, 2006 Print ISBN-10: 0-13-186505-6 Print ISBN-13: 978-0-13-186505-1 Pages: 352 Table of Contents | Index Copyright Bruce Perens' Open Source Series Preface Acknowledgments About the Author Chapter 1 Introduction What Is UML? Comparison with Other Virtualization Technologies Why Virtual Machines? A Bit of History What Is UML Used For? The Future Chapter 2 A Quick Look at UML Booting UML for the First Time Booting UML Successfully Looking at a UML from the Inside and Outside Conclusion Chapter 3 Exploring UML Logging In as a Normal User Consoles and Serial Lines Adding Swap Space Partitioned Disks UML Disks as Raw Data Networking Shutting Down Chapter 4 A Second UML Instance COW Files Networking the UML Instances A Virtual Serial Line Chapter 5 Playing with a UML Instance Use and Abuse of UML Block Devices Networking and the Host Chapter 6 UML Filesystem Management Mounting Host Directories within a UML Host Access to UML Filesystems Making Backups Extending Filesystems When to Use What Chapter 7 UML Networking in Depth Manually Setting Up Networking The UML Networking Transports An Extended Example Chapter 8 Managing UML Instances from the Host The Management Console Controlling a UML Instance with Signals Chapter 9 Host Setup for a Small UML Server Host Kernel Version UML Execution Modes Managing Long-Lived UML Instances Networking UML Physical Memory Host Memory Consumption umid Directories Overall Recommendations Chapter 10 Large UML Server Management Security Jailing UML Instances Providing Console Access Securely skas3 versus skas0 Future Enhancements Final Points Chapter 11 Compiling UML from Source Downloading UML Source Configuration Compilation Chapter 12 Specialized UML Configurations Large Numbers of Devices Clusters UML as a Decision-Making Tool for Hardware Chapter 13 The Future of UML The externfs Filesystem Virtual Processes Captive UML Virtualized Subsystems Conclusion Appendix A UML Command-Line Options Device and Hardware Specifications Debugging Options Management Options Informational Options Appendix B UML Utilities Reference humfsify uml_moo uml_mconsole tunctl uml_switch Internal Utilities Index Copyright Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and the publisher was aware of a trademark claim, the designations have been printed with initial capital letters or in all capitals The author and publisher have taken care in the preparation of this book, but make no expressed or implied warranty of any kind and assume no responsibility for errors or omissions No liability is assumed for incidental or consequential damages in connection with or arising out of the use of the information or programs contained herein The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases or special sales, which may include electronic versions and/or custom covers and content particular to your business, training goals, marketing focus, and branding interests For more information, please contact: U.S Corporate and Government Sales (800) 382-3419 corpsales@pearsontechgroup.com For sales outside the United States, please contact: International Sales www.international@pearsoned.com Visit us on the Web: www.prenhallprofessional.com Library of Congress Cataloging-in-Publication Data Dike, Jeff User Mode Linux / Jeff Dike p cm Includes bibliographical references and index ISBN 0-13-186505-6 (pbk : alk paper) Linux Operating systems (Computers) 3 Application software porting I Title QA76.76.O63D545 2006 005.4'32 dc22 2006004225 Copyright © 2006 Pearson Education, Inc This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/) Text printed in the United States on recycled paper at RR Donnelley in Crawfordsville, Indiana First printing, April 2006 Bruce Perens' Open Source Series www.prenhallprofessional.com/perens Bruce Perens' Open Source Series is a definitive series of books on Linux and open source technologies, written by many of the world's leading open source professionals It is also a voice for up-and-coming open source authors Each book in the series is published under the Open Publication License (www.opencontent.org), an open source compatible book license, which means that electronic versions will be made available at no cost after the books have been in print for six months JavaTM Application Development on Linux® Carl Albing and Michael Schwarz C++ GUI Programming with Qt 3 Jasmin Blanchette and Mark Summerfield Managing Linux Systems with Webmin: System Administration and Module Development Jamie Cameron Understanding the Linux Virtual Memory Manager Mel Gorman PHP 5 Power Programming Andi Gutmans, Stig Bakken, and Derick Rethans Linux® Quick Fix Notebook Peter Harrison Implementing CIFS: The Common Internet File System Christopher Hertel Open Source Security Tools: A Practical Guide to Security Applications Tony Howlett Apache Jakarta Commons: Reusable Java™ Components Will Iverson Linux® Patch Management: Keeping Linux® Systems Up To Date Michael Jang Embedded Software Development with eCos Anthony Massa Rapid Application Development with Mozilla Nigel McFarlane Subversion Version Control: Using the Subversion Version Control System in Development Projects William Nagel Intrusion Detection with SNORT: Advanced IDS Techniques Using SNORT, Apache, MySQL, PHP, and ACID Rafeeq Ur Rehman Cross-Platform GUI Programming with wxWidgets Julian Smart and Kevin Hock with Stefan Csomor Samba-3 by Example, Second Edition: Practical Exercises to Successful Deployment John H Terpstra The Official Samba-3 HOWTO and Reference Guide, Second Edition John H Terpstra and Jelmer R Vernooij, Editors Self-Service Linux®: Mastering the Art of Problem Determination Mark Wilding and Dan Behman Preface When I started the User Mode Linux (UML) project in 1999, I had no idea how large a project it would become or how much of my time it would end up consuming As time went on, the UML user base grew, and people found new ways to use it As a result of their requests, UML contains a number of features that would never have occurred to me This book concentrates on the use of UML rather than its internals or plans for the future I've tried to make it as easy as possible to get started with UML and put to good use all of the features my users induced me to add Of course, I couldn't resist going into how UML works and what I have planned for its future That would be too much to ask of any developer of any project I hope this content adds to the book and the readers' understanding and appreciation of UML for host network access Small server setup execution modes in patches for skas0 skas3 tt Vanderpool and Pacifica for memory for networking kernel version in long-lived instances in recommendations for umid directories in SMP (Symmetric Multi-Processing) SMP option Sniffers Sockets in MConsole notifications with with hostfs with humfs with uml_switch Solaris zones Source, downloading sparse switch Specialized configurations clusters large numbers of devices memory network interfaces Spoofing in bridging ssh command ssh keys ssh sessions, random numbers for SSI (Single-System Image) cluster SSL option SSL_CHAN option stack command 2nd Stack, dumping 2nd Standard application programming interface in captive UML Static linking configuration option for with jails STATIC_LINK option stop command Stopping instances virtual machines strace tool su with jails Subnets for instances Subsystems, virtualized superblock files 2nd Swap space adding for instances for jails MADV_TRUNCATE for partitions for performance of with compartments swapoff command swapon command 2nd switch command switch-tap option Switches for packets virtual Symbolic links Symmetric Multi-Processing (SMP) Synchronization clock in sysrq Synchronous files sysemu patch sysrq command and SysRq handler for backups in uml_mconsole invoking MAGIC_SYSRQ for sysrq file System call tracing System memory savings, COW files for System-level programming Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Z] t command in sysrq -t switch for iptables for tunctl 2nd for xterm -tap switch for uml_switch Tape drives for copying data into instances tar files copying into UML for copying data into instances for moving backing files for source length of Tasks killing real-time tcpdump for multicast networks for TUN/TAP 2nd for uml_switch with pcap telnet 2nd telnetd Terminal emulators Testing COW files for testbeds for TUN/TAP devices Threads forcing into contexts in execution modes [See Execution modes.] 3_LEVEL_PGTABLES option Time to live (TTL) setting Timers listing real-time clock for Timestamps Timing bugs tmp directory copying files to 2nd for bind mounts for databases for filesystems 2nd for jails 2nd for memory 2nd for processes tmpfs filesystem 2nd 3rd 4th Torvalds, Linus touch command Tracing thread (tt) mode enabling for threads working in Traffic analysis tools Translation of filesystem requests Transports configuration options for networking configuring for host network access for isolated networks selecting tt (tracing thread) mode enabling for threads working in TTL (time to live) setting TTY_CHAN option tty_log_dir option tty_log_fd option tun file 2nd 3rd TUN/TAP devices 2nd bridging with for frames for host network access in host setup with routing configuring 2nd connectivity in DHCP for for outside network access security for testing tunctl tunctl utility reference working with tuntap command Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Z] u command in sysrq -u switch for tunctl 2nd ubd devices advantages of for filesystem access image backup for partitioning ubd option ubd0 file ubda switch for COW files ubdb file for copying data into instances for swap space udb option UID root UIDs (user IDs) in filesystem extensions in ownership umid (unique machine ID) umid directory in small server setup process IDs in with jails umid option uml.ctl socket uml_dir option uml_mconsole uml_mconsole command 2nd [See also Management Console (MConsole).] for bridging for copying data into instances for devices for host ports for hosts 2nd for network devices for TUN/TAP device connectivity for virtual serial lines reference uml_moo uml_moo tool for merging COW files reference UML_NET options uml_net utility 2nd 3rd UML_RANDOM option UML_REAL_TIME_CLOCK option uml_switch uml_switch process configuring example for isolated networks reference UML_WATCHDOG option 2nd uname command Unique machine ID (umid) Unique machine id (umid) directory in small server setup process IDs in with jails UNIX sockets in MConsole with hostfs with humfs with uml_switch -unix switch for uml_switch Unplugging devices Unprivileged contexts untar command 2nd User IDs (UIDs) in filesystem extensions in ownership User mode vs kernel mode User notifications Utilities reference humfsify Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Z] -v option for uname valgrind Vanderpool execution mode VCPU version command 2nd version option Version queries Virtual filesystems Virtual hardware configuration options Virtual machines, purpose of Virtual memory Virtual operating systems Virtual Private Networks (VPNs) Virtual processes Virtual processors Virtual serial lines Virtual switches Virtualized subsystems vmalloc space vmlinux file vmlinuz file VMWare technology VPNs (Virtual Private Networks) vserver project vtund Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Z] WATCHDOG option Web site requests wget for connectivity for host setup winch interrupt Wright, Chris Write-protecting hostfs directories Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Z] X11 utilities Xauthority application Xauthority file xconfig configurator xdpyinfo Xen technology xhost application 2nd xload Xnest xorg-x11-tools package 96n xterm option 2nd 3rd xterm windows XTERM_CHAN option Index [A] [B] [C] [D] [E] [F] [G] [H] [I] [J] [K] [L] [M] [N] [O] [P] [Q] [R] [S] [T] [U] [V] [W] [X] [Z] Zones, Solaris .. .User Mode Linux By Dike Jeff Publisher: Prentice Hall Pub Date: April 12, 2006 Print ISBN- 10: 0-13-186505-6 Print ISBN- 13: 978-0-13-186505-1 Pages: 352... What Is UML Used For? The Future What Is UML? User Mode Linux (UML) is a virtual Linux machine that runs on Linux Technically, UML is a port of Linux to Linux Linux has been ported to many different processors, including the... Visit us on the Web: www.prenhallprofessional.com Library of Congress Cataloging-in-Publication Data Dike, Jeff User Mode Linux / Jeff Dike p cm Includes bibliographical references and index ISBN 0-13-186505-6 (pbk