Moving from Windows to Linux - Disk management

Updated: April 27, 2022

Today, I'd like to break away from my recent template of Windows-to-Linux tutorials, which have focused on showing you how to install, configure and use a variety of programs, typically designed or intended only for Windows, using frameworks like WINE. What we shall discuss today is the juicy topic of disk and drive management.

Beyond applications, there's data to reckon with. And data is critical to everything. Things become extra complicated when one considers the cardinal differences between Windows and Linux. The former uses NTFS, and data is organized in drives (C:, D:, etc). Linux stores everything under one filesystem tree (root, /), and uses different filesystem formats (like ext4), although it can handle NTFS. So then, what gives if you're trying to move your stuff over? This tutorial is a neat suggestion for those looking for order, simplicity and clarity.

Preliminary reading

This guide cannot live in isolation. There are some hard laws of physics we must obey. First, if you don't know anything about disk and/or drive management, filesystems and alike, this article is not for you really. You do need a basic foundation of these principles. Let's be realistic. This article is for nerds, albeit those with little practical experience in Linux (just yet).

That said, here are some articles of mine you should peruse before delving any further:

GParted partitioning software tutorial

The ultimate Linux guide for Windows newbies

Same same but different

All right, now that we know the lingo and the technical details, let's discuss a scenario. Say you have a Windows machine with two physical disks and a total of five disk partitions. Let's assume the layout is as follows:

Now, let's assume that the owner of the computer with the following disk arrangement is interested in moving to Linux. So what they do is as follows:

They repartition their disks - specifically, they shrink the H:\ drive, and then create a number of new partitions in the freed (and now empty) space. They then install a Linux distribution here. Now, they run a dual-boot system, and when they power on the computer, or restart it, they see a menu that allows them to choose whether to continue into the Linux or Windows environment.

Resize plan

As you can see, I've outlined this and rather similar scenarios in my various dual-boot articles, like the one linked above, as well as the Windows 7 & Ubuntu and Windows 7 & CentOS guides. This should give you a good reference point for a similar adventure, as well as allow you to get a sense of what the initial differences in disk management in Linux would look like.

Now, the user has a system with two operating systems. However, there is a problem. The bulk of the data still resides in Windows and/or is saved/kept on Windows drives, formatted with the NTFS filesystem. There are several questions here:

Let's answer these, then, shall we!

sudo dnf install ntfs-3g ntfsprogs

Disk management opacity

The solution to the scarcity of disk space and/or easy data migration path is then to present the Windows data inside the Linux system, but in a manner that will be easy to discern, as well as allow practical data backups. To explain what I mean, consider the following:

In Linux, all paths resolve to one root (/). For instance, /home/igor would be the mount point to the home directory of the user named "igor". But the physical mapping of that directory can be anywhere. It can be a different partition, a different disk, even a different system (on a network). For instance:

This means that if a user mounts Windows drives, they will be presented in Linux as part of the single root filesystem, and they won't necessarily be discernible from other locations or paths. Again, for example:

Most Linux systems will mount removable, external or non-Linux devices under /run/media or /media. So if you see two directories under these locations, however named, you won't necessarily be able to distinguish between them. One could be an internal Windows NTFS-formatted partition, and another could be a FAT32-formatted USB drive.

The solution, then

To work around this problem, I use the following method:

What does this method ensure?

There are many useful benefits to this approach:

Here's how you can do it

Following our earlier example, the first step is to figure out how Linux "sees" the internal hard disks and how it identifies the Windows drives. Again, you need a little bit of expertise here. You can use the command-line tools like fdisk to output the list of devices and their partitions. Let's assume the following:

Create the /drives top-level path and the directories underneath (for Windows drives only):

sudo mkdir /drives
sudo mkdir /drives/C
sudo mkdir /drives/D
...

Now, as root or sudo, create a backup of the /etc/fstab file and then edit it in a text editor (like nano):

sudo cp /etc/fstab /home/"your user"/fstab-backup
sudo nano /etc/fstab

In the text editor, add mount points to your Windows drives.

/dev/sda1 /drives/C ntfs-3g defaults,locale=utf8 0 0
/dev/sda2 /drives/D ntfs-3g defaults,locale=utf8 0 0
...

What do we have here?

Here's an actual example from one of my systems:

# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/nvme0n1p5 during installation
# /boot/efi was on /dev/nvme0n1p1 during installation

UUID=7f4087e7-e572-44fd-a4a1-7489099937a0 / ext4 errors=remount-ro 0 1
UUID=C05A-951D /boot/efi vfat umask=0077 0 1
/swapfile none swap sw 0 0
/dev/nvme0n1p3 /drives/C ntfs-3g defaults,locale=utf8 0 0

The first three uncommented entries are mount entries for Linux filesystems, including the root (/), /boot/efi, which is required on UEFI systems (it also shows a VFAT filesystem), and a swapfile rather than a swap partition.

The fourth entry is the addition of a Windows drive. Please note that the device identifier isn't /dev/sdaXY but it is instead /dev/nvmeXnYp3. The reason for this is the system has an NVMe hard disk, and the Linux system identifies it differently from the IDE/SATA/SCSI devices. But for all practical purposes, the notation is the same.

What we have is a first (0) NVMe bus, first (1) device, third (3) partition. Again, please refer to my guides on hard disk management earlier, as well as the GRUB tutorial, as the notation for devices and partitions is different. And so, in the example above, we mount our Windows partition, effectively the third partition on the NVMe disk, under /drives/C.

You don't need to reboot to see the effect, simply remount everything:

sudo mount -a

Now, your Windows drives will be mounted to the corresponding paths, and you can see the data. The next step is to make the mounted data easier to use and access.

File manager & Windows drives

If you want to use the data from GUI (not command line), you can do the following trick:

ln -s /drives/C ~/Windows

The command above will create a symbolic link in your home directory. Windows will map to /drives/C, which is the mount point to the C:\ drive. So when you click on the Windows folder in your Linux file manager, you will see the contents of the Windows drive.

Drive shown under home

Now, you can go one step further and create shortcuts to these drives. For instance, in the Plasma desktop environment, you can add shortcuts to the sidebar, so Windows will map to /drives/C, Games will map to /drives/D, Data will map to /drives/E, and so forth. Your next step is to potentially add backup tasks into the flow, but that's a topic for another tutorial.

Conclusion

My tutorial isn't the holy grail of data management. Far from it. But it does provide elegant suggestions to common problems people may face going from Windows to Linux. It provides a way to present the Windows data in a visible, intuitive manner. It does not include any destructive operations. It allows for convenient backups and data separation. And it offers people used to the Windows workflow to slowly adjust to the new environment without compromising on familiar clues or established workflows.

With the Windows-only drives mounted in their own path, symbolic links to give you convenient access via GUI tools, and a logical mapping, you now should have a good, solid foundation for your migration. The next step is to make sure your important data is backed up. Because data without backups is just tragedy waiting to happen. We will cover that, as well as many other practical day-to-day tips in follow-up articles. For now, ponder a little about the data scheme I outlined above. And stay tuned for additional program setup guides. See you soon.

Cheers.