07.06.2014 Views

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

2 - Raspberry PI Community Projects

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

there will be a synchronization phase as soon as the RAID device is created. After some time<br />

(the exact amount will depend on the actual size of the disks…), the RAID array switches to the<br />

“active” state. Note that during this reconstruction phase, the mirror is in a degraded mode,<br />

and redundancy isn't assured. A disk failing during that risk window could lead to losing all the<br />

data. Large amounts of critical data, however, are rarely stored on a freshly created RAID array<br />

before its initial synchronization. Note that even in degraded mode, the /dev/md1 is usable,<br />

and a filesystem can be created on it, as well as some data copied on it.<br />

TIP<br />

Starting a mirror in degraded<br />

mode<br />

Sometimes two disks are not immediately available when one wants to start<br />

a RAID-1 mirror, for instance because one of the disks one plans to include<br />

is already used to store the data one wants to move to the array. In such<br />

circumstances, it is possible to deliberately create a degraded RAID-1 array<br />

by passing missing instead of a device file as one of the arguments to mdadm.<br />

Once the data have been copied to the “mirror”, the old disk can be added to<br />

the array. A synchronization will then take place, giving us the redundancy<br />

that was wanted in the first place.<br />

TIP<br />

Seing up a mirror without<br />

synchronization<br />

RAID-1 volumes are oen created to be used as a new disk, oen considered<br />

blank. The actual initial contents of the disk is therefore not very relevant,<br />

since one only needs to know that the data wrien aer the creation of the<br />

volume, in particular the filesystem, can be accessed later.<br />

One might therefore wonder about the point of synchronizing both disks at<br />

creation time. Why care whether the contents are identical on zones of the<br />

volume that we know will only be read aer we have wrien to them?<br />

Fortunately, this synchronization phase can be avoided by passing the --<br />

assume-clean option to mdadm. However, this option can lead to surprises in<br />

cases where the initial data will be read (for instance if a filesystem is already<br />

present on the physical disks), which is why it isn't enabled by default.<br />

Now let's see what happens when one of the elements of the RAID-1 array fails. mdadm, in particular<br />

its --fail option, allows simulating such a disk failure:<br />

# mdadm /dev/md1 --fail /dev/sdh<br />

mdadm: set /dev/sdh faulty in /dev/md1<br />

# mdadm --detail /dev/md1<br />

/dev/md1:<br />

[...]<br />

Update Time : Thu Sep 30 15:45:50 2010<br />

State : active, degraded<br />

Active Devices : 1<br />

Working Devices : 1<br />

Failed Devices : 1<br />

Spare Devices : 0<br />

Name : squeeze:1<br />

(local to host squeeze)<br />

Chapter 12 — Advanced Administration<br />

305

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!