We'll take a good look at some of the 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 introduce
Block devices 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.
Block devices show up as entries in
Although it is theoretically possible to use the entire 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. These are known as
The first partition on the first SCSI disk is
The third partition on Sun systems is set aside as a special "whole disk" slice. This partition must not contain a file system.
Users who are used to the DOS partitioning scheme should note that Sun disklabels do not have "primary" and "extended" partitions. Instead, up to eight partitions are available per drive, with the third of these being reserved.
If you are not interested in drawing up a partitioning scheme,
the table below suggests a suitable starting point for most systems. For
IDE-based systems, substitute
Note that a separate
| Partition | Filesystem | Size | Mount Point | Description |
|---|---|---|---|---|
The following parts explain how to create the example partition layout described previously, namely:
| Partition | Description |
|---|---|
Change the partition layout as required. Remember to keep the root partition entirely within the first 2 GBytes of the disk for older systems. There is also a 15-partition limit for SCSI.
Start
# fdisk /dev/sda
You should be greeted with the fdisk prompt:
Command (m for help):
To view the available partitions, type in
Command (m for help): p Disk /dev/sda (Sun disk label): 64 heads, 32 sectors, 8635 cylinders Units = cylinders of 2048 * 512 bytes Device Flag Start End Blocks Id System /dev/sda1 0 488 499712 83 Linux native /dev/sda2 488 976 499712 82 Linux swap /dev/sda3 0 8635 8842240 5 Whole disk /dev/sda4 976 1953 1000448 83 Linux native /dev/sda5 1953 2144 195584 83 Linux native /dev/sda6 2144 8635 6646784 83 Linux native
Note the
Command (m for help): s Building a new sun disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Drive type ? auto configure 0 custom (with hardware detected defaults) a Quantum ProDrive 80S b Quantum ProDrive 105S c CDC Wren IV 94171-344 d IBM DPES-31080 e IBM DORS-32160 f IBM DNES-318350 g SEAGATE ST34371 h SUN0104 i SUN0207 j SUN0327 k SUN0340 l SUN0424 m SUN0535 n SUN0669 o SUN1.0G p SUN1.05 q SUN1.3G r SUN2.1G s IOMEGA Jaz Select type (? for auto, 0 for custom): 0 Heads (1-1024, default 64): Using default value 64 Sectors/track (1-1024, default 32): Using default value 32 Cylinders (1-65535, default 8635): Using default value 8635 Alternate cylinders (0-65535, default 2): Using default value 2 Physical cylinders (0-65535, default 8637): Using default value 8637 Rotation speed (rpm) (1-100000, default 5400): 10000 Interleave factor (1-32, default 1): Using default value 1 Extra sectors per cylinder (0-32, default 0): Using default value 0
You can find the correct values in your disk's documentation. The 'auto configure' option does not usually work.
It's time to delete any existing partitions. To do this, type
Command (m for help): d Partition number (1-4): 1
After deleting all partitions except the Whole disk slice, you should have a partition layout similar to the following:
Command (m for help): p Disk /dev/sda (Sun disk label): 64 heads, 32 sectors, 8635 cylinders Units = cylinders of 2048 * 512 bytes Device Flag Start End Blocks Id System /dev/sda3 0 8635 8842240 5 Whole disk
We're ready to create the root partition. To do this, type
Command (m for help): n Partition number (1-8): 1 First cylinder (0-8635): (press Enter) Last cylinder or +size or +sizeM or +sizeK (0-8635, default 8635): +512M
Now, when you type
Command (m for help): p Disk /dev/sda (Sun disk label): 64 heads, 32 sectors, 8635 cylinders Units = cylinders of 2048 * 512 bytes Device Flag Start End Blocks Id System /dev/sda1 0 488 499712 83 Linux native /dev/sda3 0 8635 8842240 5 Whole disk
Next, let's create the swap partition. To do this, type
Command (m for help): p Disk /dev/sda (Sun disk label): 64 heads, 32 sectors, 8635 cylinders Units = cylinders of 2048 * 512 bytes Device Flag Start End Blocks Id System /dev/sda1 0 488 499712 83 Linux native /dev/sda2 488 976 499712 82 Linux swap /dev/sda3 0 8635 8842240 5 Whole disk
Finally, let's create the /usr, /var and /home partitions. As before,
type
Command (m for help): p Disk /dev/sda (Sun disk label): 64 heads, 32 sectors, 8635 cylinders Units = cylinders of 2048 * 512 bytes Device Flag Start End Blocks Id System /dev/sda1 0 488 499712 83 Linux native /dev/sda2 488 976 499712 82 Linux swap /dev/sda3 0 8635 8842240 5 Whole disk /dev/sda4 976 1953 1000448 83 Linux native /dev/sda5 1953 2144 195584 83 Linux native /dev/sda6 2144 8635 6646784 83 Linux native
To save your partition layout and exit
Command (m for help): w
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 is
used as default in this handbook, continue with
Several filesystems are available, some are known to be stable on the SPARC architecture. Ext2 and ext3, for example, are known to work well. Alternate filesystems may not function correctly.
ext2 is the tried-and-true Linux filesystem. It does not support journaling, which means that periodic checks of ext2 filesystems at startup can be quite time-consuming. There is quite a selection of newer-generation journaled filesystems that can be checked for consistency very quickly at startup, and are therefore generally preferred over their non-journaled counterparts. In general, journaled filesystems prevent long delays when a system is booted and the filesystem is in an inconsistent state.
ext3 is the journaled version of the ext2 filesystem. It provides metadata journaling for fast recovery as well as other enhanced journaling modes like full-data and ordered-data journaling. Ext3 has an additional hashed b-tree indexing option that enables high performance in almost all situations. Ext3 makes an excellent and reliable alternative to ext2.
ReiserFS works only partially on sparc64 systems and is therefore not recommended for general use. XFS should be avoided, as it is known to have many problems on SPARCs and could ruin your data. Another journaling filesystem, JFS, is not supported. Regardless of your decision for filesystems, the bootloader requires that the root partition be either ext2 or ext3."
To create a filesystem on a partition or volume, tools specific to the chosen filesystem are available:
| Filesystem | Creation Command |
|---|---|
For instance, to create the root partition (
# mke2fs /dev/sda1 # mke2fs -j /dev/sda4 # mke2fs -j /dev/sda5 # mke2fs -j /dev/sda6
# mkswap /dev/sda2
To activate the swap partition, use
# swapon /dev/sda2
Create and activate the swap now.
Now that your partitions are initialized and are housing a filesystem, it is
time to mount them using the
# mount /dev/sda1 /mnt/gentoo # mkdir /mnt/gentoo/usr # mount /dev/sda4 /mnt/gentoo/usr # mkdir /mnt/gentoo/var # mount /dev/sda5 /mnt/gentoo/var # mkdir /mnt/gentoo/home # mount /dev/sda6 /mnt/gentoo/home
We will also have to mount the proc filesystem (a virtual interface with the
kernel) on
Continue with