Pages

Showing posts with label Operating System. Show all posts
Showing posts with label Operating System. Show all posts

Wednesday, 17 December 2008

FreeBSD Directory Structures

Since FreeBSD uses its file systems to determine many fundamental system operations, the hierarchy of the file system is extremely important. Due to the fact that the hier(7) man page provides a complete description of the directory structure, it will not be duplicated here. Please read hier(7) for more information.
Of significant importance is the root of all directories, the / directory. This directory is the first directory mounted at boot time and it contains the base system necessary at boot time. The root directory also contains mount points for every other file system that you want to mount.
A mount point is a directory where additional file systems can be grafted onto the root file system.
Standard mount points include /usr,/var, /mnt, and /cdrom. These directories are usually referenced to entries in the file /etc/fstab. /etc/fstab is a table of various file systems and mount points for reference by the system. Most of the file systems in /etc/fstab are mounted automatically at boot time
from the script rc(8) unless they contain the noauto option. Consult the fstab(5) manual page for more information on the format of the /etc/fstab file and the options it contains.
Read more ...

Tuesday, 16 December 2008

Using LILO or GRUB Boot Loaders part 2

Permanently Changing Boot Options
You can change the options that take effect each time you boot your computer by changing the
GRUB configuration file. In Fedora and other Linux systems, GRUB configuration centers on the
/boot/grub/grub.conf file.
The /boot/grub/grub.conf file is created when you install Linux. Here’s an example of that file
for Fedora:
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making# changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,6)
# kernel /vmlinuz-version ro root=/dev/sda7
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=10
splashimage=(hd0,6)/grub/splash.xpm.gz
title Fedora (2.6.20-1.3104.fc7)
root (hd0,6)
kernel /vmlinuz-2.6.20-1.3104.fc7 ro root=LABEL=/123 rhgb quiet
initrd /initrd-2.6.20-1.3104.fc7.img
title Windows XP
rootnoverify (hd0,0)
chainloader +1
The default=0 line indicates that the first partition in this list (in this case Fedora) will be the
one that is booted by default. The line timeout=10 causes GRUB to pause for 10 seconds before
booting the default partition. (That’s how much time you have to press e if you want to edit the
boot line, or to press arrow keys to select a different operating system to boot.)
The splashimage line looks in the seventh partition on the first disk (hd0,6) for the boot partition
(in this case /dev/sda7, which is the /boot partition). GRUB loads splash.xpm.gz as the
image on the splash screen (/boot/grub/splash.xpm.gz). The splash screen appears as the
background of the boot screen.
The two bootable partitions in this example are Fedora and Windows XP. The title lines for each
of those partitions are followed by the name that appears on the boot screen to represent each
partition.
For the Fedora Linux system, the root line indicates the location of the boot partition as the second
partition on the first disk. So, to find the bootable kernel (vmlinuz-2.20-1.3104.fc7) and the
initrd initial RAM disk boot image that is loaded (initrd-2.6.20-1.3104.fc7.img), GRUB
looks in the root of hd0,6 (which is represented by /dev/sda7 and is eventually mounted as
/boot). Other options on the kernel line set the partition as read-only initially (ro) and set the
root file system to LABEL=/123.
For the Windows XP partition, the rootnoverify line indicates that GRUB should not try to mount
the partition. In this case, Windows XP is on the first partition of the first hard disk (hd0,0) or
/dev/sda1. Instead of mounting the partition and passing options to the new operating system,
the chainloader +1 indicates to hand control the booting of the operating system to another
boot loader. The +1 indicates that the first sector of the partition is used as the boot loader.
If you make any changes to the /boot/grub/grub.conf file, you do not need to load those
changes. GRUB automatically picks up those changes when you reboot your computer. If you are
accustomed to using the LILO boot loader, this may confuse you at first, as LILO requires you to
rerun the lilo command for the changes to take effect.
Adding a New GRUB Boot Image
You may have different boot images for kernels that include different features. Here is the procedure
for modifying the grub.conf file:
1. Copy the new image from the directory in which it was created (such as /usr/src/
kernels/linux-2.6.20-1/arch/i386/boot) to the /boot directory. Name the file
something that reflects its contents, such as bz-2.6.20-1. For example:
# cp /usr/src/linux-2.6.20-1/arch/i386/boot/bzImage/boot/bz-2.6.20-1
2. Add several lines to the /boot/grub/grub.conf file so that the image can be started at
boot time if it is selected. For example:
title Fedora (My own IPV6 build)
root (hd0,1)
kernel /bz-2.6.20-1 ro root=/dev/sda7
initrd /initrd-2.6.20-1.img
3. Reboot your computer.
4. When the GRUB boot screen appears, move your cursor to the title representing the new
kernel and press Enter.
The advantage to this approach, as opposed to copying the new boot image over the old one, is
that if the kernel fails to boot, you can always go back and restart the old kernel. When you feel
confident that the new kernel is working properly, you can use it to replace the old kernel or perhaps
just make the new kernel the default boot definition.
Booting Your Computer with LILO
LILO stands for LInux LOader. Like other boot loaders, LILO is a program that can stand outside
the operating systems installed on the computer so you can choose which system to boot. It alsolets you give special options that modify how the operating system is booted. On Slackware and
some other Linux systems, LILO is used instead of GRUB as the default boot loader.
If LILO is being used on your computer, it is installed in either the master boot record or the first
sector of the root partition. The master boot record is read directly by the computer’s BIOS. In general,
if LILO is the only loader on your computer, install it in the master boot record. If there is
another boot loader already in the master boot record, put LILO in the root partition.
Using LILO
When your computer boots with the Fedora version of LILO installed in the master boot record, a
graphical Fedora screen appears, displaying the bootable partitions on the computer. Use the up
and down arrow keys on your keyboard to select the one you want and press Enter. Otherwise, the
default partition that you set at installation will boot after a few seconds.
If you want to add any special options when you boot, press Ctrl+X. You will see a text-based boot
prompt that appears as follows:
boot:
LILO pauses for a few seconds and then automatically boots the first image from the default bootable
partition. To see the bootable partitions again, quickly press Tab. You may see something similar to
the following:
LILO boot:
linux linux-up dos
boot:
This example shows that three bootable partitions are on your computer, called linux, linux-up,
and dos. The first two names refer to two different boot images that can boot the Linux partition.
The third refers to a bootable DOS partition (presumably containing a Windows operating system).
The first bootable partition is loaded if you don’t type anything after a few seconds. Or you can use
the name of the other partition to have that boot instead.
If you have multiple boot images, press Shift, and LILO asks you which image you want to boot.
Available boot images and other options are defined in the /etc/lilo.conf file.
Setting Up the /etc/lilo.conf File
The /etc/lilo.conf file is where LILO gets the information it needs to find and start bootable partitions
and images. By adding options to the /etc/lilo.conf file, you can change the behavior of
the boot process. The following is an example of some of the contents of the /etc/lilo.conf file:
prompt
timeout=50
default=linux
boot=/dev/hda
map=/boot/map
install=/boot/boot.b
message=/boot/message
linear
image=/boot/vmlinuz-18-1.2798.fc6
label=linux
initrd=/boot/initrd-2.6.18-1.2798.fc6.img
read-only
root=/dev/hda6
append=”root=LABEL=/“
other=/dev/hda1
optional
label=dos
With prompt on, the boot prompt appears when the system is booted without requiring you to
press any keys. The timeout value, in this case 50 tenths of a second (5 seconds), defines how long
to wait for keyboard input before booting the default boot image. The boot line indicates that the
bootable partition is on the hard disk represented by /dev/hda (the first IDE hard disk).
Read more ...

