Adding a hard drive to a Linux server is not as easy as adding a hard drive to a Windows computer.
I’m not going to get into the hardware part of installing the hard drive into the server, you are going to have to figure that one out yourself.
After connecting your new hard drive and booting up your server you might get some problems if you had more then one hard drive before and had mounted the other hard drive somewhere.
We will get back to that one once we have checked that the hard drives and partitions exist in the system.
Start in the command prompt and write:
lsblk -o NAME,LABEL,MODEL,FSTYPE,SIZE,MOUNTPOINT
You will get something similar to this:
The column to the left “NAME” is the system name of the hard drive or partition.
“LABEL” is the partition Label.
“MODEL” is the model of the hard drive.
“FSTYPE” is the file system type.
I think “SIZE” speaks for itself.
“MOUNTPOINT” is where it’s mounted into the system.
And Linux, and for this case Ubuntu, has named the units sdx with x is a count but in letters.
sda is the first disk,
sdb is the second disk etc.
In the screenshot, I have 4 hard drives and one usb drive ( sde in this case ),
and they all have partitions.
Partitions are usually just the unit name plus a number. It’s just to make it easier to make changes to specific partitions. And by default starts with one and goes upwards.
There are a lot of file system types, FSTYPE. For a couple of exampels:
- ext3, ext4 are Linux file systems.
- ntfs are Windows file system
- vfat is a standard old file system that works in both Linux and Windows.
So now I’m going to remove the Windows partitions from unit sdc and add a Linux partition.
YOU HAVE TO MAKE SURE THAT THE PARTITIONS ARE NOT USED AS YOU CONTINUE.
For all the following commands you will need sudo rights.
sudo fdisk /dev/sdc
Now you have started to make changes to the disk.
Here there is a one letter command prompt, type “m” for help.
So I’m staring with deleting existing partitions with “d”, it will prompt a question with which partition I want to delete and a default value if I just press enter.
I press enter, and then “d” again and enter again because there was to partitions on this disk.
Then I create a new one with “n”, selects “p” for primary.
Sense I want to use just one partition and all of the disk I will select default for the rest of the choices.
It’s going to ask for partition number, the first sector and last sector for this partition, which is useful when you are going to split the disk for more than one partition.
And when your done use “w” to write the changes to disk, otherwise use “q” to quit.
Now we need a filesystem on the partition.
sudo mkfs.ext4 /dev/sdc1
And then it’s just to mount the disk into the filesystem on the desired path.
Make sure it exists and run
sudo mount -t auto -v /dev/sdc1 /mnt/new hdd
And your new hard drive should be ready to go.
Beware that this mount is only until next reboot. Then it will get lost.
To make this connection on system start you will need to edit the /etc/fstab.
But for that I want the UUID from the disk because it’s safer if you add or remove disks.
To get the UUID run
sudo blkid
Now your going to enter that one into the fstab on a new row.
If you are unsure of what you are doing you could break your system here.
the row should be structured like this:
<file system> <mount point> <type> <options> <dump> <pass> UUID=6bc20ed3-f8c3-48a2-9b0a-5e4e4e8d54fb /mnt/new hdd ext4 default 0 0