Image: Jack Wallen

You have Linux serving up various services from within your data center. Maybe one of those servers is used for a database and you’re finding the attached drives are filling up with space. When that happens, it’s time to add extra drives to accommodate the continually growing collection of data. If that server uses the btrfs file system, what do you do?

You plug that device in, open a terminal window, and add the device.

It’s actually that simple. How do you do it? Let me show you.

SEE: Kubernetes security guide (free PDF) (TechRepublic)

What you’ll need

  • A Linux system that uses the btrfs file system

  • A new drive formatted to the btrfs file system

  • A user with sudo privileges

How to add the device

The first thing you must do is add the drive–either plug it into a USB port or attach it as an internal drive. Either way, doesn’t matter. Once you’ve attached the drive, you’ll need to find out the name the drive has been assigned. You can always do this by issuing the command:

dmesg

You should see reference to the newly added drive near the bottom of the output. The name will be in the form of /dev/sdk1.

Next, we need to create a mount point for the new drive. Let’s create a directory with the command:

sudo mkdir /data

You can name that directory whatever you like. If that directory needs specific privileges, such as for a user or a group, consider running a commands like:

sudo chown -R USER.GROUP /data
such chown -R ug+rw /data

Where USER is a specific username and GROUP is a specific user. Make sure you adjust those accordingly, if they are even necessary.

Now it’s time to add the drive. The command for this will be:

sudo btrfs device add -f /dev/sdk1 /data

Remember, the hosting file system that houses /data must be of the btrfs file system type. If you get an error that the drive is already mounted, you might have to unmount it with a command like:

sudo umount /dev/sdk1

Once the device is added, you can verify by running the command:

sudo btrfs filesystem show

You should see the new device listed in the output (Figure A).

Figure A

I’ve just added /dev/sdk1 to the system and mounted to the /data directory on HALEY.

After you’ve added the drive, it’s a good time to do a rebalance of the newly added drive. For that, you’d issue the command:

sudo btrfs filesystem balance /data

You’d want to make sure that /data is the full path to the mount point of the newly-added btrfs drive. Once the drive is balanced, you’re ready to use it.

If you ever need to delete that device, issue a command like:

sudo btrfs device delete /dev/sdk1 /data

That’s all there is to adding a new device to a btrfs system in your data center. Enjoy that expanded storage space.

Subscribe to TechRepublic’s How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays

Subscribe to the Data Insider Newsletter

Learn the latest news and best practices about data science, big data analytics, artificial intelligence, data security, and more. Delivered Mondays and Thursdays