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 ...
- 07-06-2007 #1
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."
- 07-06-2007 #2
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/
- 07-06-2007 #3Just Joined!
- Join Date
- Apr 2005
- Location
- Clinton Township, MI
- Posts
- 84
I have copied large directories, even partitions, using tar
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:
Note that this command should be punctuated exactly as it is here. Also, the directory todir must exist before you perform this command.Code:cd fromdir tar cf - . | (cd todir; tar xfp -)
- 07-06-2007 #4Just 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 commandor usingCode:su
, depending on the distribution you are using.Code:sudo
If you use su, type inand 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 useCode:su
as a prompt for the root (privileged user) account.Code:#
From root, you can run the following commands direcftly. Otherwise, prepend each command with thecommand (Ubuntu, for example, requires this syntax, no direct login to root allowed).Code:sudo
e.g.Code:sudo mkdir -p /mnt/newhome
If you want to see what's going on you can do it this way:Code:cd /home sudo tar cf - . | (cd /mnt/newhome; tar xfp -)
Note that the order of the tar arguments is not critical.Code:cd /home sudo tar cvf - . | (cd /mnt/newhome; tar xvpf -)
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 -)
- 07-06-2007 #5
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."


Reply With Quote
