Fedora Linux Support Community & Resources Center
  #1  
Old 9th August 2011, 01:39 PM
Norfen Offline
Registered User
 
Join Date: Aug 2011
Posts: 5
linuxchrome
Sharing an external hard drive using Samba.

Hi everyone,

I'll try to make it as short as possible. I installed Fedora 15 5 days ago after using debian-based distros for a few years, and until now I've had the habit of sharing many files (mostly multimedia) on my home network, except since I'm the only one using Linux, I have to do it using Samba.
In Ubuntu, Xubuntu and Linux Mint, this worked like a charm.

Two things have changed this week: I switched to Fedora 15 like I said before, and I bought a new USB external HDD. I previously used a 500 GB Western Digital, and changed for a 1.5 TB SAMSUNG which is linked to my station via USB. The drive works well and I cp'd the 450 gigs of the ancient drive within the new one without a problem.

Ever since I managed to set up fedora and GNOME 3 as I would like it, I've been trying to setup the network sharing via Samba, and that's a genuine 4-day long headache now.
Thing is, yesterday, it worked. After setting everything right, creating an automount of the external HDD in a maybe-too-much permissive folder, allowing Samba through the firewall, getting to know that buddy called SELinux I had never met before and which I struggled to tame ; after setting everything up, it worked seamlessly, I streamed music from the Windows PCs of my network and began watching a film.

Except I had a problem which had nothing to do with Linux: letting the USB drive plugged in on startup prevented the BIOS phase from going well, and my station was stuck on my motherboard splashscreen. To fix this, I had to disable the USB Legacy in my BIOS. Did the trick. Yesterday night, I rebooted like that, and everything was fine.
This morning, Fedora wouldn't boot. Since the new BIOS parameters didn't switch the drive on on startup, fstab was trying to mount a drive which wasn't there, and thus crashed, switching to emergency mode.
Had to remove the ftsab line concerning the USB drive for Fedora to boot again.

Alrite, that's fixed, I thought ; I just changed the fstab options adding noauto,user, etc. and I thought it would be ok, but it ain't.
It's now been 3 hours without me finding any clue as to how to get this working.

