Back in the day when I used Windows on a desktop, one common problem that I struggled with was having an abundance of storage devices connected to the machine. There were typically four or more drives inside the case, plus two or three USB devices, then network storage on top of that. At the day job in 2010 this sort of problem was seen again, and each drive would have its own dedicated purpose as a result.
C: was for the system and applications.
D: was for code.
E: was an SSD, so dedicated to local databases.
F: was a dumping ground for everything, including a copy of my iTunes library. Network drives started at
Z: and went backwards, except for the Windows Home Server backup machine, that was
What a pain in the bum that was, especially when one drive started to run out of space. Then you were required to make a decision:
- move a bunch of data around
- accept that some of the data was in one place, and the rest in another
- drop a lot of money to get a nice RAID card and spend a weekend watching Windows copy data from one place to another
We've probably all done the first two items, and I've done the third on a number of occasions as well. Luckily, with Ubuntu (and other modern OSes with Logical Volume Managers), this is much, much easier to deal with. We can connect a lot of storage devices to our machines and have them appear as a single logical unit, taking the pain out of trying to organize where files will go on our computers. I did this with the two 512GB SSDs on the work Lenovo, and now I'm going to show you how I did it.
Note: In order to add drives to an existing LVM, they must be completely empty and have no partition information on them. If you want to add a drive that already has a bunch of information to the storage pool without losing any information, this is not the process you're looking for.
Note 2: Using an LVM or RAID is no substitute for a proper backup mechanism. Please make proper backups of your data in the event something really, really bad happens to your computers.
For the sake of this walkthrough, I'm going to use a virtual machine with virtual drives. For this example, we have a computer with a 128GB primary hard drive and a 2.0TB device is being added to the existing storage pool.
First things first, grab your Ubuntu MATE 16.04 Live DVD, because you're going to be doing everything from within a live session. This is mainly because OSes generally do not like big changes happening to the boot partition during operations. Some people will say that they've resized their partitions while live, but this doesn't mean it's the right way to do a thing.
Once the Live MATE finishes booting, we need to make a physical drive. To do this, we need to know the device name of the new disk. Open up the Disk Management tool and find the new device. The partition will likely be unallocated or, if it came pre-formatted from the factory, NTFS. Make note of the device name, in this case
/dev/sdb and open a terminal session.
In the terminal, type:
Be sure to replace
sdb with your proper device name.
A moment later you will notice that the hard disk now shows
LVM2 PV. From here, let's grab a handy little tool called
system-config-lvm. Launch a terminal and type:
sudo apt-get install system-config-lvm
If nothing is found in the repository under that name, then you'll need to add a repository that does have the tool and update, like so:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu $(lsb_release -sc) universe"
sudo apt-get update
sudo apt-get install system-config-lvm
After installation you can find "Logical Volume Management" in Applications ⇢ System Tools. Launch the application and you'll see something like this:
Click the unallocated volumes and then choose your new device. You'll see a red bar denoting your drive, and three buttons underneath. Since we're adding this drive to an existing storage pool, click "Add to Existing Volume Group". You'll then see a window pop up asking which volume group to add it to. As this example only has one, we'll add it to that.
Which gives us:
And now, at last, we can expand the existing volume from about 123GB to almost 2.2TB. Expand the "Logical View" and choose the volume you're expanding. In this case, it's "root". You'll see a single blue cylinder representing the drive. Click the "Edit Properties" button to bring up the volume attributes. Near the centre you'll see a handy little button that says "Use Remaining", which will make the volume as large as it can be with the devices. Once done, click OK and the software will work its magic. Reboot back into your proper OS and confirm you now have what appears to be a single drive that is much bigger than before.
The tools to do this have come a long way in the last decade. I remember doing this with other Linux flavours in the early 2000s and it was always a nerve-wracking experience.