LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 03-22-2012, 02:12 AM   #1
lld
LQ Newbie
 
Registered: Mar 2012
Posts: 8

Rep: Reputation: Disabled
move /home


Hi, I'm sure there is a lot about that title out there as much as in here.

But I don't want to move it to an exclusive partition. I want to move it to an existing partition as a folder/directory.

I tried not to post a new thread, trying to hook onto sth similar, but had no luck with it, so here goes the question. Please forgive me if I am not posting in the right place, it is my first post and I am already looking around for an hour...

--------------------------

So, my /home directory is "as is" by default. Here's my df by the way

Code:
[usr@pc ~]$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs               112474480  70871480  35971000  67% /
udev                   2052100         0   2052100   0% /dev
tmpfs                  2060492      7928   2052564   1% /dev/shm
tmpfs                  2060492       772   2059720   1% /run
/dev/sda2            112474480  70871480  35971000  67% /
tmpfs                  2060492         0   2060492   0% /sys/fs/cgroup
tmpfs                  2060492         0   2060492   0% /media
/dev/sda4            370755860  81214344 270983208  24% /mnt/Datastore
/dev/sda1               508745    214868    268277  45% /boot
/dev/sda2            112474480  70871480  35971000  67% /tmp
/dev/sda2            112474480  70871480  35971000  67% /var/tmp
/dev/sda2            112474480  70871480  35971000  67% /home
Hence, I have my disk sda 500GB ,which was dd from a 120GB
sda1 is boot
sda2 is /
sda3 is swap
and
sda4 is the excess in that hdd from 120 to 500, made as partition (primary, ext4).

my fstab file is

Code:
#
# /etc/fstab
#
#
UUID=0857a373-668c-45af-9aa8-76d838d0da78 /                       ext4    defaults        1 1
UUID=ead41590-d877-4140-9eb1-ffd2f7dab3b9 /boot                   ext4    defaults        1 2
UUID=9c814d9e-42e3-472f-887e-abcf8c526f15 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/sda4               /mnt/Datastore          ext4    defaults
======================================

So i am automounting sda4 in /mnt/Datastore.

Don't want to use sda4 exclusively for /home, i want to store there other data as well, virtual machines, etc. and I don't want to decide now how much space I should allocate by determining beforehand partition size for each thing. This I think is a terrible space management...

So, I would like to have my home contents in
/mnt/Datastore/home

and somehow make my system understand that location as /home.

I have already managed to copy successfully all the /home contents including all files, folders, maintained permissions etc.

(by the way, I went through a lot of articles about that, solutions with find, cpio, compressing/archiving and decompressing to a new location, etc, in order to also copy links, all hidden and file permissions. In my case, I booted with a linux live cd, mounted sda2 and sda4 and then, the following worked for me:
cp -avfR /mnt/sda2/home /mnt/sda4/)


Thereafter, I know as much as entering in "init 1" and mv /home to a useless name.

But that's how far I get...

I cannot seem to find a way to actually tell my system to automount

/mnt/Datastore/home as /home.

I attempted to automount that relationship in /etc/fstab, but that sort-of-looped my boot. As soon as I could see the fedora loading logo, it hangs there...

From my "df" output, I see that it understands /home in /dev/sda2, which is normal and by default, but i can't find where this is set, in order to change it... (and anyway, this in itself is a problem, because /dev/sda2 is a partition, which is actually "/" root, it was not initially configured as /home: Nevertheless, df sees /dev/sda2 both as / and as /home and as anything else it wishes to see that way...

So, in case the question isn't clear, I want to move /home to a directory in an existing partition with other directory trees in it, don't want to mount to a dedicated disk/partition for that purpose.

Is that possible?
Does it make sense? maybe it doesn't make sense by design.
Am I making a dumb mistake?

Any help would be appreciated.

Thanks
 
Old 03-22-2012, 03:27 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,503

Rep: Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434Reputation: 2434
you do not need to mount it at all. try to remove that /home mount completely from fstab and create a symbolic link from /home to /mnt/Datastore/home - or you can replace the user's config so they will have their homes directly in /mnt/Datastore/home
if you want to mount /home you need to share /mnt/Datastore/home first and than configure an nfs mount for that share
 
1 members found this post helpful.
Old 03-22-2012, 03:44 AM   #3
dln
LQ Newbie
 
Registered: Mar 2012
Posts: 6

Rep: Reputation: Disabled
You could also bind mount it in fstab (/mnt/Datastore should be mounted first)
Code:
/mnt/Datastore/home	/home	none	bind
I had some issues when using a symlink.
Some functions returned the true path without symlink which could be annoying.

Last edited by dln; 03-22-2012 at 04:41 AM.
 
1 members found this post helpful.
Old 03-22-2012, 07:52 AM   #4
lld
LQ Newbie
 
Registered: Mar 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
OK,

thank you very much both of you, you were both helpful!

From pan64's reply I realised I don't have to mount, so looking into changing config for user, found out I can do that with usermod

Code:
usermod -d /mnt/Datastore/home/usr usr
(from what i've seen in man, if i hadn't already copied, including -m in the options would also move the home contents for the user)

takes care of setting the user environment to use this folder as home. So far so good, but in df output, /home still worked for the default location.

So then I followed dln's advice.

I automounted it in /etc/fstab the way he/she indicated. After a reboot, it works beautifully.

The mistake I was making, is that I was automounting in /etc/fstab with options "ext4 default" while I had to mount as "none bind" as dln indicated. I was close, but not close enough to do it without help...

So thanks to pan64 for setting my mind free, and dln for correcting my mistake.

Here's an output of df
Code:
[usr@pc ~]$ df
Filesystem           1K-blocks      Used Available Use% Mounted on
rootfs               112474480  70883612  35958868  67% /
udev                   2052100         0   2052100   0% /dev
tmpfs                  2060492      4868   2055624   1% /dev/shm
tmpfs                  2060492       764   2059728   1% /run
/dev/sda2            112474480  70883612  35958868  67% /
tmpfs                  2060492         0   2060492   0% /sys/fs/cgroup
tmpfs                  2060492         0   2060492   0% /media
/dev/sda4            370755860  81225160 270972392  24% /mnt/Datastore
/dev/sda4            370755860  81225160 270972392  24% /home
/dev/sda1               508745    214868    268277  45% /boot
/dev/sda2            112474480  70883612  35958868  67% /tmp
/dev/sda2            112474480  70883612  35958868  67% /var/tmp
/dev/sda4            370755860  81225160 270972392  24% /home
and just for the record, here's an output of /etc/fstab

Code:
#
# /etc/fstab
#
UUID=0857a373-668c-45af-9aa8-76d838d0da78 /                       ext4    defaults        1 1
UUID=ead41590-d877-4140-9eb1-ffd2f7dab3b9 /boot                   ext4    defaults        1 2
UUID=9c814d9e-42e3-472f-887e-abcf8c526f15 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/sda4               /mnt/Datastore          ext4    defaults
/mnt/Datastore/home     /home                   none    bind
I think this can be considered solved.

Thanks a lot guys!
 
  


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
[SOLVED] Can't move /home in 11.10. n5kzw Ubuntu 5 11-02-2011 10:53 AM
How to move /home to new partition frazelle09 Ubuntu 12 05-02-2007 10:22 PM
Can I move /home ? MikeyDIUP Linux - Newbie 3 09-11-2005 02:36 AM
I want to move home fannymites Linux - General 1 12-04-2004 06:45 AM
How do i move /home to a new partition? glenn69 Linux - General 8 06-25-2004 12:38 PM


All times are GMT -5. The time now is 12:19 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