[ << ]
[ < ]
[ Etusivu ]
[ > ]
[ >> ]
4. Preparing the Disks
Sisällysluettelo:
4.a. Introduction to Block Devices
Block Devices
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. The most typical block device is
probably the one that represents the first SCSI hard disk in a Linux system,
namely /dev/sda.
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 /dev/. Typically, the first
SCSI drive is named /dev/sda, the second /dev/sdb,
and so on. IDE drives are named similarly, however, they are prefixed by hd-
instead of sd-. If you are using IDE drives, the first one will be named
/dev/hda, the second /dev/hdb, and so on.
Partitions
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
partitions or slices.
The first partition on the first SCSI disk is /dev/sda1, the second
/dev/sda2 and so on. Similarly, the first two partitions on the
first IDE disk are /dev/hda1 and /dev/hda2.
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.
4.b. Designing a Partitioning Scheme
Default Partitioning Scheme
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 hda for sda in the following.
Note that a separate /boot partition is generally not
recommended on SPARC, as it complicates the bootloader configuration.
| Partition |
Filesystem |
Size |
Mount Point |
Description |
| /dev/sda1 |
ext3 |
<2 GByte |
/ |
Root partition. For all sparc32 systems, and sparc64 systems with older
OBP versions, this must be less than 2 GBytes in size, and the first
partition on the disk.
|
| /dev/sda2 |
swap |
512 MBytes |
none |
Swap partition. For bootstrap and certain larger compiles, at least 512
MBytes of RAM (including swap) is required.
|
| /dev/sda3 |
none |
Whole disk |
none |
Whole disk partition. This is required on SPARC systems. |
| /dev/sda4 |
ext3 |
at least 2 GBytes |
/usr |
/usr partition. Applications are installed here. By default this partition
is also used for Portage data (which takes around 500 Mbyte excluding
source code).
|
| /dev/sda5 |
ext3 |
at least 1GByte |
/var |
/var partition. Used for program-generated data. By default Portage uses
this partition for temporary space whilst compiling. Certain larger
applications such as Mozilla and OpenOffice.org can require over 1 GByte
of temporary space here when building.
|
| /dev/sda6 |
ext3 |
remaining space |
/home |
/home partition. Used for users' home directories. |
4.c. Using fdisk to Partition your Disk
The following parts explain how to create the example partition layout described
previously, namely:
| Partition |
Description |
| /dev/sda1 |
/ |
| /dev/sda2 |
swap |
| /dev/sda3 |
whole disk slice |
| /dev/sda4 |
/usr |
| /dev/sda5 |
/var |
| /dev/sda6 |
/home |
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 and SATA.
Firing up fdisk
Start fdisk with your disk as argument:
Koodilistaus 3.1: Starting fdisk |
# fdisk /dev/sda
|
You should be greeted with the fdisk prompt:
Koodilistaus 3.2: The fdisk prompt |
Command (m for help):
|
To view the available partitions, type in p:
Koodilistaus 3.3: Listing available partitions |
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 Sun disk label in the output. If this is missing, the disk is
using the DOS-partitioning, not the Sun partitioning. In this case, use s
to ensure that the disk has a sun partition table:
Koodilistaus 3.4: Creating a Sun Disklabel |
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.
Deleting Existing Partitions
It's time to delete any existing partitions. To do this, type d and hit
Enter. You will then be prompted for the partition number you would like to
delete. To delete a pre-existing /dev/sda1, you would type:
Koodilistaus 3.5: Deleting a partition |
Command (m for help): d
Partition number (1-4): 1
|
You should not delete partition 3 (whole disk). This is required. If
this partition does not exist, follow the "Creating a Sun Disklabel"
instructions above.
After deleting all partitions except the Whole disk slice, you should have a
partition layout similar to the following:
Koodilistaus 3.6: View an empty partition scheme |
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
|
Creating the Root Partition
We're ready to create the root partition. To do this, type n to create a
new partition, then type 1 to create the partition. When prompted for
the first cylinder, hit enter. When prompted for the last cylinder, type
+512M to create a partition 512MBytes in size. Make sure that the
entire root partition fits within the first 2GBytes of the disk. You can see
output from these steps below:
Koodilistaus 3.7: Creating a root partition |
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 p, you should see the following partition printout:
Koodilistaus 3.8: Listing the partition layout |
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
|
Creating a swap partition
Next, let's create the swap partition. To do this, type n to create a new
partition, then 2 to create the second partition, /dev/sda2
in our case. When prompted for the first cylinder, hit enter. When prompted for
the last cylinder, type +512M to create a partition 512MB in size. After
you've done this, type t to set the partition type, and then type in
82 to set the partition type to "Linux Swap". After completing these
steps, typing p should display a partition table that looks similar to
this:
Koodilistaus 3.9: Listing of available partitions |
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
|
Creating the /usr, /var and /home partitions
Finally, let's create the /usr, /var and /home partitions. As before,
type n to create a new partition, then type 4 to create the
third partition, /dev/sda4 in our case. When prompted for the
first cylinder, hit enter. When prompted for the last cylinder, enter
+2048M to create a partition 2 GBytes in size. Repeat this process
for sda5 and sda6, using the desired sizes. Once
you're done, you should see something like this:
Koodilistaus 3.10: Listing complete partition table |
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
|
Save and Exit
To save your partition layout and exit fdisk, type w:
Koodilistaus 3.11: Save and exit fdisk |
Command (m for help): w
|
Now that your partitions are created, you can now continue with Creating Filesystems.
4.d. Creating Filesystems
Introduction
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 Applying a Filesystem to a Partition.
Otherwise, read on to learn about the available filesystems...
Filesystems?
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. It uses a hashed B*-tree
index that enables high performance in almost all situations. Ext3 makes an
excellent and reliable alternative to ext2.
Applying a Filesystem to a Partition
To create a filesystem on a partition or volume, tools specific to the chosen
filesystem are available:
| Filesystem |
Creation Command |
| ext2 |
mke2fs |
| ext3 |
mke2fs -j |
For instance, to create the root partition (/dev/sda1 in our
example) as ext2, and the /usr, /var, and
/home partitions (/dev/sda4, 5
and 6 in our example, respectively) as ext3, you would use:
Koodilistaus 4.1: Applying a filesystem on a partition |
# mke2fs /dev/sda1
# mke2fs -j /dev/sda4
# mke2fs -j /dev/sda5
# mke2fs -j /dev/sda6
|
Activating the Swap Partition
mkswap is the command used to initialize swap partitions:
Koodilistaus 4.2: Creating a Swap signature |
# mkswap /dev/sda2
|
To activate the swap partition, use swapon:
Koodilistaus 4.3: Activating the swap partition |
# swapon /dev/sda2
|
Create and activate the swap now.
4.e. Mounting
Now that your partitions are initialized and are housing a filesystem, it is
time to mount them using the mount command. Don't forget to first
create the necessary mount directories for every partition you created. For
example:
Koodilistaus 5.1: Mounting partitions |
# 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
|
Huomaa:
If you want your /tmp to reside on a separate partition, be sure
to change its permissions after mounting: chmod 1777 /mnt/gentoo/tmp.
This also holds for /var/tmp.
|
We will also have to mount the proc filesystem (a virtual interface with the
kernel) on /proc. But first we will need to place our files on the partitions.
Continue with Installing the Gentoo
Installation Files.
[ << ]
[ < ]
[ Etusivu ]
[ > ]
[ >> ]
Tämän sivun sisältö ja suomennos kuuluvat
Creative Commons - Nimi mainittava-Sama lisenssi 2.5 -lisenssin alle.
Sivun sisältöä koskee myös
Gentoo Name and
Logo Usage Guidelines.
|