Results 1 to 7 of 7

Thread: permanent home

  1. #1
    Newbie
    Join Date
    Nov 2004
    Location
    Colorado
    Posts
    5

    permanent home

    I've read a couple of places that it's a good idea to have a "permanent home" partition. That way, you can fiddle around with distributions (on your other partitions) without overwriting all your data.

    So I have a separate partition, hda6. I tried to change the /etc/fstab file to make it mount at /home2. That did not work -- I got a message that it did not exist.

    What's my problem? Do I have to:

    a) change the original /home to /home2, then change the hda6 to /home?
    b) change something about the partition table, rather than /etc/fstab (I looked at cfdisk, and don't see mount points).
    c) none of the above?

    Thanking all in advance,

    wazoo

  2. #2
    Advisor
    Join Date
    Apr 2004
    Location
    orlando
    Posts
    608
    1) post the error messages, not a description of them

    2) did you 'mkdir /home2' ?

  3. #3
    Newbie
    Join Date
    Nov 2004
    Location
    Texas, USA
    Posts
    8

    Re: permanent home

    First, it's best to do this while you're not using a GUI (as your KDE/GNOME/xfce/fluxbox/Window Maker/Enlightenment/etc. user-specific settings will be called from your ~/ directory, which unless you're configured to log in to the GUI as root [where the files will be called from /root], will be called from the /home/<user> directory and may cause your X session to crater since it will effectively be "out of service" for a few moments).

    The easiest way to do this, depending on your distro, is to either boot to runlevel 1 (single user), or perhaps runlevel 3 or whatever runlevel you've got configured that won't start X and will leave you at the command line login if you're normally not allowed to log into your GUI as root.

    You could also just Ctrl-Alt-F1 to get to a command login, then Ctrl-Alt-F7 to get back when you're done, but depending on what you have going in your X session, you may have to Ctrl-Alt-Backspace to kill the session, or kill it from the command line before going back into it if you find it unstable (stuff that was looking for its files in ~/, but got waylayed between the time the original /home was renamed and the new /home was mounted).

    Second, log in as root (so be sure to use extra caution, as always, when working as root), and mount the formatted partition:

    # mount -t ext2 /dev/hda6 /mnt/hda6

    This of course assumes that you:

    1. Had formatted the partition as ext2 (if not, change it to ext3 or whatever type it was formatted as). See `man mke2fs` for more info.
    2. Had already created a temporary mount-point for it (if /mnt exists, `mkdir /mnt/hda6` will do it).

    With the partition mounted, you can proceed to duplicate your current /home directory's contents to the new partition with:

    # cp -Rip /home/* /mnt/hda6

    This will copy the directories in /home to the new partition, recursing subdirectories [R], alerting you of any file overwrites as it's being done interactively [i], and preserving ownership and permissions of the directories and files [p]. The "i" is not necessary, as the partition (/dev/hda6) is probably empty to begin with (so there shouldn't be any files being overwritten), but it's habit.

    When the copying is finished, you will see that /mnt/hda6 now contains directories for all your system's regular users (/mnt/hda6/wazoo, /mnt/hda6/jester, and /mnt/hda6/testme for example). What you *don't* want to see is "/mnt/hda6/home/wazoo", as when the partition is mounted as /home in your /etc/fstab, you would effectively have /home/home/wazoo, which is not what you're after.

    With that done, your original /home directory still exists. I'm also speculating that it is a part of your / directory, which is on another partition. Since you're logged in as root and no users are accessing the original /home/* directories, you can safely rename this directory to something else (don't delete it yet, as that can be done well after you're sure that you've got everything right and whenever it's convenient):

    # mv /home /home2

    And make an empty directory in / for the new /home mount point:

    # mkdir /home

    Now, edit your /etc/fstab to mount the new partition, using /dev/hda6 as the partition, and /home as the mount point. The entry may look something like this (again, this example is using ext2 as the type... change any settings particular to your system's configuration):

    /dev/hda6 /home ext2 defaults 1 2

    Reference `man fstab` for more information on the settings used in /etc/fstab.

    With this done, you should now have:

    1. An empty /home directory in your / directory.
    2. A partition (/dev/hda6) that contains all the user directories and files that will be mounted at /home.
    3. A modified /etc/fstab that will then mount that partition at /home.

    If you were able to do all this without having to change runlevels, you can then `mount -a` to have the /etc/fstab file re-parsed and have all the noauto mount-points reloaded, which will then mount /dev/hda6 as your new home. Log out and log in as a regular user and you should have everything operating as normal with your ~/ on the new partition.

    If you did change runlevels, a simple `init 5` or `telinit 5` (again, assuming that runlevel 5 is for your distro's GUI runlevel, and is the default runlevel that you normally boot to) will get you there.

    Once you've thoroughly tested to make sure that your changes are correct and everything's working as it should (give yourself plenty of time for this... there's no hurry unless you're running out of drive space on the / partition), you can delete the /home2 directory that contains the old /home directories to free up that space, and delete the temporary hda6 mount-point created in /mnt.

    Of course, it should go without saying that I fully expect anyone to have a backup before attempting this, that there might be particulars with the distro one's using that would require slight changes in the approach given, and that the user takes full responsibility for their actions and assumes all risk (as I won't). There are alternative ways of accomplishing this as well, but the approach given seems to work fine for most cases where the system in not in a production setting (where you have users logged in on a constant state).

    Hope this helps!

  4. #4
    Newbie
    Join Date
    Nov 2004
    Location
    Colorado
    Posts
    5

    Re: permanent home

    A marvelously detailed and helpful response. I'll plunge in and give it a try. Many thanks!

  5. #5
    Advisor
    Join Date
    Apr 2004
    Location
    orlando
    Posts
    608
    better option to not use X

    just 'su' instead of logging in as root... _or_

    best option: set up sudo

  6. #6
    Senior Member
    Join Date
    Apr 2004
    Location
    Indiana?... We named the dog Indiana!
    Posts
    488
    Quote Originally Posted by maccorin";p="3869
    better option to not use X...
    But knowing how to do it correctly leaves the options open :mrgreen: .
    Steve

  7. #7
    Newbie
    Join Date
    Nov 2004
    Location
    Colorado
    Posts
    5

    Re: permanent home

    wazoo here. I followed the instructions (except for changing the run level), and it worked like a charm -- taking me from 87% use of my hard drive to 47%, with just 2% of hda6. (Whew! Some breathing room!)

    I'm using PCLinuxOS7. I logged in as root (using the GUI), then opened a terminal. I encountered no problems, I'm assuming because in this distro, root's home is /root.

    My compliments again to dscribner: a wonderfully clear and helpful answer, and I'm much indebted.

Similar Threads

  1. LVM and /home
    By elusive in forum Redhat / Fedora
    Replies: 0
    Last Post: 02-13-2007, 11:07 PM
  2. Possible to Rename a Permanent folder?
    By travisap4 in forum Windows - General Topics
    Replies: 0
    Last Post: 05-19-2006, 03:00 AM
  3. Tutorial: phpBB 2 forum on a home server for home users on Ubuntu
    By AljoshaNL in forum Linux - Software, Applications & Programming
    Replies: 5
    Last Post: 03-15-2006, 10:58 PM
  4. /home or /home/username in fstab?
    By Dswissmiss in forum Linux - Software, Applications & Programming
    Replies: 3
    Last Post: 10-17-2004, 06:42 AM
  5. permanent routing entry
    By popcorn in forum Linux - Hardware, Networking & Security
    Replies: 2
    Last Post: 06-20-2002, 09:40 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •