LVM

Resizing your Linux based NAS

In an earlier article article I outlined how to manually create a NAS device with standard Linux tools. This article shows you how to resize the array that you created. In the example that I used, we have replaced our 1 terabyte drives with 2 terabyte drives. Then we extend our logical volume and the file system that sits on top.

Warning, if the data is important or mission critical, BACK IT UP! One wrong step and you could very likely hose all of your data!

The first thing we need to do is replace the drives, one at time. This may take a while (about 4 hours per disk on my machine) as the array has to be rebuilt each and every time you replace a drive. During this period you are vulnerable to data loss as you no longer have a valid parity drive. If another disk fails in this time period then will likely lose your data. In case you missed it before, BACK UP YOUR IMPORTANT DATA FIRST!

On my machine the drives were installed into hot swappable drive trays, and the SATA chipset supported hot swapping. Your system may differ, in which case you may need to shutdown and reboot to swap every drive.

On my machine I just removed the first drive. I checked dmesg and noticed that the drive I removed was /dev/sdd.

Using Linux Software RAID and LVM to build your own NAS


** Update 2014 **
I am transitioning away from RAID arrays (and no longer use LVM). For smaller amounts of data I am migrating to btrfs (RAID 10 or RAID 6 and larger amounts of data a cluster (using ceph or swift) is usually the answer.
** End Update **

I am a big fan of RAID arrays and I use them everywhere. After having been bitten by failed, end of life hardware devices, I have become a fan of the software RAID. In particular I am quite happy with the Linux software RAID capabilities when paired with the Logical Volume Manager (LVM).

First, I create some partitions on the drives I want to use, in my case, I have four 1TB drives that I am putting into an array. You do not need to create partitions as Linux can use the whole drive as it is, where you may have issues is if you plug the drive into a computer that does not support Linux RAID, it may prompt you to format what appears to be a blank drive. If you use partitions, at least the OS will see an unsupported partition and probably do nothing. This is not a big deal but it can help to prevent you from shooting yourself in the foot, especially when you have more than a few drives on the workbench and more than one OS in daily use.

Syndicate content