Linux Format

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 software RAID array using mdadm. Let’s suppose we have two 1TB drives, which can be had for about £30 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, and 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 are 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 #s). This won’t be a problem right away, since mdadm will use 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% of 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 mathematic­s 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 will ask if 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 primed we can create our mirrored array: # mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/ sdb1 /dev/sdc1

This will ask you if you about metadata at the beginning of the drive—don’t worry it’s safe to enter y here. Then it will create 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/lxfraid . 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 it’s UUID, which we ascertain with # blkid . Armed with this knowledge, add a line of tis form to /etc/fstab, and all should be sweet: UUID="90abcdef-...” /mnt/lxfraid ext4 defaults 0 0

 ??  ??

Newspapers in English

Newspapers from Australia