Samba share mounts as Root? [SOLVED]

Questions about Wi-Fi and other network devices, file sharing, firewalls, connection sharing etc
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
TrogdorMenoo
Level 2
Level 2
Posts: 99
Joined: Sun Nov 04, 2018 8:44 am

Samba share mounts as Root? [SOLVED]

Post by TrogdorMenoo »

Greetings. I'm having trouble with network shares where the mounted Linux share always shows 'root' as the owner and where my logged in user doesn't have write permissions.

The setup:
- Linux Mint 20 Cinammon (love it so far!) [this is the host computer]
-- VirtualBox running Linux Mint XFCE [this runs inside the host computer]
- Host has various Samba network shares
-- \\linuxHost\docs
-- Samba network username = 'dogfood'

What I want to do:
- Read/write files to the host computer's network share from the virtual machine running on the host. Intent is to allow the VM to access the host samba share to exchange files.

What I've done:
I added the samba share to /etc/fstab to be available at login with:

Code: Select all

//192.168.1.100/docs/shared /media/mydocs cifs username=dogfood,password=MeepMeep123$$
When I do "cd /media/mydocs" then "ls -l", I can browse the file system of the samba share. I can read files on there but I can't write. For example, if I open a text file that already exists on the network share, it opens it in read only mode. All the files/dirs show up as "root root".

However, if I do "sudo gedit textfile.txt", then I *can* read/write to anything.

But, why can I not read/write to the network share with the currently logged in user (in the VM)? I need to be able to read/write to the network share from a variety of different programs without needing to use sudo. Is there a way to make the network share available for read/write by the logged in user? I'm coming over from Windows and in that environment it does allow the logged in user to read/write.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 2 times in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
altair4
Level 20
Level 20
Posts: 11446
Joined: Tue Feb 03, 2009 10:27 am

Re: Samba share mounts as Root?

Post by altair4 »

CIFS is a virtual file system and will always mount with owner = root.

You can replace root with yourself if you want:
//192.168.1.100/docs/shared /media/mydocs cifs username=dogfood,password=MeepMeep123$$,uid=altair4
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
TrogdorMenoo
Level 2
Level 2
Posts: 99
Joined: Sun Nov 04, 2018 8:44 am

Re: Samba share mounts as Root?

Post by TrogdorMenoo »

altair4 wrote: Sat Oct 17, 2020 1:31 pm CIFS is a virtual file system and will always mount with owner = root.

You can replace root with yourself if you want:
//192.168.1.100/docs/shared /media/mydocs cifs username=dogfood,password=MeepMeep123$$,uid=altair4
Thank you! This worked PERFECTLY. I hope the beginner guides include this.
LakeMan-2
Level 1
Level 1
Posts: 4
Joined: Thu Dec 31, 2020 6:20 pm
Location: Canada

Re: Samba share mounts as Root? [SOLVED]

Post by LakeMan-2 »

Hi all,
This is my first post for help.
I have been using Linux Mint for 4 years now. I started with Mint 17.3 moved to 18.3 and now to 19.3. I have 4 machines, one is a Samba server hosting a number of HDD for various interest.
I have a media machine, an I5 4th gen with 16 GB of ram 2 SSD, I also have another I5 2nd get with 16 GB of ram (which I am upgrading to a 9th gen i7 with 32 GB of ram). These three machines I upgraded these from 18.3, no rebuild. Worked fine. I built a new i7 machine to replace the i5 2nd gen. All are dual boot with either Win 7 or Win 10 for mainly Adobe PS tools and Tax programs. I could have VM the Win images but I didn't. So all machine have very similar fstab files. The differences are the local partitions of root, boot, home and swap. The cifs are all identical. They mount a number of drives into /mnt which I symbolic link to my home directory for easy access. All worked great. cifs mounted with permissions $user,root and other.

Here is the cifs entries in fstab

Code: Select all

//192.168.50.124/linux2     /mnt/linux2         cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
//192.168.50.124/homefiles  /mnt/homefiles      cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
//192.168.50.124/scratch    /mnt/scratch        cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
//192.168.50.124/videos0    /mnt/videos0        cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
//192.168.50.124/videos1    /mnt/videos1        cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
//192.168.50.124/movies     /mnt/movies         cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
//192.168.50.124/travel     /mnt/travel         cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
//192.168.50.124/music      /mnt/music          cifs    credentials=/home/nor/.credentials,rw,uid=nor   0   0
I had rw access to all cifs mounts.

I notice a difference when I installed Mint 19.3 on my new i7 with the boot up screen. It was working fine but grub boot screen was different. The difference was that the upgrade from 18.3 to what I thought would be 19.3 was only to 19.0 So I have my i3, 2 i5 running 19.0 and my new i7 running 19.3.

So I used the upgrade in the upgrade manager to move from 19.0 to 19.3 which worked great with a couple of minor issue which were easy to fix.

But what changed was my i7 cifs mounts were now mounting with permissions root,root and other. And my symbolic link had a lock icon and were empty.


So I don't understand why, what changed? On my other i5 4 gen, which i upgraded all is working well with the right permissions $user,root and other. I made no changes to the i7 machine only the server the i3 machine, upgrade form 19 to 19.3. No Samba changes other than what was in the upgrade.

Code: Select all

nor@B365M:~$ cd /mnt
nor@B365M:/mnt$ ls -l
total 32
drwxr-xr-x 2 root root 4096 Dec 20 20:58 homefiles
drwxr-xr-x 2 root root 4096 Dec 20 20:39 linux2
drwxr-xr-x 2 root root 4096 Dec 20 20:58 movies
drwxr-xr-x 2 nor  nor  4096 Dec 20 20:58 music
drwxr-xr-x 2 root root 4096 Dec 20 20:58 scratch
drwxr-xr-x 2 nor  nor  4096 Dec 20 20:58 travel
drwxr-xr-x 2 root root 4096 Dec 20 20:58 videos0
drwxr-xr-x 2 root root 4096 Dec 20 20:58 videos1
I have a work around, I just open a terminal and type sudo mount -a and all mount correctly with $user,root and other permission and the symbolic links work
My SMB.CONF is below. I am only showing the changes I made to the default 19.3 install file. The suggestion from the release notes plus the change to
workgroup from the default.

You can see I tried a couple of chown commands to fix the problem to no avail. That's music and travel

The only think that corrects the problem is the mount -a

Code: Select all

nor@B365M:~$ cd /mnt
nor@B365M:/mnt$ ls -l
total 32
drwxr-xr-x 2 root root 4096 Dec 20 20:58 homefiles
drwxr-xr-x 2 root root 4096 Dec 20 20:39 linux2
drwxr-xr-x 2 root root 4096 Dec 20 20:58 movies
drwxr-xr-x 2 nor  nor  4096 Dec 20 20:58 music
drwxr-xr-x 2 root root 4096 Dec 20 20:58 scratch
drwxr-xr-x 2 nor  nor  4096 Dec 20 20:58 travel
drwxr-xr-x 2 root root 4096 Dec 20 20:58 videos0
drwxr-xr-x 2 root root 4096 Dec 20 20:58 videos1
nor@B365M:/mnt$ sudo mount -a
[sudo] password for nor:           
nor@B365M:/mnt$ ls -l
total 0
drwxr-xr-x 2 nor root 0 Mar  4 14:35 homefiles
drwxr-xr-x 2 nor root 0 Feb 25 14:47 linux2
drwxr-xr-x 2 nor root 0 Oct 23 19:49 movies
drwxr-xr-x 2 nor root 0 Nov 10 21:50 music
drwxr-xr-x 2 nor root 0 Jan 11 22:37 scratch
drwxr-xr-x 2 nor root 0 Nov 29 20:48 travel
drwxr-xr-x 2 nor root 0 Mar  4 18:06 videos0
drwxr-xr-x 2 nor root 0 Oct 21 14:38 videos1
nor@B365M:/mnt$ 

Code: Select all

[global]

## Browsing/Identification ###

# Change this to the workgroup/NT-domain name your Samba server will part of
   workgroup = SUNOR
# NWG as per 19.3 release notes.
   name resolve order = bcast host lmhosts wins
   client max protocol = NT1 

# server string is the equivalent of the NT Description field
	server string = %h server (Samba, Ubuntu)
I commented them out and no difference.


Note: that on my i5 that works I only changed to workgroup and did NOT add the two lines from the release notes.


Code: Select all

nor@B365M:/mnt$ ls -l
total 0
drwxr-xr-x 2 nor root 0 Mar  4 14:35 homefiles
drwxr-xr-x 2 nor root 0 Feb 25 14:47 linux2
drwxr-xr-x 2 nor root 0 Oct 23 19:49 movies
drwxr-xr-x 2 nor root 0 Nov 10 21:50 music
drwxr-xr-x 2 nor root 0 Jan 11 22:37 scratch
drwxr-xr-x 2 nor root 0 Nov 29 20:48 travel
drwxr-xr-x 2 nor root 0 Mar  4 18:06 videos0
drwxr-xr-x 2 nor root 0 Oct 21 14:38 videos1

Which is what I want.


I am at a loss, so can anyone suggest to me what the problem may be? Where to look or get help.

Thanks Lakeman (Nor)
altair4
Level 20
Level 20
Posts: 11446
Joined: Tue Feb 03, 2009 10:27 am

Re: Samba share mounts as Root? [SOLVED]

Post by altair4 »

As the great engineer will say: "The more they overthink the plumbing, the easier it is to stop up the drain."

Booting has become way more complicated over time and the networking stack on the Linux machine is often not fully operational when fstab is read so the cifs mounts fail. This is why a mount -a works. You are doing it after everything is up.

This HowTo has a couple of solutions to this problem: Automount Samba Shares with CIFS:

One requires you to change your mount points and the other uses systemd to fix a problem it created in the first place.
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.
LakeMan-2
Level 1
Level 1
Posts: 4
Joined: Thu Dec 31, 2020 6:20 pm
Location: Canada

Re: Samba share mounts as Root? [SOLVED]

Post by LakeMan-2 »

Thank you
That makes sense, my new machine is a 9th gen i7 which is way faster than my 2nd gen i3 server.
I am looking into the suggested solution, now that I have a new approach to proceed.

Thanks again.
User avatar
karlchen
Level 23
Level 23
Posts: 18206
Joined: Sat Dec 31, 2011 7:21 am
Location: Germany

Re: Samba share mounts as Root? [SOLVED]

Post by karlchen »

<Mod> OlivierFV's issue split into a new thread here: viewtopic.php?f=157&t=344843 </Mod>
Image
The people of Alderaan have been bravely fighting back the clone warriors sent out by the unscrupulous Sith Lord Palpatine for 771 days now.
Lifeline
Locked

Return to “Networking”