LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 05-06-2010, 11:51 PM   #1
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,688

Rep: Reputation: 55
Question on external enclosure


Hi folks,

I'm now using an external enclosure mounted with an old 40G hard drive for external storage sharing between 2 Linux PCs. I have been running it sometimes. It works without problem. The only disadvantage is the files upload changing ownership. Because the device has to mount as root. It is not very convenient as I have to change the owner of the files again after download. The advantage is old HD can be used.


My questions are;

1)
Can the abovementioned disadvantage be fixed? Avoiding changing files ownership on upload?

2)
I have an idea to purchase an USB external HD. It's price is not expensive. Can the abovementioned disadvantage be avoid?

3)
Shall I consider NAS instead of USB external HD? The device only serves 2 PCs?


TIA


B.R.
satimis
 
Old 05-07-2010, 06:02 AM   #2
RockDoctor
Senior Member
 
Registered: Nov 2003
Location: Minnesota, US
Distribution: Fedora, Ubuntu, Manjaro
Posts: 1,775

Rep: Reputation: 423Reputation: 423Reputation: 423Reputation: 423Reputation: 423
Why does have to mount as root? Are you mounting from the command line? Is there an entry for your external disk in /etc/fstab?
 
Old 05-07-2010, 06:30 AM   #3
never say never
Member
 
Registered: Sep 2009
Location: Indiana, USA
Distribution: SLES, SLED, OpenSuse, CentOS, ubuntu 10.10, OpenBSD, FreeBSD
Posts: 195

Rep: Reputation: 37
In answer to your questions.

1. Technically file ownership doesn't change. It is based on the UID which is a numeric value. Currently you probably have something like this:

Code:
UID     Computer1    Computer2
1000    root         root
1001    user1        user2
1002    user2        user3
1003    user4        user1
So when you plug the device into Computer 1 files are owned by the list of users on Computer1, when you change to Computer2 the ownership appears to change because the same UID is a different user on computer2.

So a file owned by user1 on computer1 will in fact be owned by user2 on computer2. The UID did not change.

1-a. One way to solve your problem is to make sure both systems use the same UID for all Users. eg.
Code:
UID     Computer1    Computer2
1000    root         root
1001    user1        user1
1002    user2        user2
1003    user3        user3
1004    user4        user4
Up front this is a labor intensive solution because users on one computer will have to be modified, and permissions changed . . .

1-b. Another option might be to use a script to move files to removable drive Have the script chmod and chown the files as needed.

1-c. Another option would be to use a file system that does not store ownership such as FAT. If you do that each computer will mount the removable drive as the logged in user, or root (depending on distro and setup).

2. This will probably act just like 1-c above. Why? Because most all USB Flash Drives come formatted with, you guessed it FAT.

3. NAS would be one option, you could also set up an NFS Share, or Samba between the systems if they are on the same netowrk.


Hope this helps.
 
Old 05-07-2010, 07:02 AM   #4
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,688

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by RockDoctor View Post
Why does have to mount as root? Are you mounting from the command line? Is there an entry for your external disk in /etc/fstab?
Hi RockDoctor,

Sorry I made a mistake. Previously I posted my question only from my recollection.

Now I have the USB external enclosure connected to this PC. It is mounted automatically. As user I can copy file from the enclosure to PC. But as user I can't copy file from PC to the enclosure. I must be root to do it;

$ sudo cp file /media/disk/

Afterwards the own and group of the file changed to root. I can't delete it as user.

This is quite annoying.

satimis
 
Old 05-07-2010, 07:24 AM   #5
satimis
Senior Member
 
Registered: Apr 2003
Posts: 3,688

Original Poster
Rep: Reputation: 55
Quote:
Originally Posted by never say never View Post
In answer to your questions.

1. Technically file ownership doesn't change. It is based on the UID which is a numeric value. Currently you probably have something like this:

Code:
UID     Computer1    Computer2
1000    root         root
1001    user1        user2
1002    user2        user3
1003    user4        user1
So when you plug the device into Computer 1 files are owned by the list of users on Computer1, when you change to Computer2 the ownership appears to change because the same UID is a different user on computer2.

So a file owned by user1 on computer1 will in fact be owned by user2 on computer2. The UID did not change.

1-a. One way to solve your problem is to make sure both systems use the same UID for all Users. eg.
Code:
UID     Computer1    Computer2
1000    root         root
1001    user1        user1
1002    user2        user2
1003    user3        user3
1004    user4        user4
Up front this is a labor intensive solution because users on one computer will have to be modified, and permissions changed . . .

1-b. Another option might be to use a script to move files to removable drive Have the script chmod and chown the files as needed.

1-c. Another option would be to use a file system that does not store ownership such as FAT. If you do that each computer will mount the removable drive as the logged in user, or root (depending on distro and setup).
Hi,

Thanks for your advice.

Users on PC-1 differs from PC-2. What I'm doing here is;
User1 on PC-1 download the files and change the own and group.



Quote:
2. This will probably act just like 1-c above. Why? Because most all USB Flash Drives come formatted with, you guessed it FAT.
So USB mobile drive can't help me out.


Quote:
3. NAS would be one option, you could also set up an NFS Share, or Samba between the systems if they are on the same netowrk.
Are there other options besides? Nowadays NAS is NOT expensive. I'm considering whether I need such a device to serve 2 pcs?


B.R.
satimis
 
Old 05-07-2010, 08:03 AM   #6
samnjugu
Member
 
Registered: Apr 2006
Location: Atlanta
Distribution: Centos, knoppix, Fedora, Mepis, Zenwalk, Mint
Posts: 142

Rep: Reputation: 16
I have had a similar problem but in my setup the enclosure was ntfs formatted, I could not delete contents on it as regular user, what I did was unmount the automatic mount made by the box i.e

Code:
#sudo umount /media/drive
and mount it writable by any user

Code:
sudo mount -o umask=000 /dev/sda1 /mnt/mnt_point
Replace sda1 with whatever your drive is and now you should be able to copy to it and delete from it without root privileges "sudo".
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to detect the external enclosure w/o reboot satimis Linux - Hardware 5 11-27-2007 07:36 PM
External IDE enclosure + RAID ? hollywoodb Linux - Hardware 5 12-10-2006 07:02 PM
operating system on a external enclosure rar4x Linux - General 5 06-19-2006 01:09 PM
external enclosure for hdd jcwalnut Linux - Hardware 2 09-22-2004 02:58 PM
External Speedzter5 Enclosure JimmyJ Linux - Hardware 1 05-06-2004 12:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 01:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration