Maximum PC

Adding a RAID Setup

Set up a mirrored array of redundant storage, and then make your server easy to find with a static IP

-

THE NEXT STEP is to set up a software RAID array using mdadm. Let’s suppose we have two 1TB drives, which can be had for about $50 a pop nowadays. There is a natural aversion to sacrificin­g capacity; it would be tempting to have two large partitions (one on each drive), but if one drive fails, you lose half your data, and by Murphy’s Law, it will be the good half. You could be even more reckless, and conjoin multiple drives together (JBOD) into a single logical volume, but here, if one drive fails, you lose all your data. Don’t hate your data. There’s also a common misconcept­ion that your drives have to be identical for RAID. This isn’t true—in fact, there’s a reasonable argument for using different drives, or at least drives from different batches, in case of manufactur­ing faults.

With the drives connected, check their device nodes by running lsblk ; it would be inconvenie­nt if we wiped our Debian install. Let’s assume our data drives are /dev/sdb and /dev/sdc. The first step is to partition the drives, and for this purpose, we’ll use gdisk (strictly necessary for drives larger than 2TB). SSH into your server (as root if you set a password earlier), and run: # apt-get install gdisk # gdisk /dev/sdb

Enter p to list any extant partitions. You’ll want to delete these by pressing d and following commands until there’s none left. Now create a new partition by pressing

n , and accept the default of 1 for its number. Also accept the default start sector by pressing Enter. We could just use all of the drive, using the last sector to mark the end of the partition, but this is potentiall­y risky: There are often discrepanc­ies of a few megabytes between drives of ostensibly the same capacity (even ones with identical model numbers). This won’t be a problem right away, since mdadm uses the size of the smallest drive, but we may have to replace one in the future, and it would be annoying if this replacemen­t drive came up just a little short. So, in this case, we might enter

-1G for the last sector, sacrificin­g 1GB. This is probably overly cautious, but it’s only about 0.1 percent of the total capacity, and could save much hassle later. Use a similar ratio if your drives are differentl­y sized, and use trial and error if your math is shaky—do-overs are allowed if you mess up. Enter FD00 when prompted for the partition type, and then press p to make sure things look OK. If they do, press w to write the table to the disk. Now quit gdisk and repeat the process for /dev/sdc.

We also need to install and configure mdadm. Installati­on is simply # apt-get install mdadm , which asks whether you need any mdadm devices to be available at boot time. We don’t, so just enter none . As a final step, we wipe the drives’ superblock­s, in case data from any previous RAID arrays is still there:

# mdadm --zero-superblock /dev/sdb /dev/sdc

With the drives now primed, we can create our mirrored array: # mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sdb1 /dev/sdc1

This asks you about metadata at the beginning of the drive—don’t worry, it’s safe to enter y here. Then it creates a new device node, and at this stage, it would be rude not to put a filesystem on it: # mkfs.ext4 /dev/md0 .

We need to create a mountpoint for our RAID device, which is just a matter of # mkdir /mnt/mpcraid . Finally, we need to ensure our array is automounte­d at boot. We could probably get away with referencin­g the array by its device node (/dev/md0), but it’s more failsafe to use its UUID, which we ascertain with # blkid . Armed with this knowledge, add a line of this form to /etc/fstab, and all should be sweet:

UUID=”90abcdef-...” /mnt/mpcraid ext4 defaults 0 0

 ??  ?? Wikipedia will tell you all about the more exotic RAID levels, but you need more than two hard drives for them to be of any use.
Wikipedia will tell you all about the more exotic RAID levels, but you need more than two hard drives for them to be of any use.

Newspapers in English

Newspapers from United States