Hodgepodge 3xNAS Part 6 Add a Storage Drive

Published on May 17, 2023 at 6:03 am by LEW

Introduction

In this post we will be adding a storage drive to our Linux Server. And we are going to do it the old fashion way, from the terminal. In this case we will be using the cockpit terminal (last post).

Since we are currently running our server as a Virtual machine (VM) in VirtualBox (VB), we will need to first create a new virtual drive for our server. Then, before we can use this new drive, we need to attache it to our VM.

Once it is attached, we will need to partition and then format it. We will want to test our drive by temporary mounting it to our server. And finally we need to decide where to permanently mount it, and what sort of access it will need.

Not to worry, most of this stuff is fairly straight forward, at least for this example. Things can get a bit more complicated later when we start talking about network access and Redundant Array of Inexpensive Disks (RAID). Additionally we will need to think about security and backups. But for now we will focus on getting an additional drive setup, mounted, and usable.

Creating and Attaching a New VirtualBox drive

To add a second drive to our server VM, we need to make sure it is first powered off. Once the VM is shut down, we can select Settings → Storage.

At the bottom of the Storage Controller/Drive list is a disk icon with a green plus on it. Click this icon, and from the selection menu chose Hard Drive. This will open the Hard Disk Selector Window for our server. This window shows all drives for every single VM we have.

Select the Create icon (Hard Drive with a blue circle) from the top left of the window. This will open the “Create Virtual Hard Disk” wizard. For this iteration, accept the default settings until you get to File Location and Size. Here you can adjust the size and confirm it is located in the folder with our server instance. I am going to go with the default 20 GB size. Then select finish. The drive should show up as not attached.

Back in VM Settings at the Storage display, next to the Controller:SATA, click on the hard drive icon with the plus sign. Then double click on the unattached drive we just created. Then click OK to save your settings. This will attache the virtual drive to our VM.

Locate, Partition, and Format New Drive

Power up the VM, and log in. You can chose to long in through SSH (PuTTY), or through the browser (cockpit).

Note: I have not been mentioning which commands need to be run as sudo or root. Many of the following commands will need to be run with elevated privileges. Generally if you cannot run a command, check if it will run with root permissions.

Once logged in, we want to check the /dev directory. You should see that the new drive is present. In my case sda was the original drive, and I now have a sdb drive present.

ls /dev | grep sd

Note that for our original drive we have multiple entries. If you followed the example from previous posts, you should have sda1, sda2, and sda5. Technically there are only two partitions, but one is warped in an extended partition. But I really don’t want to get into the intricacies of the legacy BIOS system here. Basically the number at the end is the partition number, so sda1 is the first partition on sda.

At this point we can partition the drive. There are several different tools for doing this. By default both fdisk and cfdisk are present in the base Debian image. The fdisk program is the older, and has a somewhat clunky interface. The cfdisk program is probably easier for most people to use.

cfdisk /dev/sdb

For my VM test I partitioned the drive as Legacy DOS and one Linux partition that takes up the whole drive.

I want to format this drive as ext4. There are several ways to run the mkfs command. What I used below is just one example. To format a partition we must reference the partition and not the drive. Since the partition is the first one it is /dev/sdb1.

mkfs.ext4 /dev/sdb1

Temporarily Mount File System

Just to make sure every thing is working, we can mount our new drive to the /mnt directory. The /mnt directory is a mount point for temporary file systems so it works for this purpose.

mount /dev/sdb1 /mnt

If you have trouble accessing the drive, check the directory permissions. In the mean time try doing some basic directory activity; create files and folders, delete file and folders, copy some stuff, move some stuff.

When you are satisfied, delete any content you added before un-mounting. Also make sure you are not in the directory before attempting to un-mount.

umount /mnt

Permanent Mounting

Ideally if we are going to use this drive as a data drive, we will want it to mount at boot, along with the other drives. To do this we will want to update the /etc/fstab file.

Before modifying the fstab file, we need to decide where the drive will be mounted too. For this example I want to mount the drive in the /srv directory. According to the File system Hierarchy Standard, the /srv folder can store system services. Since the directory is currently unused,  and this is basically a file server it seems like a good place for a storage directory.

mkdir /srv/storage

For this example the directory location and structure is somewhat simplistic since we will be using only one storage drive. Things will get somewhat more complicated when multiple drives are used, like in a RAID array.

Now that we have a location, we need to get the partitions Universal Unique IDentifier (UUID). Technically we could just use the drive designation (like /dev/sdb1). Using the UUID is the current accepted standard for the fstab file, because the UUID cannot change accidentally.

To get the UUID we need to use the blkid command. You can copy the screen output or redirect output to a file.

blkid /dev/sdb1

The structure of a line in the fstab file is white space separated values of; File System, Mount Point, Type, Options, Dump, and Pass.

Our file system is the UUID. Our mount point is /srv/storage, type is ext4, I will start with defaults for options, and for dump and pass set both to equal 0 (zero) in most cases.

UUID=85c0eade-19de-43cb-afdd-bb5c58b31445    /srv/storage    ext4 defaults    0    0

After editing and saving the fstab file reboot your computer and verify the drive was mounted.

Conclusion

In this post we added a single storage drive for our network data.

The next thing we need to do for this example is make the storage drive accessible from the network. In the next post we will do that with the samba application.

Hodgepodge 3xNAS Part 1 Project Overview

Hodgepodge 3xNAS Part 2 Software Choices

Hodgepodge 3xNAS Part 3 Virtual Install

Hodgepodge 3xNAS Part 4 Initial Configuration

Hodgepodge 3xNAS Part 5 Need a GUI?

Hodgepodge 3xNAS Part 6 Add a Storage Drive

Hodgepodge 3xNAS Part 7 SMB/CIFS

Hodgepodge 3xNAS Part 8 Expanded Storage

Hodgepodge 3xNAS Part 9 Making RAID

Hodgepodge 3xNAS Part 10 Cockpit Web GUI RAID 5

Hodgepodge 3xNAS Part 11 Mergerfs

Hodgepodge 3xNAS Part 12 Snapraid

Hodgepodge 3xNAS Part 13 LVM

Hodgepodge 3xNAS Part 14 The Server Hardware

Hodgepodge 3xNAS Part 15 The Server Operating System

Hodgepodge 3xNAS Part 16 Cockpit Install

Hodgepodge 3xNAS Part 17 SAMBA Setup

Hodgepodge 3xNAS Part 18 PLEX vs Kodi

[…] Hodgepodge 3xNAS Part 6 Add a Storage Drive […]

[…] Hodgepodge 3xNAS Part 6 Add a Storage Drive […]

Add New Comment

Your email address will not be published. Required fields are marked *