07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BACK TO BASICS<br />

Master boot record<br />

The Master Boot Record (MBR) occupies the first 512 bytes of the first hard<br />

disk, and is the first thing loaded by the BIOS to hand over control to a program<br />

capable of booting the desired operating system. In general, a bootloader<br />

is installed in the MBR, removing its previous content.<br />

8.8.1. Identifying the Disks<br />

CULTURE<br />

udev, devfs and /dev/<br />

The /dev/ directory traditionally houses so-called “special” files, intended to<br />

represent system peripherals (see sidebar “Device access permissions” (page<br />

158)). /dev/hda1 thus always corresponds to the first partition of the the first<br />

IDE hard drive. This static structure does not allow dynamic seing of “major”<br />

and “minor” numbers for these files, which forces kernel developers to<br />

limit their number, since a priori assignment of the identifiers prohibits adding<br />

more once these conventions are established.<br />

To take into account the characteristics of more and more dynamic, modern<br />

computers, the kernel has, at some time, offered an implementation of /dev/<br />

by a virtual filesystem called devfs. In some cases, this makes it easier to<br />

find files, since the naming convention uses a hierarchical structure: the first<br />

partition of the master hard drive on the first IDE bus was then represented<br />

by the file, /dev/ide/host0/bus0/target0/lun0/part1. Not only were these<br />

naming conventions not very intuitive, but they were also hard-coded into the<br />

kernel which presented problems for hot-pluggable drives because the corresponding<br />

special file name would vary.<br />

The current solution is the second incarnation of the process, udev, with which<br />

the kernel delegates the choice of the device file names to be created to a<br />

program in user space. This program (udevd) can then have all of the flexibility<br />

of user space to decide what actions to take, naming of peripherals, etc.<br />

With udev (user-space /dev/), a filesystem is stored in RAM and generated<br />

automatically by udevd (and it hides the content of any /dev/ that may be<br />

stored on-disk). udevd collaborates with the kernel's hotplug sub-system (see<br />

Section 9.11, “Hot Plugging: hotplug” (page 213)) to detect the appearance<br />

(hotplugging) of devices, then dynamically creates the corresponding special<br />

files in /dev/. The content of /dev/ is, thus, lost on each reboot, but udev<br />

recreates it systematically.<br />

This mechanism allows the machine to dynamically choose the file name. You<br />

can thus keep the same name for a given device, regardless of the connector<br />

used or the connection order, which is especially useful when you use various<br />

USB peripherals. The partition system on the first IDE hard drive can then be<br />

called /dev/hda1 for backwards compatibility, or /dev/root-partition if you<br />

prefer, or even both at the same time since udevd can be configured to automatically<br />

create a symbolic link. Furthermore, /dev/ no longer contains useful<br />

files at this time. Previously, some kernel modules did not automatically load<br />

when you tried to access the corresponding peripheral; henceforth, the peripheral's<br />

special file no longer exists prior to loading the module, which is no<br />

big deal, since most modules are loaded on boot thanks to automatic hardware<br />

detection. But for undetectable peripherals (such as older disk drives or<br />

PS/2 mice), this doesn't work. Consider adding the modules, floppy, psmouse<br />

and mousedev to /etc/modules in order to force loading them on boot.<br />

Chapter 8 — Basic Configuration: Network, Accounts, Printing…<br />

161

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!