Using LILO or GRUB Boot Loaders

A boot loader lets you choose when and how to boot the bootable operating systems installed on your computer’s hard disks. Most Linux systems give you the opportunity to use GRUB or LILO boot loaders. The following sections describe both GRUB and LILO boot loaders. Booting Your Computer with GRUB With multiple operating systems installed and several partitions set up, how does your computer know which operating system to start? To select and manage which partition is booted and how it is booted, you need a boot loader. The boot loader that is installed by default with Fedora and other Linux systems is the GRand Unified Boot loader (GRUB).
GRUB is a GNU bootloader (www.gnu.org/software/grub) that replaced LILO as the default boot loader in many Linux systems, including Fedora and Ubuntu. GRUB offers the following features:
* Support for multiple executable formats.
* Support for multi-boot operating systems (such as Fedora, FreeBSD, NetBSD, OpenBSD, and other Linux systems).
* Support for non–multi-boot operating systems (such as Windows 95, Windows 98, Windows NT, Windows ME, Windows XP, and OS/2) via a chain-loading function. Chain-loading is the act of loading another boot loader (presumably one that is specific to the proprietary operating system) from GRUB to start the selected operating system.
* Support for multiple file system types.
* Support for automatic decompression of boot images.
* Support for downloading boot images from a network.

For more information on how GRUB works, type man grub or info grub. The info command contains more details about GRUB.

Booting with GRUB
When you install Linux, you are typically given the option to configure the information needed to boot your computer (with one or more operating systems) into the default boot loader. With GRUB configured, when you boot your computer, the first thing you see after the BIOS loads is the GRUB boot screen (it says GRUB at the top and lists bootable partitions below it). Do one of the following:

* Default—If you do nothing, the default operating system will boot automatically after a few seconds. (The timeout is set by the timeout value, in seconds, in the grub.conf file.)Select an operating system—Use the up and down arrow keys to select any of the titles, representing operating systems you can boot, that are shown on the screen. Then press Enter to boot that operating system.
* Edit the boot process—If you want to change any of the options used during the boot process, use the arrow keys to highlight the operating system you want and type e to select it. Follow the next procedure to change your boot options temporarily.

If you want to change your boot options so that they take effect every time you boot your computer, see the section on permanently changing boot options. Changing those options involves editing the /boot/grub/grub.conf file.

Temporarily Changing Boot Options
From the GRUB boot screen, you can select to change or add boot options for the current boot session. First, select the operating system you want (using the arrow keys) and type e (as described earlier). You will see a graphical screen that looks like the one shown in Figure 7-2.
There are three lines in the example of the GRUB editing screen that identify the boot process for the operating system you chose. The first line (beginning with root) shows that the entry for the GRUB boot loader is on the seventh partition of the first hard disk (hd0,6). GRUB represents the hard disk as hd, regardless of whether it is a SCSI, IDE, or other type of disk. You just count the drive number and partition number, starting from zero (0).
The second line of the example (beginning with kernel) identifies the boot image (/boot/vmlinuz-
2.6.20-1.3104.fc7) and several options. The options identify the partition as initially being loaded ro (read-only) and the location of the root file system on a partition with the label root=LABEL=/123. The third line (starting with initrd) identifies the location of the initial RAM disk, which contains the minimum files and directories needed during the boot process.
If you are going to change any of the lines related to the boot process, you would probably change only the second line to add or remove boot options. Here is how you do that:

1. Position the cursor on the kernel line and type e.
2. Either add or remove options after the name of the boot image. You can use a minimal set of bash shell command-line editing features to edit the line. You can even use command completion (type part of a filename and press Tab to complete it).
3. Press Enter to return to the editing screen.
4. Type b to boot the computer with the new options. The next time you boot your computer,
the new options will not be saved. To add options so they are saved permanently,
see the next section.
Read more ...

Dual Booting with Windows or Just Linux?

It is possible to have multiple, bootable operating systems on the same computer (using multiple partitions on a hard disk and/or multiple hard disks). Setting up to boot more than one operating system, however, requires some thought. It also assumes some risks. While tools for resizing Windows partitions and setting up multi-boot systems have improved in recent years, there is still considerable risk of losing data on Windows/Linux dual-boot systems. Different operating systems often have different views of partition tables and master boot records that can cause your machine to become unbootable (at least temporarily) or lose data permanently. Always back up your data before you try to resize a Windows (NTFS or FAT) file system to make space for Linux. If you have a choice, install Linux on a machine of its own or at least on a separate hard disk.
If the computer you are using already has a Windows system on it, it’s quite possible that that the entire hard disk is devoted to Windows. While you can run a bootable Linux, such as KNOPPIX or Damn Small Linux, without touching the hard disk, to do a more permanent installation you’ll want to find disk space outside of the Windows installation. There are a few ways to do this:

* Add a hard disk—Instead of messing with your Windows partition, you can simply add a hard disk and devote it to Linux.
* Resize your Windows partition—If you have available space on your Windows partition, you can shrink that partition so there is available free space on the disk to devote to Linux. Commercial tools such as Partition Magic from Symantec (www.symantec.com) or Acronis Disk Director (www.acronis.com) are available to resize your disk partitions and set up a workable boot manager. Some Linux distributions (particularly bootable Linuxes used as rescue CDs) include a tool called QTParted that is an open source clone of Partition Magic (which includes software from the Linux-NTFS project for resizing Windows NTFS partitions).

Before you try to resize your Windows partition, you might need to defragment it. To defragment your disk on some Windows systems, so that all of your used space is put in order on the disk, open My Computer, right-click your hard disk icon (typically C:), select Properties, click Tools, and select Defragment Now.
Defragmenting your disk can be a fairly long process. The result of defragmentation is that all the
data on your disk are contiguous, creating a lot of contiguous free space at the end of the partition. There are cases where you will have to do the following special tasks to make this true:

* If the Windows swap file is not moved during defragmentation, you must remove it. Then, after you defragment your disk again and resize it, you will need to restore the swap file. To remove the swap file, open the Control Panel, open the System icon, and then click the Performance tab and select Virtual Memory. To disable the swap file, click Disable Virtual Memory.
* If your DOS partition has hidden files that are on the space you are trying to free up, you need to find them. In some cases, you won’t be able to delete them. In other cases, such as swap files created by a program, you can safely delete those files. This is a bit tricky because some files should not be deleted, such as DOS system files. You can use the attrib -s -h command from the root directory to deal with hidden files.

