The macosxhints Forums

The macosxhints Forums (http://hintsforums.macworld.com/index.php)
-   UNIX - General (http://hintsforums.macworld.com/forumdisplay.php?f=16)
-   -   Moving "Users"+"Home" directories to another HD (http://hintsforums.macworld.com/showthread.php?t=10340)

badger 03-19-2003 11:26 AM

Moving "Users"+"Home" directories to another HD
 
hi,

Now I've read the other threads on this and I'm confused as to the best way to do this.

I want to move my entire user folder to another drive in such a way that:

1)new users created here will come with all the template folders
2)I should be able to do this using "Accounts"

Now logging in as "Root" and simply changing the path for the home directory for each user doesn't seem to work. Even when I have copied the entire USERS folder across to the new HD. In doing so I change the path using NetInfo Manager to /Volumes/<drivename>/Users/<username>

I've got it to recognise the new location of HOME but, the privlidges are screwed and I've lost desktop prefs and all sorts. Infact Explorer won't even start...

So I have a brand new drive, a fantastic OS, and I can't make good use of them until I get this automated.

By the way, I know nothing about UNIX, but I'm learning.

Thaks very much if you can help....

Badger

jkp23 03-19-2003 11:43 AM

how did you copy the users directory?

you will need to use ditto (a command line util) in oder to maintain the permisions on the directories correctly. the other way is to use a copy of CCC (carbon copy cloner) which is a great util for these kinds of things if you dont want to get into the comman line stuff too much. effectively though it is just a front end for ditto in this case.

regarding how to proceed from then onward, it should be fairly straight forward.

1: write an /etc/fstab file. the instructions for this are elsewhere and i cant remember the exact syntax now, but if you go to the main osxhints site and search on user partition, or move swap partition or something a hint will show that has the syntax. this file simply tells the automount deamon (the program that mounts your drives) where to mount your new users drive. you will want it to mount at /users. in the tutorial, it tells you you must edit the netinfo database, but in my experience this is not needed. i simply wrote an fstab and it all worked fine.

2: boot into single user mode (hold apple-s on startup). this takes you to a shell prompt as the super user. if you are using 10.2 or later you will need to enter the commands that it lists in order to make any changes. as i said these commands are listed at the logon prompt when it loads. in single user mode what you need to do is delete the contents of the original user directory in order that you can mount the contents of your new disk in their place.

3: once you have done this, just reboot and it should happily mount your new user drive into the /users directory and everything should work like normal. the only other thing you might want to do is to hide the users drive from the desktop. you need to use setfile from the developers cd to do this.

all these instructions are in that hint on the main site, and i have only badly relayed them to you here. you are best off reading it from there - i would post a link bu i dont have the time to find it right now. i hope this gives you some more idea what to do tho.

gatorparrots 03-19-2003 12:32 PM

http://www.macosxhints.com/article.p...10325102750788

I would not do it this way:
http://www.macosxhints.com/article.p...10619195610633

(Read all the comments on both threads before proceeding.)

jkp23 03-20-2003 04:58 AM

gatorparrots: more clues on why not if poss?
 
well - i have read those threads but i still cant see any reason not to use automount and fstab. this is the standard unix way, and apple have now implemented it, as of 10.2.x. These toher links were written before that i think. I'd be interested to know why you specifically dont recommend this method. i have been using it fine for months now.

I have to say though, with only one system disk, I have not checked out whether apple have fixed the problems lastobelus pointed out at the end of the second article regarding drive labels. I think this is irrelveant the way i did ti, since i did not refer to the disks as /dev/disk0s10 etc, but rather to the partition names with the LABEL tag.

vonleigh 03-20-2003 05:07 AM

Hello,

Search the forums for info on using the fstab file. Me and one other user are running a setup like this and, at least for me, it has worked flawlessly:

% cat /etc/fstab
LABEL=Users /Users hfs rw 1 2
LABEL=Applications /Applications hfs rw 1 2
LABEL=Mail /var/mail hfs rw 1 2

According to the last thread on the subject that is all you must do, no loading into netinfo or anything necessary. The LABEL= indicates the name of the partition btw.



v

badger 03-20-2003 05:13 AM

Sorry chaps... I'm completely lost on this fstab business.

I have logged in as root and then used

cp -Rp /Users/username /Volumes/drivename/Users

This made a recursive copy for one user fine, but for another it runs through the files saying operation not permitted. Why is this?

And do I need to use fstab still in order to create new users in the new location?

Thanks for your help, I know little about Unix, but I'm learning...

Badger

badger 03-20-2003 05:14 AM

Sorry chaps... I'm completely lost on this fstab business.

I have logged in as root and then used

cp -Rp /Users/username /Volumes/drivename/Users

This made a recursive copy for one user fine, but for another it runs through the files saying operation not permitted. Why is this?

And do I need to use fstab still in order to create new users in the new location?

Thanks for your help, I know little about Unix, but I'm learning...

Badger

jkp23 03-20-2003 05:15 AM

Quote:

Originally posted by vonleigh Me and one other user are running a setup like this and, at least for me, it has worked flawlessly
Is that me von? if i remember i was telling you thatno netinfo tweaking was needed. does that mean its just the two of us?

jkp23 03-20-2003 05:16 AM

Quote:

Originally posted by badger
...I have logged in as root and then used

cp -Rp /Users/username /Volumes/drivename/Users

This made a recursive copy for one user fine, but for another it runs through the files saying operation not permitted. Why is this?
This doesnt prevserve the permissions i dont think - i think you need to use ditto to copy the directory. It's safer.

Titanium Man 03-20-2003 10:15 PM

cp will strip resource forks. 'ditto -rsrcFork' won't. ditto has a manpage if you're interested.

macmath 02-18-2004 12:39 PM

Quote:

Originally posted by vonleigh
Hello,

Search the forums for info on using the fstab file. Me and one other user are running a setup like this and, at least for me, it has worked flawlessly:

% cat /etc/fstab
LABEL=Users /Users hfs rw 1 2
LABEL=Applications /Applications hfs rw 1 2
LABEL=Mail /var/mail hfs rw 1 2

According to the last thread on the subject that is all you must do, no loading into netinfo or anything necessary. The LABEL= indicates the name of the partition btw.



v
Hi, vonleigh.

Thanks for the above. It is working fine.

I have a question, however. What do the 1 and 2 at the end of the line do?

vonleigh 02-18-2004 01:48 PM

This is odd, I don't seem to have a manual entry for fstab, anyway, you can find a man here:

<http://www.hmug.org/man/5/fstab.html>

Basically:

sixth field, (fs_passno), is used by the fsck(8) program to determine the order in which filesystem checks are done at reboot time. The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware. If the sixth field is not present or zero, a value of zero is returned and fsck will assume that the filesystem does not need to be checked.

---
I do find it odd that that page says it's deprecated and that man fstab doesn't return anything. If you do a man autodiskmount it lists fstab in the See Also section. Anyone have any info on this?


v

macmath 02-18-2004 02:32 PM

I did get a result from

man fstab

(even before I posted the above question) but what it said was not clear to me. I guess the two means it is the second checked at boot time, but what does the 1 mean?

Thanks.

acme.mail.order 02-18-2004 06:39 PM

The simplist way to move a user folder is to copy it (in the Finder) to the new location and symlink (in the Terminal) the old home to the new one. You do this for each user. If you add new ones all the time I'd go the fstab route, but if new users are few and far between the symlink method takes about a minute and is stable.

And it does appear that you broke the users folder with the `cp` command. You can't fix it, login to the Finder as root and copy again.

vonleigh 02-18-2004 09:03 PM

Read the thread, that's a terrible solution, you break all permissions and not all files get copied.

Logging in as root is equally bad, one should never do that, there's always a way of fixing it without resorting to root.

v

acme.mail.order 02-18-2004 10:53 PM

I read the thread, and I'm suggesting that unless Badger is adding users weekly my method is a lot less stressful than tinkering with fstab. I'ts also easier to fix after an update breaks the redirection. I also said if he is adding 3 users a week it would be worth changing the mount points, but I prefer simplicity.

And what's the phobia about logging into the Finder as root? No different than what we had in OS9, and Classic users don't routinely destroy their systems, do they? Badger said he was a unix beginner, so copy stuff in the Finder and then switch the user in Get Info. You can't copy yourself in the Finder as files are in use, and you can't copy other user's folders unless you're the root user. So if I've got 6 users to move, I do it as Root. BTW done this lots here, nothing's exploded into flame yet.

vonleigh 02-19-2004 12:00 AM

The problem with your method is that you clobber all permissions and ownership. Even though you can reset the ownership of the folder, the permissions would still be whacked. In most cases this won't be a problem (say if you don't use your public folder), but it can bring you trouble in the future. Repair permissions doesn't touch anything within your user folder.

The trouble with loggin in as root is that anything you touch, and anything you create will be owned by root. If for example someone advises you to install a program under root, that program and all it's support files will be owned by root, which again can bring trouble later on; plus when it comes time to upgrade you _have_ to login as root.

There are also security implications that we didn't have back in OS 9: a virtually un-hackable OS. If you are a unix newby you have _more_ reason (not less) to not login as root, since you don't know what trouble or security holes you could create.


>but I prefer simplicity.

The fstab method has a beautiful simplicity in itself, by isolating every part of the OS, and linking them only under the current running OS, it allows you some freedom.

For example. When it comes time for a system reinstall (or update), you can tell the OS to erase the partition; since you're booting off the OS cd, the fstab isn't read and your partitions are separate again. So it would only delete the OS part and leave your Users and Applications alone.

After the install, you can have the best of both worlds: a perfectly clean brand new OS, and after you relink everything, all your files, apps, etc.

If you search around you'll see how much trouble is caused by upgrading instead of using archive and install or a clean install. I guess this is more of a manual archive and install.

I personally don't think it's too difficult, since the fstab is just one file, you make it, reboot and you're good to go. Plus I haven't had any apps "stomp" on the fstab (I have heard of some apps/installers stomping on symlinks).


>BTW done this lots here, nothing's exploded into flame yet.

Never an indicator that one should continue the practice. I know a few people that hot unplugged ADB dongles with no trouble, yet i know somone that fried his board (a nice what was it genesis? those old monster multiprocessor clones).


v

acme.mail.order 02-19-2004 01:16 AM

Quote:

If you are a unix newby you have _more_ reason (not less) to not login as root, since you don't know what trouble or security holes you could create.
Yes, protecting users from themselves yadayadayada. You can break things much faster form the command line.

When I said simplicity, I'm thinking not only for myself or the other system admins, but of others trying to work it out on their own later. A simple redirection like a symlink is much easier to comprehend for the uninitiated than rearranging mount points in a well-buried and somewhat cryptic system file.

Everyone's needs and abilities are different - what works for me and what works for you are obviously at different ends of the table. There are several ways to do what the original post asked, and Badger will eventually do what works for him. Rigid advice like "Never login as Root" is no more helpful than "always put an @ before your functions to prevent error messages" and "Never mount a horse from the right side"

We could argue this point until Craig and Phil run out of disk space without a clear solution, because there isn't one. If there was no need for a root user then why is the facility there ?!? Don't use it every day, but it's there when needed.

I'm going back to my remote root login shell now.

vonleigh 02-19-2004 02:10 AM

Quote:

Yes, protecting users from themselves yadayadayada. You can break things much faster form the command line.
Actually, I was thinking more along the lines of protecting yourself from crackers; that's why I mentioned security holes. But yes, you can also really hose your system. This OS is not nearly as simple as OS 9.

Quote:

When I said simplicity, I'm thinking not only for myself or the other system admins, but of others trying to work it out on their own later.
As I understand it this is a home system and he is the soul administrator.

If it's a corporate environment, every admin should keep of log of things they do. That way it's easier for everyone to be on the same page or even trace back the dumb things one does at 2am because of lack of sleep. Plus if you have to set another server up, you have a cheat sheet.

Quote:

Everyone's needs and abilities are different - what works for me and what works for you are obviously at different ends of the table.
That's very true. Although your solution works, I was pointing out the problems I see to that approach. However, there's another knowledgeable poster on the forum (willy i think) that likes using symlinks. I don't recommend them because some older apps or installers will create a folder over them.

However, you'd need to copy your folder not in the finder as root but using sudo ditto -rsrc. That way your permissions are kept intact, you maintain your resource forks and you make sure it all gets moved.

Quote:

Rigid advice like "Never login as Root" is no more helpful than "always put an @ before your functions to prevent error messages" and "Never mount a horse from the right side"
Not sure about the horse part. However I stand by my advice that one should never log in as root, there is no need (my root account has never been enabled) and it's potentially dangerous.

On the @ before error messages. If you're talking of php it just supresses the message. However, nowadays by default php writes all errors to the log and displays a blank page, for security reasons. So it was such good advice that they actually threw it into the defaults.

I do believe in rigid advice: Don't use register globals, always check input from the user, use sh if you want your scripts to be portable, make sure your int's are unsigned and you have space before copying strings:

<http://www.securitytracker.com/alert...b/1009067.html>

You are entitled to your own opinion. Many here on the forum will agree with me that one shouldn't log in as root. Most unix old hands (with long beards) would too. This is not only applicable to OS X, lindows is heavily criticized because of the same reason.

As they say in school, break all the rules, but first know what the rules are and why they are there in the first place.

Quote:

If there was no need for a root user then why is the facility there ?!?
Actually by default it's shipped turned off. You have to go into netinfo or the terminal to enable it. The necessity of a root account does not condition the necessity for one to log in as the root account.


v

acme.mail.order 02-19-2004 04:22 AM

Feel better with that off your chest?

The horse part: If you go to a riding school they will repeatedly tell you that you must always get on the horse from the left. The horse doesn't particularly care one way or the other and would probably be happier if you didn't get on it at all. The advice comes from the days when we wore swords a lot. As most people are right handed the sword was hung on the left side. If you get on a horse from the right with a sword in the appropriate position it will be quickly and painfully apparent why the left side is better.

vonleigh 02-19-2004 05:24 AM

No need to get snippy, it's a discussion forum. We agree to disagree.

Thanks for the last bit of info, good to learn something new.


v

hayne 02-19-2004 10:27 AM

Re: the horse part:
You missed out on the last part of the reason why riders always mount a horse from the left side:
Quote:

a horse who's been taught to accept being mounted only from one side may be perfectly docile when the rider clambers aboard on that side, yet spook and refuse to stand still if approached from the unfamiliar direction.
(from http://www.straightdope.com/mailbag/mhorsemounting.html )

And it is a bad idea to login as root since you are not usually accustomed to having the system do whatever you say (no matter how stupid it is). Even in OS 9, the system prevented you from removing essentials like the System Folder.
One of the most valuable things about 'sudo' is that all your actions are logged - so you can go back and figure out later what you might have done wrong.


All times are GMT -5. The time now is 06:08 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.