LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   /home/ghar goes missing after it is mounted on a new partition. (http://www.linuxquestions.org/questions/linux-newbie-8/home-ghar-goes-missing-after-it-is-mounted-on-a-new-partition-622265/)

Mr. ameya sathe 02-19-2008 10:40 AM

/home/ghar goes missing after it is mounted on a new partition.
 
My Distribution is RHEL5.

Initially, my root i.e. / was on the partion /dev/hdb1.
The user ghar had its home directory /home/ghar in /dev/hdb1.
I was able to perform read/write/execute actions under /home/ghar, when logged in as the user 'ghar' .

Due to space constraints; decided to create a new partion & mount /home under it.

Created an ext3 filesystem on /dev/hdb3.

Executed the command

Code:

e2label /dev/hdb3  /home
added a new line in /etc/fstab

Code:

LABEL=/home            /home                  ext3    defaults        1 2
After rebooting; the home directory of the user ghar has been lost.

Where did I go wrong?:scratch:

alan_ri 02-19-2008 11:10 AM

I think that you have created new /home directory wich deleted the old one.

bigrigdriver 02-19-2008 12:30 PM

No, it wasn't deleted. It's still where it was originally. To prove my claim, unmount /dev/hdb3, then look at /home in your file browser.

This is where you went wrong.
You created the mount point - that's good.
You made the entry in /etc/fstab - that's good.
You never moved the /home directory from /dev/hdb1 to /dev/hdb3 - that's bad. /home is still in /dev/hdb1.

To fix this, edit /etc/fstab and comment out (not delete) the entry your made for /home on /dev/hdb3.
Reboot so that /home is where is should be, under / in /dev/hdb1.

Now make a mount point for /dev/hdb3: mkdir /mnt/hdb3
Mount it: mount /dev/hdb3 /mnt/hdb3.
Now 'cp -R /home /mnt/hdb3' to copy /home to /dev/hdb3. Then rename /home to something else. In case you make an error, you only need to rename it back to /home. If you 'mv /home /mnt/hdb3' and something goes wrong, you have lost /home unless you have a backup to restore. If all goes well, you still have to option of deleteing the renamed /home directory.

Now that you have copied /home to /dev/hdb3, go bacd to /etc/fstab and uncomment the line for /home on mount point /dev/hdb3.

Reboot. /home should now be on /dev/hdb3, and you should have more room on /dev/hdb1 for other files.

You may now delete the /mne/hdb3 folder. That was a temporary tool to make this work. You may also delete the renamed /home directory to make room on /dev/hdb1.

alan_ri 02-19-2008 01:57 PM

No,I think that now he only have /home in /dev/hdb3.

bigrigdriver 02-19-2008 02:08 PM

Read his post carefully.
Quote:

Initially, my root i.e. / was on the partion /dev/hdb1.
The user ghar had its home directory /home/ghar in /dev/hdb1.
I was able to perform read/write/execute actions under /home/ghar, when logged in as the user 'ghar' .

Due to space constraints; decided to create a new partion & mount /home under it.

Created an ext3 filesystem on /dev/hdb3.

Executed the command

Code:
e2label /dev/hdb3 /home
added a new line in /etc/fstab

Code:
LABEL=/home /home ext3 defaults 1 2
After rebooting; the home directory of the user ghar has been lost.
He has created partition /dev/hdb3.
He has added a mount point in /etc/fstab for /home.
He has not moved the files from /home on /dev/hdb1.

When he boots up, /home on /dev/hdb3 (an empty directory) is an overlay on the /home directory on /dev/hdb1. Therefore he can't see the files on /dev/hdb1.

As soon as he unmount /dev/hdb3, the overlay is removed, and the files in /home on /dev/hdb1 become visible.

I should add that I am certain this is so, because I did it to myself 2 or 3 years ago.

alan_ri 02-19-2008 02:31 PM

If I understand you good,then every time he will boot his system he will first have to unmount his /home directory which really isn't his /home dir,so what's the purpose of /dev/hdb3 then?If I look at this with logic,then I must ask you could there be 2 /home dirs,with no matter if they were on two different partitions?
If new /home dir is just created then how it can be overlay of another /home directory.I still think what I said is true and can't wait to see what thread starter will post back. ;)
And I forgot,where is ghar?

bigrigdriver 02-19-2008 02:43 PM

No, you don't understand me. He missed a vital step required to make the move of /home from /dev/hdb1 to /dev/hdb3.

All he has to do is go back to my first response to his post and follow the instructions after "To fix this".

He will then be able to do the one step he missed in his attempt to move /home to /dev/hdb3.

He will also have /etc/fstab in order so that /home is mounted on /dev/hdb3.

His files will be copied from /dev/hdb1 to /dev/hdb3 so that they are in the correct place.

He will have the original /home still on /dev/hdb1, but renamed so that he can easily from any error that might occur by simply naming it back to /home.

alan_ri 02-19-2008 02:54 PM

But there isn't a /home directory of user ghar:

Quote:

Originally Posted by Mr. ameya sathe (Post 3062603)

After rebooting; the home directory of the user ghar has been lost.


bigrigdriver 02-19-2008 03:08 PM

No, It hassn't been lost. He created a new partition called /home on another partition. That partition is empty. The /home directory on /dev/hdb1 is still in place.

When he rebooted, the / (root) filesystem (with /home directory) is mounted, then /dev/hdb3 partition is mounted at /home, which puts an empty directory over the top of the full directory. Think of it as a man putting on a hat. If he has no hat, you can see his bald spot. When he puts on the hat, you can't see the bald spot. It's covered up.

In the same manner, his /home on /dev/hdb1 is still there, but he put a hat on over it; a hat called /dev/hdb3. The hat is empty and he can't see the files under it in /dev/hdb1.

All he has to do is unmount /dev/hdb3, and the files in /home on /dev/hdb1 will suddenly appear, as if by magic.

alan_ri 02-19-2008 03:30 PM

I understand you,I never tried it before,so I was just thinking about how this and how that.I guess we just have to wait and see what will thread starter post here and I'm not saying that you can't be wright about this.But I wish that Mr.ameya sathe has been more specific.

bigrigdriver 02-19-2008 03:47 PM

My only hope is that the omission of copying /home to /dev/hdb3 was an omission in his stragegy, and not an omission is his post. If he did indeed move the files over (that step not mentioned in his post), then he may well have lost the files. But, on reading it again, I don't see how.

Mr. ameya sathe 02-20-2008 07:45 AM

Solution successful with few more solutions & questions
 
1. I looked into the /home directory present in /dev/hdb3 partition. It contained only single empty sub directory called lost+found.

2.I did Carry out the steps mentioned by bigrigdriver albeit with few changes.
I did login as root to carry out the following steps.
Code:

mkdir /mnt/bckghar
cp -a /home/ghar /mnt/bckghar

Uncommented the /home entry in the /etc/fstab file & rebooted.

Code:

cp -a /mnt/bckghar/ghar /home/
rm -r /mnt/bckghar

Please note the option -a
3. On another tty1; I did login as the user ghar.
I was deposited into my home directory, along with all files present. Thank you for help :) . Thus; some disk space under root partition reduced somewhat. :cool:

4. I understood the reply containing 'hat' & 'bald man' concept:newbie:. But, what will be its technical answer?:study:

P.S. I ran du command on the directory /.

Found out that; /usr is occupying 93% of the space.
So, want to shift this /usr to a new partition. Is it possible? :scratch:

Mr. ameya sathe 02-28-2008 07:44 AM

If I copy the whole directory i.e. to a new partition /usr
& then, mount it during boot time.
then, is this a safe step?

alan_ri 02-28-2008 07:54 AM

I don't see why it should not be.


All times are GMT -5. The time now is 12:34 PM.