Once your disk is defragmented, you can use one of the commercial tools described earlier (Partition Magic or Acronis Disk Director) to repartition your hard disk to make space for Linux. An open source alternative to those tools is QTParted.
Boot KNOPPIX or any of several other bootable Linux distributions (particularly rescue CDs) and run QTParted by selecting System Tools➪QTParted from the desktop main menu. From the QTParted window, select the hard disk you want to resize. Then choose Options➪Configuration to open a window where you can select the ntfsresize tool to resize your NTFS partition.
After you have cleared enough disk space to install Linux (see the disk space requirements in the
chapter covering the Linux distribution you’re installing), you can choose your Linux distribution
and install it. As you set up your boot loader during installation, you will be able to identify the Windows, Linux, and any other bootable partitions so that you can select which one to boot when
your start your computer.
Read more ...

Choosing a Linux Distribution

Dozens of popular Linux distributions are available today. Some are generalized distributions that you can use as a desktop, server, or workstation system; others are specialized for business or computer enthusiasts.
Linux at Work
Because I know a lot of people who use Linux, both informally and at work, I want to share my general impressions of how different Linux distributions are being used in the United States. Most consultants I know who set up small office servers used to use Red Hat Linux, but now have mostly moved to Fedora, CentOS (built from Red Hat Enterprise Linux software), Ubuntu, or Debian GNU/Linux. Mandriva Linux (formerly Mandrakelinux) has been popular with people wanting a friendly Linux desktop, but Fedora is also well-liked. The more technically inclined like to play with Gentoo (highly tunable) or Slackware (Linux in a more basic form).
The agreement between Novell and Microsoft at the end of 2006 prompted some open source proponents to abandon SUSE. Whether this will result in a migration from SUSE in the enterprise space, however, has yet to play out. However, right now, Red Hat Enterprise Linux offers the best choice in the enterprise realm for those who object to the alliance.
For people transitioning to Linux with Macintosh hardware, Yellow Dog Linux lets you install on a PowerPC and learn skills that are useful to expand later to Red Hat systems. (Yellow Dog was originally based on Red Hat Linux.) As for the bootable Linuxes, everyone I know thinks they are great fun to try out and a good way to learn about Linux. For a bootable Linux containing desktop software that fits on a full CD (or DVD), KNOPPIX is a good choice, as is Ubuntu; for a bootable mini–CD size Linux, Damn Small Linux works well. However, you can also try out these live CDs from the media that come with this book: INSERT, Puppy Linux, SLAX Popcorn, System Rescue CD, or BackTrack.
You can also try to connect in to the growing Linux user communities because strong community
support results in a more solid software distribution and help when you need it (from such things
as forums and online chats).
Read more ...

Installing Linux

If someone hasn’t already installed and configured a Linux system for you, this chapter is going to help you get started so you can try out the Linux features described in the rest of the book. With recent improvements to Linux live CDs and installers, getting your hands on a working Linux system is quicker and more solid than ever before. If you are a first-time Linux user, I recommend that you:* Try a bootable Linux—This book’s CD and DVD include several bootable Linux systems. The advantage of a bootable Linux is that you can try out Linux without touching the contents of your computer’s hard drive. In particular, KNOPPIX is a full-featured Linux system that can give you a good feel for how Linux works. Using the DVD or CD, you can try out several different live CDs, as described in Appendix A. Some of these live CDs also include features for installing Linux to your hard disk. Although live CDs tend to run slower than installed systems and don’t keep your changes once you reboot, they are good tools for starting out with Linux.

* Install a desktop Linux system—Choose one of the Linux distributions and install it on your computer’s hard disk. Permanently installing Linux to your hard disk gives you more flexibility for adding and removing software, accessing and saving data to hard disk, and more permanently customizing your system. Installing Linux as a desktop system lets you try out some useful applications and get the feel for Linux before dealing with more complex server issues.

This chapter provides you with an overview of how to choose a Linux distribution, and then describes issues and topics that are common to installing most Linux distributions. Appendix A describes which Linux distributionsare included on this book’s DVD and CD and how to run them live or use them to install Linux permanently. Each of the other chapters in this part of the book is dedicated to understanding and installing a particular Linux distribution.
After you’ve installed Linux, you’ll want to understand how to get and manage software for your Linux system. These are important topics that are covered throughout the book, but this chapter describes the major packaging formats and tools to get you going.

Read more ...