Showing posts with label samba. Show all posts
Showing posts with label samba. Show all posts

Wednesday, September 29, 2010

Ubuntu 10.04: Sharing a Folder on an NTFS Partition

I had two computers running Ubuntu 10.04.  These machines were connected by ethernet cable through a router.  Both had Samba installed, and both had a shared folder set up as described in another post.  I had set up one of those shared folders on an ext3 partition.  As that other post indicates, I was able to see the contents of that shared folder from the other computer.  But without thinking about it, I had set up the other computer's shared folder on an NTFS partition.  Seeing a folder on that partition turned out to be a more complicated matter than I had expected.  This post describes my efforts in that regard.

Right away, I rediscovered that chown wouldn't work as expected with NTFS drives, and that it was therefore necessary or advisable to type "sudo gedit /etc/fstab" and change the lines for NTFS drives or partitions to something like this:

UUID=[UUID for the drive] /media/partitionname ntfs-3g rw,suid,dev,exec,auto,user,async,umask=000 0 0
and then unmount ("sudo umount /media/partitionname") and remount the partition.  Remounting would apparently force a look at the new contents of fstab, and could be done with "sudo mount /dev/sdc3 /media/drive1" or just "sudo mount -a" (assuming a folder named /media/drive1 had already been created (e.g., "sudo mkdir /media/drive1")).  That fstab line was one I had developed to replace the "defaults" word that appeared in some fstab lines previously:  it made all of the default settings explicit, and changed some of them.  Yet even with this change, when I tried to set the Sharing Options in Nautilus, I got this error message:
Folder Sharing

'net usershare' returned error 255: net usershare add: cannot share path /media/partitionname/folder2 as we are restricted to only sharing directories we own.

Ask the administrator to add the line "usershare owner only=false" to the [global] section of the smb.conf to allow this.
I was willing to go into smb.conf and make that change, but first I wanted to know why (as I confirmed with a right-click > Properties) root still owned that folder.  This led to the insight that NTFS filesystems (such as the one I was trying to share) did not remember ownership, so the partition would need to be reminded each time I mounted it.  One way to do this was to modify the fstab line to include user and group identifications:
UUID=[UUID for the drive] /media/partitionname ntfs-3g rw,suid,dev,exec,auto,user,async,umask=000,uid=username,gid=groupname 0 0
and then save fstab and unmount and remount the partition (above).  And yet that still didn't do it.  The better statement seemed to be, not that NTFS partitions needed to be reminded, but that they simply didn't have an ownership concept.  There seemed, then, to be no alternative but to type "sudo gedit /etc/samba/smb.conf" and add the line "usershare owner only=false" to its [global] section, as advised above.  I saved and closed that and tried Sharing Options again.  This time it worked, or at least it didn't give me an error message.

Unfortunately, the shared folder still wasn't showing up on the other computer's Places > Network list.  It sounded like the solution might be to try Sharing Options as root ("sudo nautilus").  Unfortunately, at this point "sudo nautilus" was giving me an error message on that computer:
(nautilus:23890): Unique-DBus-WARNING **: Error while sending message: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
I wondered what would happen if I stepped away from the NTFS situation for a moment.  I decided to try sharing a folder on an ext3 partition in that same computer.  I right-clicked on the ext3 partition in Nautilus, chose Create Folder, named the folder, went to the Share tab, and selected "Share this folder" and "Allow others to create and delete files in this folder."  This gave me an error message:
'net usershare' returned error 255: net usershare add:
cannot stat path /media/partitionname/foldername to ensure this is a directory.  Error was No such file or directory
I guessed that this might be because I had gone directly to the Share tab without first clicking Close in the Basic tab there in the P4 Share Properties dialog.  So, OK, I saved the new folder first, and then right-clicked on it in Nautilus and chose Sharing Options.  This time it went OK.  I went into System > Administration > Samba, as described in the other post, and added this folder there.  But I still wasn't able to see it from the other computer.  I rebooted this problematic machine and tried again.  In doing so, I noticed that GParted and some other things were still running on another desktop, so that may have explained why "sudo nautilus" worked OK after the reboot.  The sharing step just described also worked OK.  But Places > Network on the other computer still didn't show the problematic computer.  

I was just about to change some hardware and reinstall Ubuntu on that machine anyway, so I deferred further effort on this project until after that was done.  At that point, though, I found a better folder-sharing solution by using a Synology network-attached storage (NAS) unit.

Tuesday, September 28, 2010

Ubuntu 10.04: Ethernet Networking Two Computers and a Router

I had installed Ubuntu 10.04 on two desktop computers.  Both were connected by ethernet cable to a router.  This seemed like the basis for a network, so that the two computers could talk to each other directly.  I had not previously set up a network in Ubuntu.  This post describes that learning experience.

I started with a search for guidance.  This led to a thread that persuaded me to try Samba shares, with Webmin for my Samba GUI.  So I typed these lines, one at a time:

sudo apt-get install samba
wget http://prdownloads.sourceforge.net/webadmin/webmin_1.510-2_all.deb
sudo dpkg --install webmin_1.510-2_all.deb
sudo apt-get install -f
The last line was a response to the error messages.  Then, in Firefox, I went to https://localhost:10000 and, after confirming a security exception, I entered the same username and password that I used to log into Ubuntu on the computer.  This gave me a locally stored Webmin webpage.  I clicked "Refresh Modules" on the left side of the page.  When that process was done, I clicked on Servers, in the top left corner.  Sure enough, it said, "Samba Windows File Sharing."  I went through that same process on both computers.

Then I searched for information on how to use Webmin.  This led to the discovery that Webmin was not fully compatible with Ubuntu, which would explain why it wasn't available for download through Synaptic.  So now it was time to undo what I had just done:
sudo apt-get remove webmin
sudo apt-get autoremove
As an alternative, someone mentioned eBox.  It looked like eBox had had some hard times, but hopefully those were all behind us now.  So I went into Synaptic and marked ebox-samba for installation.  This brought the plain ebox platform and a boatload of other packages along with it.  One of those packages was ddclient, which asked me many questions that I could not answer.  I tried to fake it, just going with the defaults, but wound up with an "Empty host list" message telling me that I had failed in some significant sense.  With that taken care of, Synaptic went ahead and installed all these downloads, presenting me once again with the ddclient Empty host list before it was done.  Yet after all that, there was no eBox icon in my menu and typing "ebox" at the prompt just gave me "command not found."  So I used the same steps as above to remove eBox.

A different search led to a page that advised me to type this command:
sudo apt-get install samba samba-common system-config-samba
With that done, I went to System > Administration > Samba.  This brought up a Samba Server Configuration dialog.  There, it looked like I could go to File > Add Share to designate a folder that would be shared between computers.  I took these same steps on the other computer.  Then I specified a folder on one computer that I did want to share.  I made it writable, visible, and accessible to everyone.  I found that this had to be a folder; I couldn't share a whole partition.  Later, I saw in another source that I should also have gone into Preferences > Server Settings > Security tab, there in the Configuration dialog, and change Authentication Mode to Share and Guest Account to my username, so I went back and did that,  Then, back in Nautilus, I right-clicked on that folder and selected Sharing Options > Share this folder and allowed others to create and delete.  I right-clicked on the folder in Nautilus again and went to Properties > Permissions, but it was already owned by me with all kinds of rights and privileges.

That seemed to be all I was supposed to do.  But I couldn't figure out where I was supposed to go, on the other computer, to see the shared folder on the first computer.  Eventually I saw instructions to go to Ubuntu's menu > Places > Network.  There, it had entries for each of the two computers, plus something called Windows Network.  I found that, if I just double-clicked on the entry for the other computer and then waited patiently for it to do its thing, with no visible indication that it had heard me, eventually (after maybe ten seconds) it would get around to showing me the shared folder on the other computer.  And it worked:  I was able to retrieve a file from that other computer.