Mirroring and backups
Mirroring is NOT an alternative to making backups.
- Mirroring protects you from hardware failure like disk crashes.
The system continues working with a faulty disk.
- Journalling (ext3) protects you from power failure.
The system continues working after power is restored,
and just little data is lost (modifications of the last minute).
- Backup protects you from your errors like deleting or modifying a file beyond repair.
Data can be restored from the last backup before you made it useless.
A backup can be stored very well on the local disk.
- Remote backup protects you from external errors damnaging your computer.
Data can be restored from the last backup even
if your wife threw your computer out of the window on the 4th floor.
So mirroring your disks is part of the solution.
Mirroring - aka Raid-1
Mirroring disks (also known as Raid-0) makes your computer
writes all data write onto 2 disks at the same time.
If one disk fails, no data is lost.
Just replace the faulty disk.
Reading data may be faster, since there are 2 disks available to read from.
The disadvantages: you have to buy twice the amount of disk surface,
writing data may cost twice the time.
Mirroring protects you from disk failures,
Not from you accidently deleting files.
So it is NOT an alternative ro making backups.
Of course you can make a (compressed) backup to disk,
if you have enough space.
Raid-0 and Raid-5
Raid-o maintains 2 copies of every file on 2 different disks.
They may be written (almost) at the same time. It costs twice the amounts of disks.
It hardly gives extra CPU load, since no computations are involved.
Raid-5 is cheaper: for every disk block it maintains a smaller parity block on another disk.
So you have more disk surface or your money.
But the drawback is: the parity table is recreated every time when the block is written.
It costs extra CPU time.
Hardware mirroring
The BBS comes with a Raid-controller.
It is capable of mirroring 2 pairs of identical disks.
The rightmost disk (connected to the motherboard, not to the Raid controller)
cannot be part of a hardware mirror.
Software mirroring
Software mirroring supports pairs of equally sized disks or partitions
to create mirrored devices, so the disks need not to be paired.
It also supports mirroring of partitions on all 5 disks,
not excluding the rightmost disk.
You could even throw in some USB disks or floppies.
However, if you want to mirror partitions of an odd number of disks,
or several (at least 3) disks of unequal sizes,
you may end-up with a lot of useless small mirrored partitions.
That is why Logical Volumes is invented.
Logical volumes, logical disks
You may have several odd sized disk, due to several reasons
- still using good old disks of different sizes
- result of softare mirroring
Usually you need other partition sizes to store your fotos, music, etc.
The Logical Volume Manager (LVM) can throw all blocks of odd-sised available devices
into a pool of disk blocks, and then assemble the useable devices as large as you need them.
There is no relationship between the sizes of the physical disks and the logical disks
as long as the total size of logical disks is not more than the physical disk surface.
So what shall we do ?
There are a few rules to obey:
- A disk can only contain 4 primary partitions,
and some more extended partitions.
- Linux (2.6 and up) can boot from a mirrored disk, not from a logical volume.
- Mirroring the swap partition in a 7x24 server just takes twice the disk size with no advantage.
- Mirroring the swap partition in a desktop makes it 'wakeup' after 'sleep' more reliable.
- Mirroring costs 50% of the disk surface (and a little more).
- Hardware mirroring requires pairs of equally-sized disks.
- Hardware mirroring is limited to the 4 leftmost internal disks.
- Software mirroring is possible on all internal and external disks,
regardless the sizes.
- Software mirroring requires re-combining those odd-shaped devices into usable virtual disks.
- Virtual disks makes reconfiguring physical disks and logical volumes independant, en thus very flexible.
- Using logical volumes, built from mirrored decives, allows us
to replace software mirrors by hardware mirrors later on.
Based on this, the following decisions were made,
(on which this document is based):
- The boot partition is mirrored.
It takes the first partition on the 2 newest (largest) disks.
They are only 150 MBytes (about 20 cylinders depending on the disk layout).
- Most disk-surface is taken by unreplacable data like photographs and music.
So it must be mirrored.
- The Operating System must be reliable.
So it must be mirrored.
- Mirroring swap space is not necessary
(the BBS is not a portable laptop).
However it is put onto a Logical disk for 2 reasons:
- it is far more flexible to change the size afterwards, etc.
- less complex when building the system:
now the boot partitions are the only exceptions.
- the 'wasted' amount of disk size is almost negligible
compared to the total disk size.
The rest of this document is based on these decisions !
Example how to turn available partitions into useable disks
with thanks to Ton Hospel for the idea
Disk /dev/sdb is partitioned into /dev/sdb1, /dsv/sdb2, /dev/sdb3.
The partitions sdd1 and sdb3 are equally sized,
and combined into 1 single mirrored device /dev/md1.
The mirrored devices /dev/md[1-9] are combined into a group named /dev/all_disks.
Half of /dev/md4 is missing, since disk /dev/sda isn't available at the moment. But it still works !
Then the volume group /dev/all_disks is devided into usefull logical volumes,
like /home, /var, / (root), and possible /var/www (website), /var/music (music files)
as you wish.
You just need to add root while installing, you can do the rest later.
| physical devices |
mirrored devices |
logical volume group |
logical volume |
mounted as |
/dev/sdd1 /dev/sdb3 | /dev/md1 |
/dev/all_disks |
/dev/all_disks/home | /home |
/dev/sdc2 /dev/sdb4 | /dev/md2 |
/dev/all_disks/var | /var |
/dev/sdc3 /dev/sdd2 | /dev/md3 |
/dev/all_disks/root | / |
/dev/sdb2 missing | /dev/md4 |
/dev/all_disks/log | /var/log |
/dev/sdc1 /dev/sdb1 | /dev/md0 |
Used as mirrored boot device,
NOT part of logical volumes.
|
/boot |
Note the devices /dev/sdb1 and /dev/sdc1 are NOT part of the logical volumes.
sdb1 and sdb1 are both partitions of only 7 cylinders, 150 MBytes each,
combined together to a mirrord device /dev/md0, also 150 MBytes.
At startup-time, the system is booted from /dev/md0,
if at least 1 of /dev/sdb1 or /dev/sdc1 is working properly.