We'll take a good look at disk-oriented aspects of Gentoo Linux and Linux in general, including Linux filesystems, partitions and block devices. Then, once you're familiar with the ins and outs of disks and filesystems, you'll be guided through the process of setting up partitions and filesystems for your Gentoo Linux installation.
To begin, we'll introduce
The block devices above represent an abstract interface to the disk. User programs can use these block devices to interact with your disk without worrying about whether your drives are IDE, SCSI or something else. The program can simply address the storage on the disk as a bunch of contiguous, randomly-accessible 512-byte blocks.
Although it is theoretically possible to use a full disk to house your Linux
system, this is almost never done in practice. Instead, full disk block devices
are split up in smaller, more manageable block devices. On
Itanium systems use EFI, the Extensible Firmware Interface, for booting. The partition table format that EFI understands is called GPT, or GUID Partition Table. The partitioning program that understands GPT is called "parted", so that is the tool we will use below. Additionally, EFI can only read FAT filesystems, so that is the format to use for the EFI boot partition, where the kernel will be installed by "elilo".
The
If you are not interested in drawing up a partitioning scheme for your system, you can use the partitioning scheme we use throughout this book:
| Partition | Filesystem | Size | Description |
|---|---|---|---|
If you are interested in knowing how big a partition should be, or even how
many partitions you need, read on. Otherwise continue now with partitioning
your disk by reading
The number of partitions is highly dependent on your environment. For instance,
if you have lots of users, you will most likely want to have your
As you can see, it very much depends on what you want to achieve. Separate partitions or volumes have the following advantages:
However, multiple partitions have one big disadvantage: if not configured properly, you might result in having a system with lots of free space on one partition and none on another. There is also a 15-partition limit for SCSI and SATA.
As an example partitioning, we show you one for a 20GB disk, used as a demonstration laptop (containing webserver, mailserver, gnome, ...):
$ df -h Filesystem Type Size Used Avail Use% Mounted on /dev/hda5 ext3 509M 132M 351M 28% / /dev/hda2 ext3 5.0G 3.0G 1.8G 63% /home /dev/hda7 ext3 7.9G 6.2G 1.3G 83% /usr /dev/hda8 ext3 1011M 483M 477M 51% /opt /dev/hda9 ext3 2.0G 607M 1.3G 32% /var /dev/hda1 ext2 51M 17M 31M 36% /boot /dev/hda6 swap 516M 12M 504M 2% <not mounted>(Unpartitioned space for future usage: 2 GB)
The following parts explain how to create the example partition layout described previously, namely:
| Partition | Description |
|---|---|
Change your partition layout according to your own preference.
# parted /dev/sda
Once in
GNU Parted 1.6.22 Copyright (C) 1998 - 2005 Free Software Foundation, Inc. This program is free software, covered by the GNU General Public License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. Using /dev/sda (parted)
At this point one of the available commands is
(parted) print Disk geometry for /dev/sda: 0.000-34732.890 megabytes Disk label type: gpt Minor Start End Filesystem Name Flags 1 0.017 203.938 fat32 boot 2 203.938 4243.468 linux-swap 3 4243.469 34724.281 ext3
This particular configuration is very similar to the one that we recommend above. Note on the second line that the partition table is type is GPT. If it is different, then the ia64 system will not be able to boot from this disk. For the sake of this guide we'll remove the partitions and create them anew.
The easy way to remove all partitions and start fresh, which guarantees that we
are using the correct partition type, is to make a new partition table using the
(parted) mklabel gpt (parted) print Disk geometry for /dev/sda: 0.000-34732.890 megabytes Disk label type: gpt Minor Start End Filesystem Name Flags
Now that the partition table is empty, we're ready to create the partitions. We will use a default partitioning scheme as discussed previously. Of course, don't follow these instructions to the letter if you don't want the same partitioning scheme!
We first create a small EFI boot partition. This is required to be a FAT filesystem in order for the ia64 firmware to read it. Our example makes this 32 megabytes, which is appropriate for storing kernels and elilo configuration. You can expect each ia64 kernel to be around 5 megabytes, so this configuration leaves you some room to grow and experiment.
(parted) mkpart primary fat32 0 32 (parted) print Disk geometry for /dev/sda: 0.000-34732.890 megabytes Disk label type: gpt Minor Start End Filesystem Name Flags 1 0.017 32.000 fat32
Let's now create the swap partition. The classic size to make the swap partition was twice the amount of RAM in the system. In modern systems with lots of RAM, this is no longer necessary. For most desktop systems, a 512 megabyte swap partition is sufficient. For a server, you should consider something larger to reflect the anticipated needs of the server.
(parted) mkpart primary linux-swap 32 544 (parted) print Disk geometry for /dev/sda: 0.000-34732.890 megabytes Disk label type: gpt Minor Start End Filesystem Name Flags 1 0.017 32.000 fat32 2 32.000 544.000
Finally, let's create the root partition. Our configuration will make the root partition to occupy the rest of the disk. We default to ext3, but you can use ext2, jfs, reiserfs or xfs if you prefer. The actual filesystem is not created in this step, but the partition table contains an indication of what kind of filesystem is stored on each partition, and it's a good idea to make the table match your intentions.
(parted) mkpart primary ext3 544 34732.890 (parted) print Disk geometry for /dev/sda: 0.000-34732.890 megabytes Disk label type: gpt Minor Start End Filesystem Name Flags 1 0.017 32.000 fat32 2 32.000 544.000 3 544.000 34732.874
To quit from parted, type
(parted) quit Information: Don't forget to update /etc/fstab, if necessary.
Now that your partitions are created, you can now continue with
Now that your partitions are created, it is time to place a filesystem on them.
If you don't care about what filesystem to choose and are happy with what we use
as default in this handbook, continue with
The Linux kernel supports various filesystems. We'll explain vfat, ext2, ext3, ReiserFS, XFS and JFS as these are the most commonly used filesystems on Linux systems.
vfat is the MS-DOS filesystem, updated to allow long filenames. It is also the only filesystem type that the EFI firmware on ia64 systems understand. The boot partition on ia64 systems should always be vfat, but for your data partitions you should use one of the other filesystems listed below.
ext2 is the tried and true Linux filesystem but doesn't have metadata journaling, which means that routine ext2 filesystem checks at startup time can be quite time-consuming. There is now quite a selection of newer-generation journaled filesystems that can be checked for consistency very quickly and are thus generally preferred over their non-journaled counterparts. Journaled filesystems prevent long delays when you boot your system and your filesystem happens to be in an inconsistent state.
ext3 is the journaled version of the ext2 filesystem, providing metadata journaling for fast recovery in addition to other enhanced journaling modes like full data and ordered data journaling. It uses a hashed B*-tree index that enables high performance in almost all situations. In short, ext3 is a very good and reliable filesystem.
ReiserFS is a B*-tree based filesystem that has very good overall performance and greatly outperforms both ext2 and ext3 when dealing with small files (files less than 4k), often by a factor of 10x-15x. ReiserFS also scales extremely well and has metadata journaling. ReiserFS is solid and usable as both general-purpose filesystem and for extreme cases such as the creation of large filesystems, very large files and directories containing tens of thousands of small files.
XFS is a filesystem with metadata journaling which comes with a robust feature-set and is optimized for scalability. We only recommend using this filesystem on Linux systems with high-end SCSI and/or fibre channel storage and an uninterruptible power supply. Because XFS aggressively caches in-transit data in RAM, improperly designed programs (those that don't take proper precautions when writing files to disk and there are quite a few of them) can lose a good deal of data if the system goes down unexpectedly.
JFS is IBM's high-performance journaling filesystem. It has recently become production-ready and there hasn't been a sufficient track record to comment positively nor negatively on its general stability at this point.
To create a filesystem on a partition or volume, there are tools available for each possible filesystem:
| Filesystem | Creation Command |
|---|---|
For instance, to have the boot partition (
# mkdosfs /dev/sda1 # mke2fs -j /dev/sda3
# mkswap /dev/sda2
To activate the swap partition, use
# swapon /dev/sda2
Create and activate the swap with the commands mentioned above.
Now that your partitions are initialized and are housing a filesystem, it is
time to mount those partitions. Use the
# mount /dev/sda3 /mnt/gentoo
We will also have to mount the proc filesystem (a virtual interface with the
kernel) on
Continue with