March 13th, 2008
Chapter 29. File-Tree Organization Nowadays, a UNIX system is big, very big. This is especially true of GNU/Linux: the amount of software available would make for an unmanageable system if no guidelines for the location of files in the tree existed. The acknowledged standard is the FHS (Filesystem Hierarchy Standard) for which version 2.3 was released in January 2004. The document which describes the standard is available on the Internet in different formats on The Pathname web site [http://www.pathname.com/fhs/]. This chapter will only provide a brief summary, but it should be enough to show you which directory is likely to contain a given file, or where a given file should be placed. 1. Shareable/unshareable, Static/Variable Data Data on a UNIX system can be classified according to the following criteria: shareable data may be common to several computers in a network, while unshareable cannot. Static data must not be modified in normal use, while variable data may be. As we explore the tree structure, we will classify the different directories into each of these categories. These classifications are only a recommendation. It’s not mandatory to follow them, but adopting these guidelines will greatly help you manage your system. Also, bear in mind that the static/variable distinction only applies to general system usage, not its configuration. If you install a program, you will obviously have to modify normally static directories, such as /usr. 2. The root Directory: / The root directory contains the entire system hierarchy. It cannot be classified since its sub-directories may or may not be static or shareable. Here is a list of the main directories and sub-directories, with their classifications: /bin: essential binary files. It contains the basic commands which will be used by all users and which are necessary for the operation of the system: ls, cp, login, etc. Static, unshareable. /boot: contains the files required by the GNU/Linux bootloader (GRUB or LILO for Intel, yaboot for PPC, etc). It may or may not contain the kernel, but if the kernel isn’t located in this directory then it must be in the root directory. Static, unshareable.
Posted in Linux | No Comments »
March 13th, 2008
2. Conventions for Naming Disks and Partitions names the partitions even if it doesn’t know how to manage them initially (it ignores the fact that they’re not native GNU/Linux partitions). Mandriva Linux now uses udev (refer to the udev FAQ [http://www. kernel.org/pub/linux/utils/kernel/hotplug/udev-FAQ] for more information). It ensures full compatibility with the scheme described above and with standards like the Linux Standards Base Project [http://www. linuxbase.org/]. Each device is dynamically added to the system as soon as it becomes available or needed.
Posted in Linux | No Comments »
March 12th, 2008
2. Conventions for Naming Disks and Partitions Logical partitions, if any, are named /dev/hda5, /dev/hda6, etc. in the order of their appearance in the table of logical partitions. So GNU/Linux will name the partitions as follows: First Primary Partition /dev/hda1 Primary Master IDE Hard Disk (/dev/hda) First Primary Partition Second Primary Partition /dev/hdb1 /dev/hdb2 Primary Slave IDE Hard Disk (/dev/hdb) Figure 28.1. First Example of Partition Naming under GNU/Linux Extended PartitionPrimary Partition 2nd Logical Partition1st Logical Partition (/dev/hda2) /dev/hda1 /dev/hda5 /dev/hda6 Primary Master IDE Hard Disk (/dev/hda) First Primary Partition Second Primary Partition /dev/hdb1 /dev/hdb2 Primary Slave IDE Hard Disk (/dev/hdb) Figure 28.2. Second Example of Partition Naming under GNU/Linux With this knowledge in hand, you should be able to name your various partitions and hard disks when you need to manipulate them. You’ll also see that GNU/Linux
Posted in Linux | No Comments »
March 11th, 2008
2. Conventions for Naming Disks and Partitions It is possible to resize most partitions; if you do need to resize them or to use a different partition scheme, without the need to reinstall your system and without losing your data. Please consult Section 1, Managing your Hard Drive Partitions with DiskDrake [303]. With some practice, you’ll even be able to move a crowded partition to a brand new hard drive. 2. Conventions for Naming Disks and Partitions GNU/Linux uses a logical method to name partitions. First, when numbering the partitions, it ignores the file-system type of any partition you may have. Second, it names the partitions according to the disk on which they are located. This is how the disks are named: The primary master and primary slave IDE devices (whether they be hard disks, CD-ROM drives or anything else) are called /dev/hdaand /dev/hdb respectively. On the secondary interface, the master is called /dev/hdc and the slave is /dev/hdd. If your computer contains other IDE interfaces (for example, the IDE interface present on some Soundblaster cards), the disks will be called /dev/hde, /dev/hdf, etc. You may also have additional IDE interfaces if you have RAID controllers. SCSI disks are called /dev/sda, /dev/sdb, etc., in the order of their appearance on the SCSI chain (depending on the increasing IDs). The SCSI CD-ROM drives are called /dev/scd0, /dev/scd1, always in the order of their appearance on the SCSI chain. If you have SATA IDE disks, the SCSI naming scheme applies. The partitions are named after the disk on which they’re found, in the following way (in our example, we’ve used partitions on a primary master IDE disk but the same applies to all other types of disks): The primary (or extended) partitions are named /dev/hda1 through /dev/hda4, when present.
Posted in Linux | No Comments »
March 11th, 2008
1.3. Defining the Structure of Your Disk Root: / The most important partition. Not only does it contain critical data and programs for the system, it also acts as a mount point for other partitions (see Chapter 32, File Systems and Mount Points [433]). The needs of the root partition in terms of size are not great, 400MB is generally enough. However, if you plan to install commercial applications, which are often located in the /opt directory, you will need to increase the size of the root partition accordingly. Alternatively, you could create a separate partition for /opt. Static data: /usr Most packages install the majority of their executables and data files under the /usr directory. The advantage of creating a separate partition is that it allows you to easily share it with other machines over a network. The recommended size depends on the packages you wish to install, and can vary from 100MB for a very lightweight installation, to several GB for a full installation. A compromise of two or three GB (depending on your disk size) is usually sufficient. Home directories: /home This directory contains the personal directories for all of the users hosted on your machine. The partition size depends on the number of users hosted and their needs. Another solution is to not create a separate partition for the /usr files: /usr could simply be a directory inside the root (/) partition, however you would need to increase the size of your root (/) partition accordingly. Finally, you could also only create the Swap and root (/) partitions, in case you’re not sure what you want to do with your computer. In this case, your /home directory would be located on the root partition, as would the /usr and the other directories. 1.3.3. Exotic Configurations When setting up your machine for specific uses such as a web server or a fire- wall the needs are radically different to that of a standard desktop machine. For example, a FTP server will probably need a large separate partition for /var/ftp, while the /usr directory could be relatively small. In these situations, you’re encouraged to carefully think about your needs before even beginning the installation process.
Posted in Linux | No Comments »
March 9th, 2008
1.3. Defining the Structure of Your Disk Because physical errors on a hard disk are generally located on adjacent sectors, not scattered across the disk, distributing your files across different partitions could limit data loss if your hard disk is physically damaged. Normally, the partition type specifies the file system which the partition is supposed to contain. Each operating system might recognize some partition types, but not others. Please see Chapter 32, File Systems and Mount Points [433], and Chapter 30, The Linux File System [407], for more information. 1.3. Defining the Structure of Your Disk 1.3.1. The Simplest Way This scenario would imply only two partitions: one for the Swap space, the other one for the files1, called root and labelled as /. A rule of thumb is to set the swap partition size to twice the size of your RAM memory (i.e.: if you have 128 MB of RAM memory the swap size should be of 256 MB). However for large memory configurations (512 MB or more), this rule isn’t critical, and smaller sizes are acceptable. Please bear in mind that the swap partition’s size may be limited depending on which platform you are using. For example it is limited to 2GB in x86, PowerPC and MC680×0; to 512MB on MIPS; to 128GB on Alpha and to 3TB on Ultrasparc. Bear in mind also that the larger the swap partition, the greater the amount of OS resources (notably RAM memory) needed to manage it. 1.3.2. Another Common Scheme Separate data from programs. To be even more efficient, one usually defines more partitions to separate the system and programs from the data. The system partition will contain the programs required to start your system and to perform basic maintenance. Therefore we could define four partitions: Swap A Swap partition whose size is roughly twice the size of physical RAM. The default file system used by Mandriva Linux is called ext3
Posted in Linux | No Comments »
March 8th, 2008
Chapter 28. Disks and Partitions This chapter contains information for those who simply wish to know more about the technical details underlying their system. It will give a complete description of the PC partitioning scheme. Therefore it will be most useful if you are planning to manually configure your hard drive partitions. 1. Structure of a Hard Disk A disk is physically divided into sectors. A sequence of sectors can form a partition. Roughly speaking, you can create as many partitions as you wish, up to 67 (3 primary partitions and a secondary partition containing up to 64 logical partitions inside): each partition is regarded as a single hard drive. 1.1. Sectors To simplify, a hard disk is merely a sequence of sectors, which are the smallest data unit on a hard disk. The typical size of a sector is 512 bytes. The sectors on a hard disk of n sectors are numbered from 0 to n-1 . 1.2. Partitions The use of multiple partitions enables you to create many virtual hard drives on your real physical drive. This has many advantages: Different operating systems use different disk structures (called file systems): this is the case with Windows and GNU/Linux. Having multiple partitions on a hard drive also allows you to install various operating systems on the same physical drive. For performance reasons, an operating system may prefer different drives with various file systems on them because they may be used for completely different things. One example is GNU/Linux which requires a second partition called Swap. The latter is used by the virtual memory manager as virtual memory. Even if all of your partitions use the same file system, it may prove useful to separate the different parts of your OS into different partitions. A simple configuration example would be to split your files into two partitions: one for your personal data, and another one for your programs. This allows you to update your OS, completely erasing the partition containing the programs while keeping the data partition safe.
Posted in Linux | No Comments »
March 8th, 2008
Posted in Linux | No Comments »
March 7th, 2008
4.6. Useful Keyboard Shortcuts First: the arrow keys. bash maintains a history of previous commands which you can view with the up and down arrow keys. You can scroll up to a maximum number of lines defined in the HISTSIZE environment variable. In addition, the history is persistent from one session to another, so you won’t lose all the commands you typed in previous sessions. The left and right arrow keys move the cursor left and right on the current line, allowing you to edit your commands. But there’s more to editing than just moving one character at a time: Ctrl A and Ctrl -E , for example, will take you to the beginning and the end of the current line. The Backspace and Del keys work as expected. Ctrl Ctrl -K will delete from the position of the cursor to the end of line, and -W will delete the word before the cursor (so will Alt Backspace ). Typing Ctrl -D on a blank line will let you close the current session, which is much shorter than having to type exit. Ctrl - C will interrupt the currently running command, except if you were in the process of editing your command line, in which case it will cancel the editing and put you back to the prompt. Ctrl -L clears the screen. Ctrl -Z temporarily stops a task, it suspends it. This shortcut is very useful when you forget to type the & character after typing a command. For instance: $ xpdf MyDocument.pdf Hence you cannot use your shell anymore since the foreground task is allocated to the xpdf process. To put that task in the background and restore your shell, simply type Ctrl Z and then enter the bg command. - Finally, there are Ctrl S and Ctrl -Q, which are used to suspend and restore output to the screen. They are not used often, but you might type Ctrl -S by mistake (after all, S and D are close to each other on the keyboard). So, if you get into the situation where you’re typing but you can’t see any characters appearing on the Terminal, try Ctrl - Ctrl -S and Ctrl - Q . Note that all the characters you typed between the unwanted Q will be printed to the screen all at once.
Posted in Linux | No Comments »
March 6th, 2008
4.6. Useful Keyboard Shortcuts If no file or directory is specified on the command line, ls will list files in the current directory. Its options are numerous, so we will only describe a few of them: -a: lists all files, including hidden files. Remember that in UNIX, hidden files are those whose names begin with a .; the -A option lists almost all files, which means every file the -a option would print except for . and .. -R: lists recursively, i.e. all files and sub-directories of directories entered on the command line. -h: if the file size is shown, it is in a human readable format, next to each file. It means that you’ll see file sizes using suffixes like K , M and G , for example 234K and 132M . Please also note that sizes are referred in a power of 2, not a power of 10. It means that 1K is really 1024 bytes instead of 1000 bytes. -l: prints additional information about the files such as the permissions associated to it, the owner and owner group, the file’s size and the last-modification time. -i: prints the inode number (the file’s unique number in the file system, see Chapter 30, The Linux File System [407]) next to each file. -d: treats directories on the command line as if they were normal files rather than listing their contents. Here are some examples: ls -R: recursively lists the contents of the current directory. ls -ih images/ ..: lists the inode number and the size, in human-readable format, for each file in the images/ directory as well as in the parent directory of the current one. ls -l images/*.png: lists all files in the images/ directory whose names end with .png, including the file .png, if it exists. 4.6. Useful Keyboard Shortcuts There are a number of shortcuts available, their primary advantage being that they may save you a lot of typing time. This section assumes you’re using the default shell provided with Mandriva Linux, bash, but these keystrokes might work with other shells too.
Posted in Linux | No Comments »