After the device is connected, it should be recognized in the system. However, at the software level, it still requires some configuration to use it properly. In this guide, check out how to add a new disk device to Fedora Linux.
When you connect the new device to the computer, assuming the unit is functional, it should be recognized by the BIOS. If not, then here are a few possibilities to look for.
- Ensure that the device is connected properly. Often, that’s a major source of headache, especially with external storage devices.
- While it’s uncommon, you may also have a dead device at hand.
- Sometimes, certain storage devices aren’t supported by some computers. It’s dependent on multiple factors like brand, model, etc.
Finding the disk device
Finding the new drive using CLI
Assuming that the device is functional and connected properly, let’s get started.
In Linux, all the disk devices are assigned a unique device name that begins with “hd” or “sd”. For example, “/dev/sda” is the first device label, “/dev/sdb” is the second device label.
Launch the terminal, and run the following command. It should list all the connected disk devices.
As the output suggests, the disk “/dev/sda” has two partitions, “/dev/sda1” and “/dev/sda2”.
Now, connect the new storage device, and run the command again.
Here, the new disk “/dev/sdb” has a single partition “/dev/sdb1”. If the device had no partition, there’d be only “/dev/sdb” in the result.
Finding the new drive using GUI
If you prefer using GUI, then it’s suggested to use the GNOME Disks. It’s a part of the GNOME desktop.
An alternative tool is to use GParted. It’s one of the most powerful tools for managing disk devices. GParted can handle disk formatting, partitioning, UUIDs, and even data rescue. Install GParted right away.
$ sudo dnf install gparted
Launch GParted. To check the partitions of a certain disk, select it from the drop-down menu on the top-right corner.
A partition in disk drives is a logical separation of the disk space. Depending on the disk space and partition table type, the number of partition varies. Generally, high-capacity disks are split into multiple partitions.
If the disk is already partitioned properly, then you may skip this part. Following this step will erase any existing data from the disk, ensuring that there’s nothing valuable stored.
Ensure that the disk isn’t in use. If any of the disk partitions are mounted, make sure to unmount them. Learn how to unmount partitions using umount command.
Creating a partition using CLI
Fdisk is a powerful tool for managing disk partitions. One major benefit of fdisk is, all the changes you make aren’t immediately applied to the disk. All the changes are stored in memory and only applied when you tell the fdisk to do so. Launch the fdisk tool in interactive mode for our target device.
$ sudo fdisk <device_label>
It’s an interactive mode with lots of options available. To see all the available options, enter “m”.
Enter “p” to print all the partitions in the current partition label. It’ll also report the partition table type (GPT/DOS/SGI/Sun).
If there’s no need for the partition table type to change, then proceed with deleting the partition. Enter “d” to prompt fdisk to delete the partition.
To change the partition type, enter “g” (GPT), “G” (SGI (IRIX)), “o” (DOS), or “s” (for SUN). In this case, I’m going to create a new empty GPT partition table.
Enter “w” to write the new partition table. Note that it’ll remove any existing partitions.
At this point, the fdisk will exit. The disk will contain all its free space. To make the space usable, it has to be partitioned. Re-launch fdisk for the disk.
The device must contain a partition or more to use the available storage space. To create a partition, enter “n”.
Fdisk will ask for various information, for example, the partition number, first/last sector, partition size, etc. Unless there’s something custom necessary, hit “Enter”. Fdisk will use the default values and the entire disk space for the new partition.
To write the changes to the disk, enter “w”.
Creating a partition using GUI
GParted another powerful solution for managing disk devices. Launch GParted.
From the top-left corner, ensure that the correct device is selected.
If the disk has any partition mounted, performing any alteration is going to be problematic. Right-click the partition(s) and select “Unmount”.
If the partitioning is fine, then there’s no need to touch anything. If not, consider re-partitioning the drive. Right-click the partition(s) and select “Delete”.
To create a new partition, right-click the “unallocated” space, and select “New”.
Change the values as you see fit. For this demonstration, the entire disk space will be under a single partition.
To take the changes into effect, click the “Apply All Operations” button. All the changes will be written to the disk, so ensure that everything is configured properly.
Once the process is finished, GParted will show the following window.
Creating a filesystem
The disk is properly partitioned. The next step is to create a Linux filesystem on the partition so that the operating system can use the space for storing data.
Creating a filesystem using CLI
Depending on the desired filesystem type, the command to run will change. By default, it’s recommended to make an EXT3/EXT4 filesystem for the best experience. If the disk is a portable one and used cross-device, then FAT16/FAT32 filesystem is recommended. However, FAT16 and FAT32 filesystems have a fixed value of the highest single file size.
Determine the new partition label.
In this demonstration, our target partition is “/dev/sdb1”. Note the mount point. Then, unmount the partition using the following command.
$ sudo umount -v <mount_point >
To format the partition, run the following command.
$ sudo mkfs -v -t <filesystem> <partition>
As for the filesystem, the mkfs tool supports the following values.
Creating a filesystem using GUI
Launch GParted and select the target device. Right-click the partition, go to “Format to”, and select your desired filesystem.
Once selected, click the “Apply All Operations” button.
Finally, the filesystem is ready to be used. It has to be mounted to be accessible from the operating system.
Mounting a filesystem using CLI
Here’s a guide on how to use the Linux mount command for mounting partitions. To mount our desired partition, first, create a directory. This directory will act as the mount point.
$ sudo mkdir -v /my_partition
Now, mount the partition to the mount point we just created.
$ sudo mount –source <partition> –target <mount_point>
Verify if the mounting was successful.
Mounting a filesystem using GUI
While GParted is capable of mounting a partition, it won’t allow the action unless the partition is declared under “/etc/fstab”.
An alternative is to use the GNOME Disks utility. Launch GNOME Disks. From the left panel, navigate to the target device. Select the partition and click “Mount selected partition”. Disks will automatically create a mount point for the partition.
This guide demonstrates adding a new disk device to Fedora. It isn’t anything difficult. It’s a slightly time-consuming process. The good news is, it’s mostly a one-time process. However, it’s common that you may need to perform these actions once again.