LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Copying /home - use dd or cp ? (https://www.linuxquestions.org/questions/slackware-14/copying-home-use-dd-or-cp-440051/)

Eternal_Newbie 04-29-2006 01:17 PM

Copying /home - use dd or cp ? SOLVED
 
I want to copy my /home partition over to a new disc as I am running short of space.

The existing /home is on /dev/hdb2 ,is Rieser3 and the new one will probably be on /dev/sda5 and Reiser3

I am unsure whether to use cp or dd to do this . Most of what I have read seems indicate dd is better for this sort of task, but I am still unsure what command switches/options I should use. :confused: :scratch:

I think that this would work for cp:
boot using Slax
mount existing partition as /mnt/hdb2
mount new (formatted) partition as /mnt/sda5
cp -dpR /mnt/hdb2/ /mnt/sda5/

I have no idea how use dd :( - the options confuse me. I do know that I want to copy the contents of the partition, not the actual partition, if possible.


I assume changing the fstab entry to point at /dev/sda5 is enough or does anything else need changing

Speek 04-29-2006 01:21 PM

I'va once copied an entire Slackware system from one partition to another with "cp -a" and everything was fine. So I recommend "cp -a".

Randux 04-29-2006 01:22 PM

I think dd is better suited for making exact images of stuff that shouldn't be moved. When you're copying files and directories, cp is fine.

The other thing you could do is to tar home and untar it in the new partition. That way you would also have a backup.

Eternal_Newbie 04-29-2006 01:26 PM

Thanks for your answers :)

I try this as soon as World Community Grid has finished it's latest unit.

Pollyanna 04-29-2006 03:09 PM

tar!
 
Hello,

my personal favorite for doing this is "tar":

(cd /home_old; tar cf - .)|(cd /home_new; tar pxvf -)

It does the same thing as "cp -a":
* preserves mode, ownership, timestamp
* copys symolic links as links
* includes subdirectories and hidden files

Please pay close attention to the ownership of files and directories, because it is preserved as *numerical* value (=UID). In your case this doesen't seem to be a problem, but if you transfer partitions between different Systems, on the same machine, or even on different machines, this is will sureley get in your way.
Trust me. 8-(


Hopefully helpfull

Pollyanna

Randux 04-29-2006 03:23 PM

The only thing I would add is that when making a tar and if space is at a premium, use bzip2 compression (j switch). For less compression and faster processing, use gzip (z switch)

Pollyanna 04-29-2006 03:54 PM

compression?
 
Hi,

well I think under this circumstances, transfering the contents of one directory to another directory on the same machine, compression is not only unnecessary but obstructive.
The only thing it does is to compress bits (slow), move them from harddisk to harddisk (fast) (or partition to partition, fast too) and then decompress bits (slow). If you get rid of compression here there is only one fast step left. 8-)

When it comes to archiving data, compression is a must! Well, mostly a must. ;-)


Hopefully clarifing

Pollyanna

Eternal_Newbie 04-29-2006 06:38 PM

Up and running, thanks for the help :)
 
Thanks for all the advice everyone :D

I am now posting from my spacious new /home :)

In the end I decided to go with cp -a /mnt/hdb2/*.* /mnt/sda8 (not sure why I've got so many partitions on this disk). Everything seems OK.

Next time I will try using tar

Pollyanna 04-29-2006 07:16 PM

hounted by microsoft
 
Hi

while this is Your life and You do as You please, there is one thing I want to tell. ;-)

In Linux and Unix as a whole, there are no such beasts as "extensions" in filenames. The dot is simply a part of the filename.
Take a look at /etc/rc.d/ and at the files therein. "rc.inet1" has its "filetype" at the beginning! (It is a "rc-script".) And what about "/etc/ssh/ssh_conf"? Look Ma, no extension! ;-)
"ls *.*" is very different from "ls *" which is what you actually meant.

"*.*" means "all things with names containing a dot", while "*" means "all things, with a name at all". Try it for yourself and please be sure that really all files have been transferred!

And the partitions can be checked with "fdisk -l" (as root) or, even much nicer, with "parted" (also root required) which shows the filesystems on the partitions too.


Yours

Pollyanna

Eternal_Newbie 04-29-2006 08:19 PM

thanks for the warning - the curse of m$ strikes again

As far as I can tell I did copy everything. I just made typo in the post thankfully :)

I will triple check everything, though - just in case.

gnashley 04-30-2006 08:50 AM

cp -avx /home /new/path
is the easiest and cleanest to move or copy something.

ArmOrAttAk 05-01-2006 07:51 AM

I was trying to do this with dd and cp one day. The target and source directories didn't have the same number of files or innode count or something when i did ls -a. rsync is what i ended up using.

gnashley 05-01-2006 12:10 PM

cp won't copy hidden files unless you use the -a option, which also preserves all permissions and ownership of the files if possible.
cp -av is what the Slackware ZipSlack HOWTO recommends for 'migrating' your installation to a linux partition. Works fine if you don't need any compression during transfer.


All times are GMT -5. The time now is 05:09 PM.