How To Add a New Drive to Your Existing Linux Server

Elya Vatel/Shutterstock

If you’ve obtained a exhausting drive you need to add to your Linux server, bodily or digital, it’s not going to work out of the field. You’ll have to initialize the drive with a filesystem, and set it to routinely mount at boot.

This information will deal with the fundamentals for getting a new exhausting drive up and operating on Linux. If you want extra advanced administration, we suggest utilizing Logical Volume Management (LVM) as an alternative, which follows a completely different process. Among different issues, this makes managing partitions on drives simpler, and permits for straightforward resizing of logical volumes.

Install The Drive

This could seem self explanatory, but it surely’s not at all times so simple as simply plugging it in. If you’re putting in a bodily drive in a bodily server, you might have to boot into your BIOS or RAID configuration utility to create a new logical drive out of the bodily drive you put in. This approach, you possibly can group a number of exhausting drives collectively into one giant, uniform file system, or just simply use the only drive. If you’re simply utilizing a single drive, RAID 0 is your solely possibility. If you have got two drives, RAID 1 is a more sensible choice for sturdiness. For three drives, RAID 5 is your greatest wager, and at 4 drives and above, RAID 10 or RAID 6 are each good choices.

If your RAID controller permits it, it’s possible you’ll select to add a new drive to your current array and develop the whole dimension. If that is an possibility, you don’t want to do something previous setting it up with the RAID controller, although it’s possible you’ll want to wait via an array rebuild relying in your configuration.

If you’re putting in a drive into a cloud server, resembling a new EBS volume, you’ll have to be sure the drive is initialized and is hooked up to your cloud server. The advantage of cloud drives like EBS is that it’s absolutely managed; You don’t have to fear about changing problematic exhausting drives are coping with RAID configuration, as that’s all dealt with by AWS and is abstracted away from you. EBS volumes will also be swapped between cases at will (although EFS is the one AWS drive kind that may be hooked up to a number of cases directly).

Either approach, it should work the identical approach. You can confirm that the drive is put in and dealing correctly if a new block degree gadget is discovered when operating lsblk:

If you need extra data, you may also run sudo fdisk -l, however lsblk makes for a higher screenshot.

Linux treats nearly all the pieces on the OS as a file you possibly can write to, and drives are not any completely different. The /dev/ folder incorporates gadget recordsdata, that are a particular interface to the drive {hardware} itself. Usually, your first drive will likely be sda, with all subsequent mounts coming in alphabetical order.


In this case, the first OS drive is sda, with two partitions (denoted by a quantity after the drive prefix), one among which is mounted on the root of the file system. The second drive that was simply put in is sdb, which isn’t mounted and is simply an empty disk, devoid of a filesystem. If you’re putting in a cloud drive, it should in all probability come on this identical kind too, solely initialized and prepared for no matter filesystem you select to placed on it.

A quick phrase of warning: We’ll assume your drive is sdb for the remainder of this tutorial, since that’s possible to be the default in case you’re putting in a second drive. However, you’ll need to be further cautious when coming into instructions, because you don’t need to screw it up and mess with drives which have already been configured.

Create a New Filesystem

Since the drive doesn’t have a filesystem, we will’t use it for storing recordsdata. Not to fear, as a few instructions will make fast work of that.

If you need, you can partition your drive earlier than putting in a filesystem. This is non-obligatory, as a filesystem could be put in instantly to the gadget itself, which can act as one big partition. If you’re organising a non-boot drive, likelihood is you in all probability need to make use of your entire factor, so except you have got a particular motive to partition, you possibly can omit this step.

To create a new filesystem on an empty quantity, you’ll need to use the aptly named mkfs command:

sudo mkfs -t ext4 /dev/sdb

This creates a new ext4 filesystem on sbd. Linux has a lot of filesystem types, all with various help. ext4 is secure, and the default filesystem for Linux. After about 50 TB although, it begins to degrade in efficiency, and filesystems like ZFS and XFS begin to turn into extra viable choices.

Next, you’ll need to create a mount level. This could be wherever in your drive, as long as the folder is accessible. By default, Linux makes use of the /mnt/ listing for many non permanent mounts, and /media/ for detachable mounts like CDs, however that’s simply conference. Really, it doesn’t matter the place you mount it, simply make a new folder for it:

sudo mkdir /mnt/newdrive

Make positive this mount folder has correct permissions. Now, you possibly can mount and take a look at the brand new drive with:

sudo mount /dev/sdb /mnt/newdrive

The drive ought to now be absolutely usable, and out there from the mount location you’ve chosen.

However, this mount isn’t everlasting, and won’t persist throughout reboots. Since that’s clearly a difficulty for a exhausting drive, you’ll have to add it to your fstab file.

Add The Mount To fstab

fstab, or filesystem tab, retains monitor of gadgets and their mount factors. It’s liable for mounting your main exhausting drive to /, and any drive added right here will turn into a part of the OS in a lot the identical approach.

Another phrase of warning: errors in an fstab file could cause the system to be unbootable, and unable to be fastened besides from grub mode or an exterior USB. This isn’t a main concern, since you possibly can verify for errors earlier than restarting, however you’ll need to be sure to achieve this.

Anyway, you’ll in all probability need to again up fstab:

sudo cp /and so on/fstab /and so on/fstab.outdated

Rather than utilizing the gadget label (like /dev/sdb) gadgets in fstab have to be added by way of UUID. This is as a result of gadget order isn’t assured, and it’s very potential for drive letter allocations to change, since they’re added dynamically on startup and each time drives are sizzling swapped. You can discover your gadget’s UUID with:

sudo blkid

Copy the UUID, and open up fstab:

sudo nano /and so on/fstab

You’ll need to add the next line, changing the UUID with your personal, and /mount/level with your personal mount level.

UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx /mount/level ext4 defaults,nofail 0 2

The nofail possibility tells the OS that it’s superb to boot with out this drive, or if there are any errors in mounting. If it’s crucial that your system at all times has this drive out there, you’ll need to take away this.

Now, you’ll need to verify that there are not any errors in fstab. Unmount the drive:

sudo umount /mount/level

And mount the drive utilizing fstab:

sudo mount -a

If this accomplished with no errors, you’re good to go. If not, you’ll need to double verify that your UUID and configuration is appropriate, and restore from the backup fstab.outdated in case you want to.

Source link

This Web site is affiliated with Amazon associates, Clickbank, JVZoo, Sovrn //Commerce, Warrior Plus etc.

Related Posts

Leave a Reply

Your email address will not be published.