Duplicate home directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Duplicate home directory
# 1  
Old 02-19-2014
Duplicate home directory

Hi,

I'm running a RHEL6 machine on a VMWare platform and I have somehow created a duplicate /home directory. See below.

Code:
[root@localhost twood]# pwd
/home/home/twood
[root@localhost twood]# ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
[root@localhost twood]#

I am currently working on some disk quota procedures and I amended the /etc/fstab file so that /home directory is mounted on /dev/sda2:

Code:
# vim /etc/fstab
# /etc/fstab
# Created by anaconda on Mon Mar  5 08:13:08 2012
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=d1b32264-d4f4-43d3-8cae-6df75fc41feb /                       ext4    defaults        1 1
UUID=abda4f23-6594-4276-bdf1-49ddc55f71fb /boot                   ext4    defaults        1 2
UUID=eaaeb2c7-ddb9-4dcf-9416-e09a11197112 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/sr0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
/dev/sdb1               /test                   ext4    defaults        1 2
LABEL=NEWSWAP           swap                    swap    defaults        0 0
/dev/sda2               /home                   ext4    defaults,usrquota 1 2

Code:
[root@localhost twood]# mount | grep home
/dev/sda2 on /home type ext4 (rw,usrquota)

Since I mounted the /home file sytem on /dev/sda2 I seem to have created a duplicate home directory:

Code:
[root@localhost twood]# pwd
/home/home/twood
[root@localhost twood]# ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
[root@localhost twood]#

I am not sure how this has happened but when I try to remove the duplicate home directory I am unable to as I get the following message:

Code:
root@localhost home]# pwd
/home
[root@localhost home]# rmdir home
rmdir: failed to remove `home': Device or resource busy
[root@localhost home]#


I want my home directory to be as ' /home/twood', not '/home/home/twood' as it currently stands. Please can anyone advise me of working round this?
# 2  
Old 02-19-2014
/home/home now contains home directories. If you get rid of /home/home you also lose /home/home/twood. Ditto for any other home directories in /home/home. You need to log off as twood and get any other affected users off the box. Then login as root and do:
Code:
cd /home/home
mv twood /home

Do that for any other affected users as well. Once /home/home is empty you can do:
Code:
cd /
rmdir /home/home

What is listed in /etc/passwd as your home directories? You may need to edit that as well.
# 3  
Old 02-20-2014
Was /home part of the root filesystem and did you move the content of /home to the new filesystem with something like this:-
Code:
mkdir /newhome
mount /dev/sda2 /newhome
mv /home /newhome
umount /newhome
mount /home

I would always do this booted from media so I could ensure that the disks were all idle. You may well find that home directories point to /home/twood etc. but when you log in it tells you that it's not found.

If you have done this, then a better way to have achieved this would be:-
  • Boot from media, no network, start a shell. Then:-
    Code:
    mkdir /mnt/root
    mkdir /mnt/home
    mount /dev/sda1 /mnt/root
    mount /dev/sda2 /mnt/home
    
    cd /mnt/root/home
    tar -cvf - . | (cd /mnt/home ; tar -xvpf -)
    cd
    
    mv /mnt/root/home /mnt/root/oldhome
    mkdir -pm 755 /mnt/root/home
    umount /mnt/root
    umount /mnt/home
    exit

  • Reboot the server.
If this all works then you can dispose of /oldhome when you are happy.

Of course, it depends where you are now. Can you tell us what was actually done?



Robin
Liverpool/Blackburn
UK
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Solaris

SunOS confusing root directory and user home directory

Hello, I've just started using a Solaris machine with SunOS 5.10. After the machine is turned on, I open a Console window and at the prompt, if I execute a pwd command, it tells me I'm at my home directory (someone configured "myuser" as default user after init). ... (2 Replies)
Discussion started by: egyassun
2 Replies

2. Solaris

Restricting SFTP user to a defined directory and home directory

Hi, I've created solaris user which has both FTP and SFTP Access. Using the "ftpaccess" configuration file options "guest-root" and "restricted-uid", i can restrict the user to a specific directory. But I'm unable to restrict the user when the user is logged in using SFTP. The aim is to... (1 Reply)
Discussion started by: sftpuser
1 Replies

3. Programming

Getting Home Directory

Hi I need to get the home directory of current user who is running the program, also i need to store the value in a particular variable and pass to the function. thanks in advance (4 Replies)
Discussion started by: cutechaps
4 Replies

4. Shell Programming and Scripting

home directory

hello i want shell script. as root , i want to untar specific.tar.gz to all home user directory and after untar , there is 1.txt 2.txt ~~ 26.txt in/public_html/test1/ i want randomly selected 6 text files in 1.txt 2.txt ~26.txt to be renamed newword1.word , newword2.word , ~~... (8 Replies)
Discussion started by: topic32428285
8 Replies

5. SuSE

home directory is not mounting

Our home directory is not mounting in SUSE 10, can you please help me in this regard. Thanks (1 Reply)
Discussion started by: durgaprasadr13
1 Replies

6. Filesystems, Disks and Memory

Could not chdir to home directory

I have SunOS 5.8. Yesterday when i tried to log in I got message: Could not chdir to home directory /export/home/blahblah: No such file or directory Instead of the home directory i used to get in, I was bounced to the root directory. I searched through the filesystems but could not find my... (2 Replies)
Discussion started by: liux99
2 Replies

7. UNIX for Dummies Questions & Answers

home directory

Hi what is the difference between the directory named /home and the user's home directory? can anyone plz reply? really confuse about it!!!!!!!! thank you (1 Reply)
Discussion started by: nokia3100
1 Replies

8. UNIX for Dummies Questions & Answers

cd into home directory ~

I'm trying to cd into a home directory with cd ~username_here and I'm getting the following error: ~username_here: does not exist The directory exists and I can directly go to it via cd /export/home/username_here without any problems. Any suggestions? (4 Replies)
Discussion started by: here2learn
4 Replies

9. UNIX for Dummies Questions & Answers

c++ home directory??

when i compile *.cpp files the compiler didn't find the non standart includes.If i have to put the full path of the includet files where shall i begin from root dirctory or i heve to put includet files in cpp home directory??? can i compile java files in unix(linux mandrake 7) if yes haw... (3 Replies)
Discussion started by: user666
3 Replies
Login or Register to Ask a Question