LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-15-2008, 03:56 PM   #1
paparob
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Rep: Reputation: 0
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?
 
Old 04-15-2008, 06:21 PM   #2
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Jessie 8.4
Posts: 5,873

Rep: Reputation: 348Reputation: 348Reputation: 348Reputation: 348
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.

Last edited by bigrigdriver; 04-15-2008 at 06:22 PM.
 
Old 04-15-2008, 09:30 PM   #3
paparob
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
Old 04-24-2008, 03:57 AM   #4
paparob
LQ Newbie
 
Registered: Apr 2008
Posts: 4

Original Poster
Rep: Reputation: 0
Lightbulb 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.
 
  


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
PhotoRec completely filled home - can not remove the recup_dir.# directories Herbivore Linux - Newbie 3 06-03-2013 01:47 PM
Using a partition for multiple distro home directories koady Linux - Hardware 3 08-18-2007 02:24 AM
Change text in multiple files in multiple directories vivo2341 Linux - General 5 11-27-2006 09:16 PM
Apache Root/Home Directory and setting up FTP for home directories? Mankind75 Linux - Newbie 6 07-23-2006 03:37 PM
Searching multiple directories and sub directories for a file jeep99899 Linux - Newbie 2 10-13-2005 01:23 PM


All times are GMT -5. The time now is 10:50 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration