
Adding additional drives to Linux
Adding additional drives to Linux
Getting to use Linux
My current role predominantly requires me to work within the Windows environment, however, I do get to use Linux quite often, in fact, it is probably my favourite part of the current job. Much of the time, I am working with Virtual Machines, accessing and sharing drives with a Virtual Machine is usually quite simple and I won’t go into that in this post.
What I am going to cover is how we might access a second, third or more drives when using a native Linux installation.
Default working space..
Most of the time, I work with a couple of HP (Hewlett Packard) laptops, one of which contains multiple physical hard drives, but this would work for a laptop with a single physical drive that has multiple partitions, perhaps one for the Boot record, one for Windows and one for Linux.
Filesystems
It is possible to mount the Windows drive/partition at boot time, and most modern Linux installs can read the NTFS Windows filesystem, however, it is unlikely to be able to write to that partition.
Windows does do things differently, and by default, will not see the Linux partition, which is probably ext4 or perhaps even Btrfs, at all, so accessing files written with Linux whilst in the Windows OS is a little harder.
Sometimes I need to replicate things in both Linux and Windows, and from both Operating Systems, I could just create a Virtual Machine representing the other Operating System, but whilst Virtualisation is basically amazing, it doesn’t answer every question.
Therefore my prefered way of working is to have a 3rd drive or partition that is formatted with exFat, this is the format that you would find on most modern removable media (USB Sticks, SD Cards (at least an SDXC)). This is a format that most Operating Systems recognise, it can be read from and written to by pretty much all modern operating systems.
Third Drive
In my situation, at least one of my laptops has the ability to take 3 physical drives, not including USB/SD. As such, I use 1x NVMe for Windows, this has its own Boot partition. I have a second NVMe with Fedora, this again, has a boot partition (I will explain why later). I have a SATA III drive that I have formatted using exFat, this will be the shared space. However, as stated earlier, this would also work if you had more or less physical drives and or partitions, i.e. it is possible to take a large physical drive and partition it into Boot, Windows, Linux, Shared space, for example.
Why multiple boot partitions?
This is not essential, however, whenever I work on a machine that can take multiple drives, then I will go to any length to avoid messing with the Windows drive. It may come down to my lack of skill, but dealing with a broken Windows installation is a lot harder than dealing with a broken Linux installation, at least for me.
I installed Windows to a single NVMe, the boot partition is created by Windows as part of the installation process. I then added my second NVMe drive to the computer, I temporarily change the boot order to boot from a USB drive containing my Fedora install media, I install Fedora to the second drive, ignoring Windows completely. Once that installation is complete, I use my computers BIOS/UEFI settings to set the default boot order to the 2nd NVMe drive.
At this stage, booting the computer would always default to Fedora. When in Fedora I use the Grub2 config editor to detect and then add the Windows OS to my boot options. This could likely be done during the installation of Fedora, but I actually physically move the drive between computers sometimes, so knowing how to find a Windows installation and point to it is something I need to get used to.
Using Windows to format the drive
For simplicity, I booted into Windows, opened the Start Menu or Windows Menu as I think it is known these days, type Manage, the top option for me was Computer Management:
I went to Storage, found the new disk, right clicked on it, selected Make s Simple Volume and formatted it as exFat.
From Windows, I then set my default Downloads location to that new drive so that anything I download in one OS can be accessed by the other OS (I’ll do the same from Linux shortly).
I could have formatted the drive in Linux, the result would have been the same, I just chose to start in Windows this time.
Accessing the drive from Linux
Accessing the drive in Linux is a little more work. Using the filemanager, I can see the drive:
But clicking on the drive will require me to provide a password in order to mount it:
This in itself is not a show stopper, I could always do this without issue. However, it does mean that I would need to remember to manually mount the drive each time I boot into Linux before I want to access the files, or, write new files to that partition. Therefore what I need is the ability to auto-mount that drive, to do that, I need to know a little more about my drives.
lsblk and blkid
I’m going to use ‘lsblk to understand the drives I have available to me:
The output tells me that I have a couple sda partitions and multiple nvme partitions. As I already stated, I know the NVMe partitions relate to Operating Systems, the Sata III drive is my spare drive, therefore I’m interested in those sda partitions, and specifically, I want the largest partition as thats the one I’ve formatted using exFat.
I want to know a little more about that partition, so I am going to use blkid to get the UUID:
I need to record that UUID for use in the next step.
fstab
Let’s look at the current mountpoints, using fstab (sudo more /etc/fstab
):
I’m going to modify that file, it’s always worth making a backup, just in case.
sudo cp /etc/fstab /etc/fstab.old
sudo vi /etc/fstab
I will add the new entry to the bottom of the file:
##########################################################
# EXFAT - SHARED DRIVE MOUNT (MULTI-OS)
/dev/disk/by-uuid/8449-DCC8 /home/david/Downloads auto nosuid,nodev,nofail,x-gvfs-show,uid=1000,gid=1000 0 0
I may have gone a little crazy on my options (nofail,uid,gid, etc) but these work for me.
As you will perhaps notcie, I am mounting my user Downloads directory to this new drive, in fact, with Linux, I could mount almost any directory to almost any drive. I will still be able to mount the drive from other Linux user accounts as well, but that is not really an issue on this device as I am the only user.
I will keep more than just downloads in this directory, but it will also mean that any downloads I do make, which at the moment, seems to be gigabytes worth of Oracle stuff, it willl go directly to that drive and I will be able to access it from Windows as well.
There are risks, the key being that if I download junk, Windows will likely be the weaker link, but I am usually careful about what I download wanyway. Famous last words?
Testing
We need to test, we don’t want to make assumptions and then find it doesn’t work when we need it. The easiest test would be sudo mount -a
Verify that it actually connected with df
:
david@Voyager:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p3 975097856 210528664 762717336 22% /
/dev/nvme0n1p3 975097856 210528664 762717336 22% /home
/dev/nvme0n1p2 996780 487948 440020 53% /boot
/dev/nvme0n1p1 613184 19840 593344 4% /boot/efi
/dev/sda2 937659392 1536 937657856 1% /home/david/Downloads
I’d recommend a reboot as well, and then, write something and check it can be seen in Windows (or write in Windows and verify it can be seen in Linux). That should be it.
The end, or is it…
I said before that I sometimes move my Linux drive to other machines, for example, I have a desktop with some NVMe slots, if I do move the drive, I will need to update my fstab to account for that different system, however, I suspect this will be where my NVMe drive spends most of its time so it isn’t a thing I’m worried about today.