I while back I did an article about using NFS to share a folder from one Linux computer to another. This one is slightly different.
It's about sharing a drive from your Windows PC to your Linux computer.
Note: I have to write this article in two parts. I have to do the first part from my windows PC. Then I have to change computers and do the second part from my Linux system.
I am using Windows 11 Professional for this article. Your steps might be slightly different.
Open up your file explorer in Windows. You share just a folder if you like, or an entire drive if your like. The steps are same either way. You cannot share a single file. A folder or a drive are really the only two options. In this case I will be sharing my F: drive.
Right click on the "Local Disk (F) icon. Obviously if you want to share your D: drive or E: drive it will be different.
Notice there is a "Sharing" tab at the top. Click on that.
Click on the the "Share" button. Once you click on it, it will be greyed out, and you will see the drive is shared.
Go ahead and click on "Advanced Sharing".
Here you can share to just a single user, or in my case, I'm sharing to everyone who has an account on my Windows PC.
You can give them Read only or Read/Write (Change) permissions as you think is best. Click "Apply" and then click on "OK".
You can close all of these popups now; your drive is shared.
This next part is a little tricky. What account are you using on your PC. My login screen has my full name.
Yours might say "Elvis Pressley" or something like that. Usually it will have a first and last name. This probably isn't your login account. It's just your name. Although, your login password is the password we'll need for this.
So then, if that isn't your login account, what is? Open up a Windows command line prompt on your Windows PC and type.
This will usually look something like this... computername/username.
example:
hunterBlaptop/hunterb
That could be your computer account you need for file sharing, but that doesn't always work.
Option 2. (This is what worked for me).
Hold down your Windows key and the R key at the same time. When the popup appears type this.
"control userpasswords2". You should then see a screen similar to this.
In my case my computer account is tied to my gmail account. You may have something similar.
One last command we can run on our Windows PC before we move over to the Linux system.
That should return something similar to this.
Make sure the drive you shared is in this list. Since my F: drive is here, I'm good to go.
=================================================================
Ok, now for the second part. I'm logged into my Linux computer now.
First need to make a mount point on our Linux computer.
You will need to install the cifs-utils package on your Linux computer.
Debian/Ubuntu/Mint
Fedora/Redhat/Rocky/Alma
Arch
This is the command we will use to mount our Windows PC F: drive.
Obviously your username and password will be different.
If all goes according to plan, you should now see your Windows drive mounted on your PC.
It should look similar to the last entry here.
Well, OK, that's great, but the next time you reboot your computer, you'll have to mount it again. How do we make it permanent? Add this line to your /etc/fstab file.
That will work, but now my windows password is out in the open, and everyone who has access to the fstab file can see my password. What can we do about that?
Let's create a file in your home directory that only you (and root) have access to. We can name it something like
'win-credentials"
Now let's change our mount line in /etc/fstab
Now no one can see your windows credentials (except root).
It's about sharing a drive from your Windows PC to your Linux computer.
Note: I have to write this article in two parts. I have to do the first part from my windows PC. Then I have to change computers and do the second part from my Linux system.
I am using Windows 11 Professional for this article. Your steps might be slightly different.
Open up your file explorer in Windows. You share just a folder if you like, or an entire drive if your like. The steps are same either way. You cannot share a single file. A folder or a drive are really the only two options. In this case I will be sharing my F: drive.
Right click on the "Local Disk (F) icon. Obviously if you want to share your D: drive or E: drive it will be different.
Notice there is a "Sharing" tab at the top. Click on that.
Click on the the "Share" button. Once you click on it, it will be greyed out, and you will see the drive is shared.
Go ahead and click on "Advanced Sharing".
Here you can share to just a single user, or in my case, I'm sharing to everyone who has an account on my Windows PC.
You can give them Read only or Read/Write (Change) permissions as you think is best. Click "Apply" and then click on "OK".
You can close all of these popups now; your drive is shared.
This next part is a little tricky. What account are you using on your PC. My login screen has my full name.
Yours might say "Elvis Pressley" or something like that. Usually it will have a first and last name. This probably isn't your login account. It's just your name. Although, your login password is the password we'll need for this.
So then, if that isn't your login account, what is? Open up a Windows command line prompt on your Windows PC and type.
Code:
whoami
This will usually look something like this... computername/username.
example:
hunterBlaptop/hunterb
That could be your computer account you need for file sharing, but that doesn't always work.
Option 2. (This is what worked for me).
Hold down your Windows key and the R key at the same time. When the popup appears type this.
"control userpasswords2". You should then see a screen similar to this.
In my case my computer account is tied to my gmail account. You may have something similar.
One last command we can run on our Windows PC before we move over to the Linux system.
Code:
net share
That should return something similar to this.
Code:
net share
Share name Resource Remark
-------------------------------------------------------------------------------
C$ C:\ Default share
IPC$ Remote IPC
F$ F:\ Default share
ADMIN$ C:\WINDOWS Remote Admin
F F:\
The command completed successfully.
Make sure the drive you shared is in this list. Since my F: drive is here, I'm good to go.
=================================================================
Ok, now for the second part. I'm logged into my Linux computer now.
First need to make a mount point on our Linux computer.
Code:
sudo mkdir /mnt/windows_f
You will need to install the cifs-utils package on your Linux computer.
Debian/Ubuntu/Mint
Code:
sudo apt update
sudo apt install cifs-utils
Fedora/Redhat/Rocky/Alma
Code:
sudo dnf install cifs-utils
Arch
Code:
sudo pacman -S cifs-utils
This is the command we will use to mount our Windows PC F: drive.
Code:
sudo mount -t cifs -o username='[email protected]',password='pri$cill@',vers=3.0 //10.0.0.75/F /mnt/windows_f
Obviously your username and password will be different.
If all goes according to plan, you should now see your Windows drive mounted on your PC.
Code:
tmpfs 32G 4.0K 32G 1% /tmp
/dev/nvme0n1p2 2.9G 371M 2.5G 13% /boot
/dev/nvme0n1p3 800G 57G 744G 8% /home
/dev/nvme0n1p4 80G 2.7G 78G 4% /var
/dev/nvme0n1p7 912G 111G 802G 13% /space
/dev/nvme0n1p1 333M 7.6M 326M 3% /boot/efi
/dev/sda1 234G 168G 55G 76% /sda
/dev/sdb1 481G 2.1M 456G 1% /sdb
tmpfs 1.0M 0 1.0M 0% /run/credentials/systemd-tmpfiles-setup.service
tmpfs 1.0M 0 1.0M 0% /run/credentials/systemd-resolved.service
tmpfs 6.3G 3.7M 6.3G 1% /run/user/1000
tmpfs 6.3G 84K 6.3G 1% /run/user/0
//10.0.0.75/F 1.9T 17G 1.9T 1% /mnt/windows_f
It should look similar to the last entry here.
Well, OK, that's great, but the next time you reboot your computer, you'll have to mount it again. How do we make it permanent? Add this line to your /etc/fstab file.
Code:
//10.0.0.92/D /mnt/windows_d cifs [email protected],password=b1gB@ng45,vers=3.0 0 0
That will work, but now my windows password is out in the open, and everyone who has access to the fstab file can see my password. What can we do about that?
Let's create a file in your home directory that only you (and root) have access to. We can name it something like
'win-credentials"
Code:
username=wilmaflintstone
password=fr3dfl1st0ne
Now let's change our mount line in /etc/fstab
Code:
//10.0.0.63/f /mnt/windows_f cifs credentials=/home/wilma/win-credentials,uid=1000,gid=1000,dir_mode=0755,file_mode=0755 0 0
Now no one can see your windows credentials (except root).
Attachments
Last edited: