System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

mounting file system on existing user's home directory without deleting user

j.neelam
Occasional Visitor

mounting file system on existing user's home directory without deleting user

Hi Guru's,
we created user "abc" and mounted on directory "/opt/abc" as per requirement, but latest requirement says /opt/abc" should be a file system not a directory.
Is it possible to mount a file system on the home directory of existing user without deleting the user.

please help me with the steps.
Thanks
9 REPLIES
Dennis Handly
Acclaimed Contributor

Re: mounting file system on existing user's home directory without deleting user

>mounted on directory "/opt/abc"

This should be a location of abc software, not the home directory for user abc.

>Is it possible to mount a file system on the home directory of existing user without deleting the user.

I don't see why not. While you might have problems if the user is logged on, it should work after he isn't using files in the home directory.
j.neelam
Occasional Visitor

Re: mounting file system on existing user's home directory without deleting user

thanks for your response Dennis.
As I mentioned that was a requirement to use /opt/abc as home directory.
I copied all the files under this directory and tried to mount the file system but it says "/opt/abc is busy, or allowable number of mount points exceeded" even user is not logged logged in.
Bill Hassell
Honored Contributor

Re: mounting file system on existing user's home directory without deleting user

> As I mentioned that was a requirement to use /opt/abc as home directory.

A user's HOME directory can be anywhere (and can be changed at any time) so the simplest method is to run vipw and change the HOME diectory to /opt/abc. I am assuming that abc is not an ordinary user but an application maintenance user, much like an oracle user.

> /opt/abc is busy...

So additional cleanup is needed first. Start by cleaning up /opt/abc. If it already contains the necessary files, create a new lvol and filesystem, mount to a temporary mountpoint and copy all the files from /opt/abc. Use find to count directories and files to verify the counts (not size).

Now remove all the files and directories in /opt/abc (which I assume is part of /opt and not a separate mountpoint). umount the temporary mountpoint and mount it to /opt/abc which is now an empty directory, ready to use as a mountpoint. Use bdf to verify that /opt and /opt/abc are separate mountpoints.

Now run vipw to change the user's HOME directory to /opt/abc. Finally, check the old user's HOME directory (/home/abc?) and move any required files to /opt/abc. Besides ordinary files, hidden files like .profile should be moved to the user's new HOME. Now you can remove the old abc HOME directory.


Bill Hassell, sysadmin
j.neelam
Occasional Visitor

Re: mounting file system on existing user's home directory without deleting user

We are going in different directions...

let me clear:
"/opt/abc" is already used as home directory for user "abc" . I need to mount new file system on "/opt/abc" without loosing data under "/opt/abc"
Tingli
Esteemed Contributor

Re: mounting file system on existing user's home directory without deleting user

If you mount a new file system into an existing directory, all the files in the original directory will not be seen unless you have the new file system is unmounted. So, you need to copy all the files from /opt/abc to the new file system first, then mount the new file system to /opt/abc. This way, you can still have the user abc there.
Mancboy
Valued Contributor

Re: mounting file system on existing user's home directory without deleting user

hi,
just move the directory out of the way, and create a new directory of the same name, then mount.
copy what ever you need back to the new mount point.
any files currently open will no be affected, any new attempts to open the files will open the new mount point files

so:
mv abc def
mkdir abc
mount FS abc
rsync -avz def/* abc

or if not too bothered about upsetting the user, instead of rsync, run mv

Re: mounting file system on existing user's home directory without deleting user

Hi,

Why not create a new home directory and mount the filesystem and then copy the files or directories under /opt/abc

-Pramod.
Dennis Handly
Acclaimed Contributor

Re: mounting file system on existing user's home directory without deleting user

>I need to mount new file system on /opt/abc without losing data under /opt/abc.

As mentioned, if you mount a new filesystem, you will hide the data that's there.

>says "/opt/abc is busy,

Have you used lsof or fuser(1m) to see if someone is using that /opt/abc directory tree?

As Mancboy said, using mv would solve both these issues.
Tom Henning
Trusted Contributor

Re: mounting file system on existing user's home directory without deleting user

One additional comment. Before you try to issue the mount command to mount the new filesystem on /opt/abc, make sure that noone currently has their cwd as /opt/abc. i.e. 'cd /' before you try to mount onto /opt/abc.
You can use the fuser command to see if there are any processes running that has /opt/abc as their cwd, or as an alternative you can use the lsof command, which is not supplied by default but is the better tool, to do the check.

Tom
What is it that possesses otherwise sane individuals to change something just because it has not been changed in a while?