• Aucun résultat trouvé

Partitioning with fdisk

Dans le document LINUX RAID (Page 90-93)

You don’t need to partition disks before using them in an array, but partitioning does provide a couple of advantages. First, partitioning is necessary if you want the kernel to automatically start arrays, because themddriver uses the partition type to identify member disks. Second,mddevices don’t support partitioning directly, but in some cases, having a filesystem that spans an entire array is undesirable. Using soft-ware RAID for system partitions means that smaller partitions are necessary. After all, you don’t want/var or/boot to span a whole array.

If you have a lot of disks, then you might not want to go through the trouble of partitioning each disk—a process that can take a lot of time if you have more than a few drives. In that case, you can simply use a whole, unpartitioned disk as an array member (/dev/sda, for example).

This means that you won’t be able to autostart arrays, however, so you’ll have to include commands to startmddevices in your system initialization scripts.

The rest of this chapter assumes that disk-sized partitions are used, but unless you want to subpartition or need to automatically start arrays, you can skip the rest of this section. Replace the use of partitioned disks found in the examples throughout the rest of this chapter with unpartitioned devices. Where Iuse/dev/sdb1to denote a single disk-sized partition as an array member disk, you could simply use/dev/sdb.

The site http://cgi.cse.unsw.edu.au/~neilb/patches/linux/contains patches that enable you to subpartition software arrays. The web page is indexed by kernel revision and patch name.

Use any standard partitioning utility to partition disks connected to your system.

Sincefdiskis generally available on all Linux systems, I’ll discuss it here, but you can use whichever utility you prefer. The partitioning utility you choose doesn’t need any

special features, but to take advantage of automatic RAID activation at boot time, you need a partitioning utility that allows you to set a partition to the type Linux Raid Auto(or hexadecimal code0xFD). Download the latest version of your partition-ing software to ensure that you can take advantage of this feature. This process marks a drive for autodetection and allows the kernel to automatically start arrays at boot time, which means that administrators don’t need to modify startup scripts each time they add an array.

Some GUIpartitioning utilities might not allow you to set a drive to this nonstand-ard type. If, for some reason, you are unable to make these changes using GUI parti-tioning software, Irecommend downloading the current version of fdisk and following the examples below. The latest version offdiskwill support theLinux Raid Autopartition type. (Older versions may not have this option.) You must create par-titions on each drive that you plan to use in your array. If you don’t want the kernel to automatically start arrays, you can use an unpartitioned block device instead, such as/dev/sda or/dev/hda, instead of/dev/sda1 or/dev/hda1.

Partitioning for autodetection

The example that follows creates a single partition (/dev/sdb1) on the second SCSI drive (/dev/sdb) and marks it as an automatically detectable RAID partition:

# fdisk /dev/sdb Command (m for help): n Command action

e extended

p primary partition (1-4) p

Partition number (1-4): 1

First cylinder (1-1116, default 1): 1

Last cylinder or +size or +sizeM or +sizeK (1-1116, default 1116): 1116

Change the drive type of /dev/sdb1to Linux Raid Auto(0xFD) so it can be detected automatically at boot time:

Command (m for help): t Partition number (1-4): 1

Hex code (type L to list codes): fd

Changed system type of partition 1 to fd (Linux raid autodetect)

When the partitions that are part of an array are all set toLinux Raid Auto, the ker-nel will automatically start that array when the system boots. Autodetection works only with MS-DOS style partition tables. So if you’re using Sun, Amiga, or another architecture that has its own partition type, you will have to start arrays manually or use system initialization scripts. The kernel starts arrays beforerc scripts run. So if you need to defer array startup until after you have performed other functions, then it’s important to not set the type toLinux Raid Auto.

Partitioning without autodetection

If you don’t want to use autodetection, but still plan to partition your disks, set parti-tions to type Linux(0x83). This is the default partition type, but to be certain the proper type is assigned, set the type manually:

# fdisk /dev/sdb Command (m for help): t Partition number (1-4): 1

Hex code (type L to list codes): 83

Changed system type of partition 1 to 83 (Linux)

Write the new partition table to the disk and exitfdisk.

Command (m for help): w

The partition table has been altered!

Calling ioctl( ) to re-read partition table.

Syncing disks.

You should follow the process shown here to create partitions on each disk you plan to use in an array. If you create a new partition on a disk that is in use (that is, a disk that contains a mounted partition),fdiskwill complain. You must then restart your system before using the new partition. In the following example,/dev/sda contains mounted partitions, but/dev/sda13 is currently set to type Linux(0x83) instead of Linux Raid Auto (0xFD):

# fdisk /dev/sda13 Command (m for help): t Partition number (1-13): 13 Hex code (type L to list codes): fd

Changed system type of partition 13 to fd (Linux raid autodetect) Command (m for help): w

The partition table has been altered!

Calling ioctl( ) to re-read partition table.

Re-read table failed with error 16: Device or resource busy.

Reboot your system to ensure the partition table is updated.

Once partitions are created, you can usefdiskto compare each of the new partitions.

Make certain that they meet your specifications and that partitions for arrays are the same size when necessary:

# fdisk -l

Disk /dev/sda: 255 heads, 63 sectors, 553 cylinders Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System /dev/sda1 * 1 16 128488+ 83 Linux /dev/sda2 17 33 136552+ 82 Linux swap /dev/sda3 34 84 409657+ 83 Linux /dev/sda4 85 553 3767242+ 5 Extended /dev/sda5 85 276 1542208+ 83 Linux

/dev/sda6 277 407 1052226 83 Linux /dev/sda7 408 553 1172713+ 83 Linux Disk /dev/sdb: 255 heads, 63 sectors, 1116 cylinders Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System

/dev/sdb1 1 1116 8964238+ fd Linux raid autodetect Disk /dev/sdc: 255 heads, 63 sectors, 1116 cylinders

Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System

/dev/sdc1 1 1116 8964238+ fd Linux raid autodetect Disk /dev/sdd: 255 heads, 63 sectors, 1116 cylinders

Units = cylinders of 16065 * 512 bytes

Device Boot Start End Blocks Id System

In addition to the system drive, two partitions are defined in the preceding listing.

There is a partition on each of the second and third SCSIdrives:/dev/sdb1and/dev/

sdc1. A fourth drive with no partitions defined resides at/dev/sdd.

Dans le document LINUX RAID (Page 90-93)