Auto mount Windows partition on startup

Continuing the discussion from Manjaro 20.1 - Windows partition mount issue:

I think my issue is similar. only I am unsure how to make the necessary updates to to /etc/fstab. I can see it in nano. I want to be careful here.

To be clear I am using a shortcut on my desktop to run a Windows game in wine. It works fine after I go into dolphin and re-mount the windows drive each time. I just want it to mount automatically.

After reading several threads like this I have an idea of what to do, I know I need to add something like:

dev/sda1 /home/abhi/Data ntfs-3g auto,rw,defaults,uid=1000,gid=1000,umask=022,utf8 0 0

But I am not sure how to adjust it for my system. Or where exactly to put the script.

Have a look at:

lsblk --fs

there you see which device would be the windows partition…

  1. Exchange /dev/sda1 with the correct one, but I would rather suggest to label the partition, like that:
sudo ntfslabel /dev/sdXY "windows" 

then you can use instead of /dev/sda1, this LABEL=windows (you can also use the UUID)

  1. Create folder:
sudo mkdir -pv /media/windows
  1. Add this to the file /etc/fstab
LABEL=windows /media/windows ntfs-3g defaults,noauto,x-systemd.automount,x-systemd.idle-timeout=30min,windows_names,uid=1000,gid=1000,umask=0022,fmask=0022 0 0
  1. Mount it:
sudo mount /media/windows

It will be mounted automatically on every boot when you access the folder and unmounted after 30min of idle.

1 Like

Ok so I got most of it done, but when I tried to add the label I got this:
sudo ntfslabel /dev/nvme0n1p3 “windows”
Windows is hibernated, refused to mount.
Failed to mount ‘/dev/nvme0n1p3’: Operation not permitted
The NTFS partition is hibernated. Please resume Windows and turned it
off properly, so mounting could be done safely.

I already logged into windows and turned fast start off in the settings. Also hibernate was unchecked, I checked (lol).

No idea why it would think windows is in hibernate, or why it would be.

Also I shut down fully every time I log out of windows because I hardly ever log in.

As a side note,since you are using KDE,you can also use the built-in automatic mount a removable device on login

1 Like

In FSTAB use the UUID as this is something that will not change and is reliable.

UUID=xxxxxxxxxxxxxxxxxxx         /path/to/mount/point file-system-type options...

You can also use Gnome Disks to set mount point.

You must disable Windows functions such as hibernation, hybrid sleep and fast startup.

If you fail to disable those services - Linux will not mount the device.

Create a file using below snippet - paste it into the terminal

sudo tee -a /etc/systemd/system/data-windows.mount > /dev/null <<EOT
Description=My Windows Partition
What=/dev/disk/by-uuid/$(lsblk -no UUID /dev/sda1)

start and enable the mount

sudo systemctl enable --now data-windows.mount

Now your windows partition will be available at the path /data/windows

What the first part did was to construct a mount unit - then use tee to write it to the correct location. The UUID is inserted as the result of a command which lists the UUID of the partition in question.

More info on the concept of mount units

1 Like

So far this seems to have worked. Thanks. I want to learn more about fstab and the command line stuff, but I am not quite there yet.