Linux.Desktop.Hacks [Electronic resources] نسخه متنی

اینجــــا یک کتابخانه دیجیتالی است

با بیش از 100000 منبع الکترونیکی رایگان به زبان فارسی ، عربی و انگلیسی

Linux.Desktop.Hacks [Electronic resources] - نسخه متنی

Jono Bacon, Nicholas Petreley

| نمايش فراداده ، افزودن یک نقد و بررسی
افزودن به کتابخانه شخصی
ارسال به دوستان
جستجو در متن کتاب
بیشتر
تنظیمات قلم

فونت

اندازه قلم

+ - پیش فرض

حالت نمایش

روز نیمروز شب
جستجو در لغت نامه
بیشتر
لیست موضوعات
توضیحات
افزودن یادداشت جدید






Hack 1. Give Your Computer the Boot

The beginning of all
Linux
journeys originates with the humble bootloaderthe small bit of
code that jump-starts the whole boot process. Knowing how to
configure your bootloader is almost requisite for using a Linux
system. You also need to understand the bootloader if you want to
configure your system to boot more than one operating system.

Within the exciting bootloader world
are a number of choices for
starting your computer. For x86 machines, there are two main
contenders: LILO and
GRUB. If you are running Linux on a Mac, LILO
and GRUB are not available, and the main
bootloader
is called yaboot. Another potential situation in which you might need
to boot a computer is when you are trying to boot a CD to install an
operating system. Sometimes you can encounter a problem booting from
a CD if your computer's BIOS does not support
booting from CD-ROM or if your CD-ROM drive does not support booting
from a CDR. You can resolve this problem with a tool called the Smart
Boot Manager.

This hack explores the GRUB, yaboot, and Smart Boot Manager
bootloaders.


1.2.1. Configure GRUB


Without a doubt, GRUB is a far
more flexible boot manager than LILO. It enables you to add new
kernels or boot parameters without having to install each update to
the Master
Boot Record (MBR). GRUB also allows you to pass parameters to it or
to the kernel at boot time. Many Linux distributions now ship with
GRUB as the default bootloader. Although GRUB is reliable and
flexible enough to recover from most disasters, it is still advisable
to back up your boot sector just in case something goes wrong. To do
this, run the following command:

root@bar:~# dd if=/dev/hda of=/root/hda.mbr bs=512 count=1

GRUB is managed by a central configuration file which is either
/boot/grub/menu.lst on Debian and Gentoo
systems, or /etc/grub/grub.conf on Red Hat-based
systems. This file contains a number of entries that indicate the
name of the kernel, the root partition where the kernel can be found,
and an initrd if one applies. Here is an example
of a typical Linux kernel stanza in the GRUB configuration file:

title           Ubuntu, kernel 2.6.8.1-2-386
root (hd0,0)
kernel /vmlinuz-2.6.8.1-2-386 root=/dev/hda3 ro quiet splash
initrd /initrd.img-2.6.8.1-2-386
savedefault
boot

It's important to note how GRUB deals with disks and
partition numbers. Unlike Linux, GRUB refers to the first disk as
hd0 and the first partition as partition
0. In Linux this is designated as
/dev/hda1. Basically, if the letters that
designate the hard drive in Linux were numbers, you would subtract 1
from them. Therefore, an a (1) becomes 0, a
b (2) becomes 1, and so on. Also, you would
subtract 1 from the partition number itself. For example, a boot
partition located on /dev/hdb3 becomes
hd1,2 in GRUB parlance. In the previous stanza,
you refer to the location of the kernel (root) as
hd0,0, but on the kernel line, you refer to the
root partition as /dev/hda3. Because it is a
kernel parameter, it uses the normal Linux method of referring to
disks and partitions. The final part of the stanza uses
savedefault to make the stanza a default option in
the GRUB menu, and the command boot actually boots
the system.

If you want to add another operating system, simply add it elsewhere
in the configuration file. A Windows stanza looks like this:

title         Windows 95/98/NT/2000
root (hd0,0)
makeactive
chainloader +1

When you are booting
non-Linux operating systems (most likely Windows),
you usually will need to use the makeactive and
chainloader keywords. The
makeactive keyword is used to set this partition
as GRUB's main root filesystem device. The
chainloader command is used so that the bootloader
can call another bootloader (usually the Windows boot manager)
instead of loading a Linux kernel.

If your boot manager is hidden,
it is probably because your
distribution set it to be hidden. Look for the parameter
hiddenmenu in your grub.conf
file, and comment it out if you want to see your boot
menu. You might also have a default option, which
specifies the stanza in the file you want to be your default boot
configuration. As an example, if you want the first stanza to be the
default, use this:

default     0


1.2.2. Configure the Mac Bootloader


Mac versions of Linux
use
a different bootloader called yaboot. Although not quite as flexible
as GRUB, yaboot takes a similar stanza-based approach to specifying
kernels. Here is a typical Linux kernel on the first partition (you
should adjust the path on the image line when your
kernel is located elsewhere):

image=/vmlinux-2.6.8.1
label=NewLinux
read-only
append="quiet splash"
initrd=/initrd.img-2.6.8.1

To enable your system to boot Mac OS X as well, simply add the
following option to /etc/yaboot.conf and
indicate the correct partition that contains Mac OS X (you can
determine the right partition by running a partitioning tool such as
cfdisk):

macosx=/dev/
hda4

When you have edited the file, you need to run the
ybin program to write the boot sector. If you
use the -v option, you can see the output of the
command:

root@bar:~# ybin -v


1.2.3. Boot from a CD-ROM


The vast majority of Linux
distributions are available on CD. Their
installation program loads automatically when you boot the computer
with the CD in the drive. On newer machines, this process is not a
problem (though you might need to enter your BIOS setup program and
select the CD drive as the first bootable device). On older
computers, this can be an issue because some computers do not support
a bootable CD drive. Another common complaint with old secondhand
computers is that the BIOS might be password-protected but no one
knows the password. This means you can't make the CD
drive the first boot device.

Many Linux distributions get around this problem by including a
floppy-disk boot image that you
can use to create boot floppies. These
floppies "jump-start" the
installation process and give access to the CD despite any hardware
shortcomings. The CDs usually include a tool called
rawrite that can be used to copy the boot images
to the floppies. If this works with your distribution, the problem is
solved, but unfortunately not all distributions include a floppy boot
image.

Another solution is to use a tool
called the Smart Boot Manager
(http://btmgr.sourceforge.net).
This useful little utility creates a boot sector on a floppy disk
that allows you to boot from the CD and use the CD installation
program. To use the Smart Boot Manager, you need to download it from
http://btmgr.sourceforge.net/downloadl
and unpack it to your disk. I recommend downloading the latest
version that is statically linked. The software includes a program
you can use to install the Smart Boot Manager to the floppy disk in
/dev/fd0:

foo@bar:~$ sbminst -t us -d /dev/fd0

This command installs the English theme into the boot sector on
device /dev/fd0. A number of different languages
are supported across the different themes. These include:

cz = Czech theme

de = German theme

es = Spanish theme

fr = French theme

hu = Hungarian theme

pt = Portuguese theme

ru = Russian theme

us = English theme

zh = Chinese theme


When you boot into the Smart Boot Manager, you can configure the
software from within the program with a simple-to-use text-based
windowing interface.


/ 140