LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Remove Multiple Home Directories (https://www.linuxquestions.org/questions/linux-newbie-8/remove-multiple-home-directories-635566/)

paparob 04-15-2008 02:56 PM

Remove Multiple Home Directories
 
I'm running Ubuntu 7.1 Gutsy. I recently installed a 2nd hard drive and successfully copied my home folder to it, added mount points, edited the fstab and permissions, etc. It all worked. Now I have 3 home directories. Two on my new hard drive and one in my old one. How can I remove my old home directory on the old drive and remove one of the new ones on the new drive?

terra (sdb1) is my new drive. My home directories are under (old drive, sda1) /home, (new drive) mnt/terra/home and mnt/terra/robert, the terra/home has copies of the /terra directory. I'd prefer to keep the /terra/home/robert directory.

My fstab is:

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/sda1
UUID=cb034bda-8749-460e-b732-42513bdd105d / ext3 defaults,errors=remount-ro 0 1
# /dev/sda5
UUID=8e3f14db-3b4c-4af1-8f0a-a4464c6a321d none swap sw 0 0
/dev/sdb1 /mnt/terra ext3 defaults 0 0
/dev/sdb1 /home ext3 defaults,errors=remount-rw 0 1
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec 0 0
/dev/scd1 /media/cdrom1 udf,iso9660 user,noauto,exec 0 0


If all else fails, I can just reformat but I'd prefer not to. Any ideas?

bigrigdriver 04-15-2008 05:21 PM

What you should have done:
a) create the partition /dev/sdb1
b) create a temporary mount point for it: mkdir /mnt/sdb1 (or whatever name you choose).
c) mount /dev/sdb1 /mnt/sdb1.
d) mv (not copy) the contents of /home to /mnt/sdb1. That would put your /home files on the new partition, and remove them from the old /home folder.
e) edit /etc/fstab to make an entry for the new /home partition: /dev/sdb1 /home ext3 (etc).

As a result of copying /home to /dev/sdb1, you now have a duplicate copy (your old /home is now the duplicate) which will be invisible (covered up) by /dev/sdb1 when it is mounted.

Su to root, unmount /dev/sdb1 (to keep your new /home safe and sound), then cd to /home (the old home), and rm -rf /home/* (putting the /home/* in there is for safety sake. rm will only delete files in /home).

That leaves /home empty (to be the mount point for /dev/sdb1) Now you can remount /dev/sdb1 to display your new /home folder.

By the way, from your /etc/fstab:
Quote:

/dev/sdb1 /mnt/terra ext3 defaults 0 0
/dev/sdb1 /home ext3 defaults,errors=remount-rw 0 1
This looks like you are mounting /dev/sdb1 to two different mount points at the same time. 'umount /mnt/terra' will remove one of your duplicate /home directories. Then edit /etc/fstab to remove /dev/sdb1 /mnt/terra.

On reboot, you should have only one /home, on /dev/sdb1.

paparob 04-15-2008 08:30 PM

Thanks bigrigdriver, worked like a charm. I knew it had something to do with the fstab, but didn't know which to remove. The how-to I read about adding a hdd and moving the home folder didn't use mv, it used cp -vax /home, so it didn't delete the home folder on the old drive. Thanks again.

paparob 04-24-2008 02:57 AM

Important note for newbies - /home and /etc/fstab
 
It is important to point out that the new drive must have an existing directory on / to mount to. I had a really tough time figuring that out the past 2 days, as I tried, again, to rename/move/screw around with my new drive mountpoint.
(I literally just logged in as a user 20 minutes ago)

It was named /mnt/terra, which I changed to /mnt/sdb1 to keep it simple. Then I noticed that /home wasn't on my new drive. It appears that I inadvertently deleted my /home folder after moving its contents to the new drive, /dev/sdb1. For the past 2 days I haven't been able to log on as a user, but only as root. So after creating and re-creating a /home directory in /mnt/sdb1, then moving my 70GB worth of /home data to and fro on /sdb1, editing the /etc/fstab many times, and rebooting to only find out that I cannot login as user.

I was trying to figure out why it wasn't mounting my /home directory. Well, my /etc/fstab was mounting my /dev/sdb1 drive, as /mnt/home/user, not as my actual /home. I couldn't login as user, or use any of my setting (desktop, email, etc.) Error on login: "It appears your home directory /home/user does not exist..." or something similar.

I re-read bigrigdriver's post (x10) and the answer was there:

"That leaves /home empty (to be the mount point for /dev/sdb1) Now you can remount /dev/sdb1 to display your new /home folder."

It just took me 2 days (and a bunch of man pages) to figure out that the /home directory must be in /, not in another directory (/mnt/home in my case). Then the /etc/fstab can find it and mount it as /home.

Old fstab line:

/dev/sdb1 /mnt/home ext3

(/home directory in /mnt on /sdb1 drive) -NOT WORKING-

New fstab line :

/dev/sdb1 /home ext3

(/home directory in / on /sda1 drive) -WORKS-


I thought by pointing to /mnt/home in /etc/fstab, it would direct my /home directory to /mnt/home and therefore use all of my data and settings. It doesn't...

Just wanted to share my frustratingly enlightening experience.


All times are GMT -5. The time now is 10:37 PM.