Handbook:Alpha/Blocks/Disks/en

Block devices
Let's take a good look at disk-oriented aspects of Gentoo Linux and Linux in general, including Linux filesystems, partitions and block devices. Then, once the ins and outs of disks and filesystems are known, this document will guide the reader through the process of setting up partitions and filesystems for a Gentoo Linux installation.

We start with block devices. The most famous block device is probably the one that represents the first drive in a Linux system, namely. SCSI and Serial ATA drives are both labeled ; even IDE drives are labeled with the new libata framework in the kernel. When using the old device framework, then the first IDE drive is.

The block devices above represent an abstract interface to the disk. User programs can use these block devices to interact with the disk without worrying about whether the 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.

Slices
Although it is theoretically possible to use a full disk to house a Linux system, this is almost never done in practice. Instead, full disk block devices are split up in smaller, more manageable block devices. On Alpha systems, these are called slices.

Default partitioning scheme
As an example we use the following slice layout:

To understand better how big a partition should be, or how many partitions (or volumes) are needed, read on. Otherwise continue now with Using fdisk to partition the disk (SRM only) or Using fdisk to partition the disk (ARC/AlphaBIOS only).

How many and how big
The number of partitions is highly dependent on the environment. For instance, if a system has lots of users, then it is recommended to have separate as it increases security and makes backups easier. If Gentoo is being configured to perform as a mailserver, then should be separate as all mails are stored inside. A good choice of filesystem will then maximize the performance. Game servers will have a separate as most gaming server software are installed there. The reason is similar for : security and backups. In any case, make sure to keep big: not only will it contain the majority of applications, the portage tree alone takes around 500 Mbyte excluding the various sources that are stored in it.

As can be seen, it very much depends on what the system is meant for. Separate partitions or volumes have the following advantages:


 * Administrators can choose the best performing filesystem for each partition or volume
 * The entire system cannot run out of free space if one defunct tool is continuously writing files to a partition or volume
 * If necessary, file system checks are reduced in time, as multiple checks can be done in parallel (although this advantage is more with multiple disks than it is with multiple partitions)
 * Security can be enhanced by mounting some partitions or volumes read-only, nosuid (setuid bits are ignored), noexec (executable bits are ignored) etc.

However, multiple partitions have disadvantages as well. If not configured properly, the system will have lots of free space on one partition and none on another. Another nuisance is that separate partitions - especially for important mountpoints like or  - often require the administrator to boot with an initramfs to mount the partition before other boot scripts start. This isn't always the case though, so results may vary.

Using fdisk to partition a disk (SRM only)
The following parts explain how to create the example slice layout described previously, namely:

Change the slice layout according to personal preference.

Identifying available disks
To figure out what disks are running in the system, use the following commands:

For IDE disks:

For SCSI disks:

The output will show what disks were detected and their respective entry. In the following parts we assume that the disk is a SCSI disk on.

Now fire up fdisk:

Deleting all slices
If the hard drive is completely blank, then first create a BSD disklabel.

We start with deleting all slices except the 'c'-slice (a requirement for using BSD disklabels). The following shows how to delete a slice (in the example we use 'a'). Repeat the process to delete all other slices (again, except the 'c'-slice).

Use to view all existing slices. is used to delete a slice.

After repeating this process for all slices, a listing should show something similar to this:

Creating the swap slice
On Alpha based systems there is no need for a separate boot slice. However, the first cylinder cannot be used as the aboot image will be placed there.

We will create a swap slice starting at the third cylinder, with a total size of 1 GB. Use to create a new slice. After creating the slice, we will change its type to (one), meaning swap.

After these steps a layout similar to the following should be shown:

Creating the root slice
We will now create the root slice, starting from the first cylinder after the swap slice. Use the command to view where the swap slice ends. In our example, this is at 1003, making the root slice start at 1004.

Another problem is that there is currently a bug in  making it think the number of available cylinders is one above the real number of cylinders. In other words, when asked for the last cylinder, decrease the cylinder number (in this example: 5290) with one.

When the slice is created, we change the type to 8, for ext2.

The resulting slice layout should now be similar to this:

Save the slice layout and exit
Save  by typing. This will also save the slice layout.

Using fdisk to partition the disk (ARC/AlphaBIOS only)
The following parts explain how to create the example slice layout described previously, namely:

Change the partition layout according to personal preference.

Identifying the available disks
To figure out what disks are running, use the following commands:

For IDE disks:

For SCSI disks:

From this output it should be easy to see what disks were detected and their respective entry. In the following parts we assume that the disk is a SCSI disk on.

Now fire up fdisk:

Deleting all partitions
If the hard drive is completely blank, then first create a DOS disklabel.

We start with deleting all partitions. The following shows how to delete a partition (in the example we use '1'). Repeat the process to delete all other partitions.

Use to view all existing partitions. is used to delete a partition.

Creating the boot partition
On Alpha systems which use MILO to boot, we have to create a small vfat boot partition.

Creating the swap partition
We will create a swap partition with a total size of 1 GB. Use to create a new partition.

After these steps a layout similar to the following is shown:

Creating the root partition
We will now create the root partition. Again, just use the command.

After these steps a layout similar to the following should be shown:

Save the partition layout and exit
Save the changes made in  by typing.

Now that the partitions are created, continue with Creating filesystems.