Find the answer to your Linux question:
Results 1 to 5 of 5
Hi everybody I've been messing around with Debain for a while now, mainly using it as a backup/experiment system. When i installed, I put it all on one partition but ...
  1. #1
    Linux Newbie the bassinvader's Avatar
    Join Date
    Jun 2006
    Location
    Europe
    Posts
    168

    moving /home to new partition

    Hi everybody

    I've been messing around with Debain for a while now, mainly using it as a backup/experiment system. When i installed, I put it all on one partition but now I'm trying to move my /home directory and all its files and settings onto a new partition. I've had some partial success using the usermod command and moving some files with the mv command but it's not really 100%. When i log into the my account, for example i dont see my desktop backgrounds or have my firefox settings or kppp settings ready.

    Is there a way to essentially move my whole /home/user directory to a new partition without lots of messy commands in a long process? If so how?
    " I didn't know it was a picture of his wife! I thought it was a publicity shot form Planet Of the Apes."

  2. #2
    Trusted Penguin Roxoff's Avatar
    Join Date
    Aug 2005
    Location
    Nottingham, England
    Posts
    3,392
    What you do is log in using single-user mode (if you're on a lan this is quite important; if it's just you at home, you probably wont break anything if you dont bother - just make sure no users other than root are logged in while you do this), then mount your new /home on a temporary location such as /mnt.

    Next do (as root):

    cp -a /home /mnt

    Edit your /etc/fstab to set your new /home using the new partition, reboot and test.

    When you're satisfied that all is working, you can flip back to single user mode, unmount /home and delete the contents of the old /home (freeing the disk space) before remounting your new /home and flipping back to your normal multi-user runlevel.
    Linux user #126863 - see http://linuxcounter.net/

  3. #3
    Just Joined!
    Join Date
    Apr 2005
    Location
    Clinton Township, MI
    Posts
    84

    I have copied large directories, even partitions, using tar

    Quote Originally Posted by the bassinvader View Post
    Hi everybody

    I've been messing around with Debain for a while now, mainly using it as a backup/experiment system. When i installed, I put it all on one partition but now I'm trying to move my /home directory and all its files and settings onto a new partition. I've had some partial success using the usermod command and moving some files with the mv command but it's not really 100%. When i log into the my account, for example i dont see my desktop backgrounds or have my firefox settings or kppp settings ready.

    Is there a way to essentially move my whole /home/user directory to a new partition without lots of messy commands in a long process? If so how?
    The tar command, originally used for "Tape ARchives", is really much more than that since it uses the classic UNIX I/O conventions.

    With tar, you can create an archive and instead of storing it on a directory where you are located, you can use command grouping and pipe the output of one tar command to the input of another tar command in a different directory.

    Here is a direct quote from tar on how to copy directories. I have used this very technique on both UNIX and Linux systems, using both the original UNIX form of the tar command and the GNU equivalent, and the behavior is similar:

    Duplicate Directory

    It is possible to duplicate an entire directory tree onto a disk using the tar command. The shell pipe mechanism is used with standard input and standard output. To copy the current directory to a directory named todir you should use the following set of commands:
    Code:
    cd fromdir
    tar cf - . | (cd todir; tar xfp -)
    Note that this command should be punctuated exactly as it is here. Also, the directory todir must exist before you perform this command.

  4. #4
    Just Joined!
    Join Date
    Apr 2005
    Location
    Clinton Township, MI
    Posts
    84

    Here is a further explanation

    Note the file and directory names can be anything, for example, suppose you want to move /home to a different partition.


    Here is an example:

    login to a terminal console, such as an xterm, eterm, konsole, gnome-terminal, etc.

    Become the root user, either using the command
    Code:
    su
    or using
    Code:
    sudo
    , depending on the distribution you are using.

    If you use su, type in
    Code:
    su
    and then press Enter. You are prompted for the root password. Type in the password and then press Enter. If you provided the correct information, you should get a somewhat different prompt. Most systems use
    Code:
    #
    as a prompt for the root (privileged user) account.

    From root, you can run the following commands direcftly. Otherwise, prepend each command with the
    Code:
    sudo
    command (Ubuntu, for example, requires this syntax, no direct login to root allowed).

    e.g.
    Code:
    sudo mkdir -p /mnt/newhome
    Code:
    cd /home
    sudo tar cf - . | (cd /mnt/newhome; tar xfp -)
    If you want to see what's going on you can do it this way:
    Code:
    cd /home
    sudo tar cvf - . | (cd /mnt/newhome; tar xvpf -)
    Note that the order of the tar arguments is not critical.

    I can do similar things if the file is REALLY large by using the GNU tar feature that incorporates gzip functionality:
    Code:
    cd /home
    sudo tar cvzf - . | (cd /mnt/newhome; tar xvzpf -)

  5. #5
    Linux Newbie the bassinvader's Avatar
    Join Date
    Jun 2006
    Location
    Europe
    Posts
    168
    ahhh.....single-user mode and tar. New animals for me to learn about

    THanks guys. I'll try both ideas and let you know how I get on.

    Many thanks
    " I didn't know it was a picture of his wife! I thought it was a publicity shot form Planet Of the Apes."

Posting Permissions

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