IMO, the problem comes from the fact that Samba is missing the right to access the drive. Samba seems to be OK: from the Windows station I can see my Linux station on the network map, I can access it entering the Smbuser I created for this, and the "ext-hdd" dir is present (that's the alias I used in the Samba config files), but when I try to access it, Windows says it can't access it.


I'll try to add as many pieces of information as possible that might be useful:

SELinux config:
Code:
[norfen@norfens-station ~]$ getsebool -a | grep samba
samba_create_home_dirs --> on
samba_domain_controller --> on
samba_enable_home_dirs --> off
samba_export_all_ro --> on
samba_export_all_rw --> on
samba_run_unconfined --> on
samba_share_fusefs --> on
samba_share_nfs --> on
use_samba_home_dirs --> off
virt_use_samba --> on
/media/SAMSUNG permissions:
Code:
[norfen@norfens-station media]$ ls -al
[...]
drwx------.  1 norfen norfen  4096 Aug  6 17:23 SAMSUNG
Samba and Samba-client are ticked as Trusted Services in the Firewall.

My simplified /etc/samba/smb.conf:
Code:
[...]
	workgroup = WORKGROUP
	server string = Samba Server Version %v
[...]
	security = user
[...]
[ext-hdd]
	comment = External HDD on Norfen's Station.
	path = /media/SAMSUNG
	read only = no
	browseable = yes
	valid users = sarafinah
(Note: sarafinah is the user supposed to access the files on the network, she exists both as a Fedora user and a Samba user).



Thanks in advance to whoever will try and help me, and I hope a similar post doesn't already exist but I doubt it since I've been looking for answers for 4 days.
Reply With Quote
  #2  
Old 9th August 2011, 03:45 PM
kukacek Offline
Registered User
 
Join Date: Mar 2010
Location: Kurim, Czech Republic
Posts: 16
linuxfirefox
Re: Sharing an external hard drive using Samba.

Hi,

I believe it is issue with permissions. As I can see the only user able to read the directory is norfen. Change the permissions as it is suitable for you, but grant sarafinah with execute and read rights.

If permissions will not solve the issue, could you provide an output of the following command?
Code:
smbclient //localhost/ext-hdd -U sarafinah
Reply With Quote
  #3  
Old 9th August 2011, 05:40 PM
Norfen Offline
Registered User
 
Join Date: Aug 2011
Posts: 5
linuxchrome
Re: Sharing an external hard drive using Samba.

Oh crap, I forgot to tell.

I was trying to mount my external drive manually because when I let the automount do the job, I can't seem to find a way to change the permissions on the mount folder.

To make it clear:

Code:
[root@norfens-station media]# ls -al /media | grep SAMSUNG
drwx------.  1 norfen norfen  4096 Aug  6 17:23 SAMSUNG
[root@norfens-station media]# chmod -R 777 /media/SAMSUNG
[root@norfens-station media]# ls -al /media | grep SAMSUNG
drwx------.  1 norfen norfen  4096 Aug  6 17:23 SAMSUNG
I believe the problem comes from the ntfs-3g drivers who's responsible for automounting the ntfs drives if I'm not mistaken, but I'm sincerely not used to tweaking with this tool and a few google searchings didn't help me figure it out...

As for the command you asked me to perform, first I must say that I had to install samba-client, which seems strange since I've been able to connect to the windows shared folders of my network since I installed Samba.

After the install, here's the result:
Code:
[norfen@norfens-station ~]$ smbclient //localhost/ext-hdd -U sarafinah
Enter sarafinah's password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.5.8-68.fc15]
smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
Error in dskattr: NT_STATUS_ACCESS_DENIED
smb: \> cd ..
smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
Error in dskattr: NT_STATUS_ACCESS_DENIED
smb: \> cd ext-hdd
cd \ext-hdd\: NT_STATUS_ACCESS_DENIED

Thanks for replying!
Reply With Quote
  #4  
Old 10th August 2011, 09:08 AM
kukacek Offline
Registered User
 
Join Date: Mar 2010
Location: Kurim, Czech Republic
Posts: 16
linuxfirefox
Re: Sharing an external hard drive using Samba.

Hi

Ok, I see. NTFS disk, right? You need to do few thing to get this working.
First, add both users norfen and sarafinah to disk group:
Code:
$ grep disk /etc/group
disk:x:6:root

# usermod -a -G 6 norfen
# usermod -a -G 6 sarafinah
Then modify automounter options for the disk and add following parameters to -fstype: fmask=0002,dmask=0002,umask=0002,gid=6.
Something like
Code:
SAMSUNG -fstype=fuseblk,user,auto,fmask=0002,dmask=0002,umask=0002,gid=6
Of course change it according to your needs. Hope it will help.



kuku
Reply With Quote
  #5  
Old 10th August 2011, 01:31 PM
Norfen Offline
Registered User
 
Join Date: Aug 2011
Posts: 5
linuxchrome
Re: Sharing an external hard drive using Samba.

Hello again and thanks for your help.

The problem is, I can't seem to figure out where the heck is that automounting feature configured.

I did a chkconfig | grep on and nothing there seems to be supposed to automount devices plugged in. In the Fedora docs for fc14, all the configuration files named are totally absent from my /etc dir. So the main problem is that I have been trying to change the automount permissions for a while to allow more access, but I really can't find where that gets done.

If you have a clue on that, I'd really love to hear it.

Just in case:

Code:
[norfen@norfens-station ~]$ sudo chkconfig | grep 5:on
abrt-ccpp      	0:off	1:off	2:off	3:on	4:off	5:on	6:off
abrt-oops      	0:off	1:off	2:off	3:on	4:off	5:on	6:off
auditd         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
cpuspeed       	0:off	1:on	2:on	3:on	4:on	5:on	6:off
cups           	0:off	1:off	2:on	3:on	4:on	5:on	6:off
ip6tables      	0:off	1:off	2:on	3:on	4:on	5:on	6:off
iptables       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
iscsi          	0:off	1:off	2:off	3:on	4:on	5:on	6:off
iscsid         	0:off	1:off	2:off	3:on	4:on	5:on	6:off
livesys        	0:off	1:off	2:off	3:on	4:on	5:on	6:off
livesys-late   	0:off	1:off	2:off	3:on	4:on	5:on	6:off
lldpad         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
lvm2-monitor   	0:off	1:on	2:on	3:on	4:on	5:on	6:off
mdmonitor      	0:off	1:off	2:on	3:on	4:on	5:on	6:off
netfs          	0:off	1:off	2:off	3:on	4:on	5:on	6:off
nmb            	0:off	1:off	2:on	3:on	4:on	5:on	6:off
portreserve    	0:off	1:off	2:on	3:on	4:on	5:on	6:off
sandbox        	0:off	1:off	2:off	3:off	4:off	5:on	6:off
sendmail       	0:off	1:off	2:on	3:on	4:on	5:on	6:off
smb            	0:off	1:off	2:on	3:on	4:on	5:on	6:off
smolt          	0:off	1:off	2:on	3:on	4:on	5:on	6:off
As I awaited you reply (with a huge bit of impatience I must admit), I ran a little test after adding norfen and sarafinah to the disk usergroup:
Code:
$ mkdir /media/test
$ chown -R norfen:disk /media/test
$ chmod -R 770 /media/test
and added the /media/test folder in the Samba shared dir list. This works like a charm, Windows users can stream videos through the network and I can access it locally using smbclient.
IMO this totally means it's a permission-related problem.

BTW, if you meant for me to add the mounting options in /etc/fstab, I must precise that I already tried to add this:
Code:
UUID=9CBCD465BCD43C08 /media/ext-hdd    ntfs  noauto,user,exec,rw,async  0  0
and I saw no diffrerence since the device was still automounted on plug in /media/SAMSUNG by the-great-unknown-process-responsible-for-that.

I'm pretty sure I'm missing the big picture here but I can't understand why.

Thanks again for your interest in my problem.

Last edited by Norfen; 10th August 2011 at 01:36 PM.
Reply With Quote
  #6  
Old 10th August 2011, 04:15 PM
kukacek Offline
Registered User
 
Join Date: Mar 2010
Location: Kurim, Czech Republic
Posts: 16
linuxfirefox
Re: Sharing an external hard drive using Samba.

Ah ok, so it is automounted by HAL, I thought you are using autofs as automounter. My mistake, I did not get it.

Actually for HAL, I am not really sure where/how to configure it, try to google it out.
Anyway, if you will mount it via fstab, put the following to your try you mentioned above: gid=6,umask=0002 or you can put both users to a different group and set the gid to this group.
Code:
UUID=9CBCD465BCD43C08 /media/ext-hdd    ntfs  noauto,user,exec,rw,async,gid=6,umask=0002  0  0

kuku
Reply With Quote
  #7  
Old 10th August 2011, 09:25 PM
Norfen Offline
Registered User
 
Join Date: Aug 2011
Posts: 5
linuxchrome
Re: Sharing an external hard drive using Samba.

Allright...

I think I got a workaround thanks to your help, but I'm not totally sure yet.

Here's what I did:

I edited my /etc/fstab according to what you said:
Code:
UUID=9CBCD465BCD43C08 /media/ext-hdd    ntfs  noauto,user,exec,rw,async,gid=6,umask=0002  0  0
And to automate the mounting lately in the boot process, I added this to my /etc/rc.d/rc.local:
Code:
mkdir /media/ext-hdd
chown -R norfen:disk /media/ext-hdd
chmod -R 775 /media/ext-hdd
mount -U 9CBCD465BCD43C08
For the time being, it works... But on second thought, I wonder if there's a real difference between this and replacing 'noauto' with 'auto' in fstab... So I'll try it a few days before declaring the problem solved. With auto, the fact that the USB device wasn't turned on at startup hanged the boot process.

Anyway, thanks a lot for your help, and if this workaround keeps working, I hope the thread'll be useful to other people!

I'll be away from home for a few days so I'll post news in a week or so.
Reply With Quote
  #8  
Old 16th August 2011, 03:38 PM
Norfen Offline
Registered User
 
Join Date: Aug 2011
Posts: 5
linuxchrome
Re: Sharing an external hard drive using Samba.

Hello again!

This time, I think I'm done.

The startup script works well and doesn't hang startup process if the external HDD isn't plugged in.

Since the BIOS property "USB Legacy Disabled" sometimes prevents the drive to turn on when the computer starts, I also made a lil' bash script (vide infra) to simplify the post-boot mounting, since NTFS driver (ntfs-3g) won't allow users to mount a NTFS drive without tweaking with a few annoying things I'm sincerely not comfortable with.

I think it's safe to tag this thread as solved, many thanks to kukacek, and I hope my unfortunate experience will help other puzzled people!

My /usr/bin/mntexthdd:
Code:
#!/bin/bash

# Bash script to mount external harddrive in case it didn't happen on startup.
# Execute as root!

# Make sure only root can run this script.
if [[ $EUID -ne 0 ]]; then
	echo "This script must be run as root." 1>&2
	exit 1
fi
# Check if the mounting-targetted directory exists, and create it if not.
if [ ! -d "/media/ext-hdd" ]; then
	mkdir /media/ext-hdd
fi
chown -R norfen:disk /media/ext-hdd
chmod -R 775 /media/ext-hdd
mount -U 9CBCD465BCD43C08
Reply With Quote
Reply

Tags
samba, usb drive, windows shares

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
When Safely Remove Drive menu is clicked on the external Hard Drive FD15 gets stuck vefoda Hardware & Laptops 16 3rd November 2011 05:31 PM
sharing a hard drive zatchchris Servers & Networking 5 21st June 2010 06:22 PM
Booting from USB external drive instead of internal hard drive davrom Hardware & Laptops 2 24th November 2008 11:56 AM
Sharing Hard Drive between Fedora 6 and Windows XP kotrt Hardware & Laptops 3 25th April 2007 05:35 AM
Trouble sharing external hard drives mckechan Using Fedora 0 17th March 2007 10:57 AM


Current GMT-time: 01:12 (Thursday, 24-04-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat