home dir to usb

Kurt Granroth kurt+plug-discuss at granroth.com
Wed Dec 30 20:13:41 MST 2009


Your advice to use 'dd' was referring to something other than copying 
your home directory ;-)

The 'dd' command is as low-level and hard-core as you typically can get. 
  It is used to make a *perfect* byte-by-byte copy of a file.  However, 
it's rarely used to make copies of "normal" files anymore.  Instead, 
it's used to make copies of "block" files.  That is, all hard drives and 
all partitions in the hard drives have a special pseudo file called 
/dev/something.  So if you want to make a perfect copy of an entire hard 
drive (including all file systems with their inodes and logs and 
everything), then you use 'dd'.  The normal 'cp' and the like can't get 
low-level enough to deal with things like that.

('dd', btw, stands for "Copy and Convert".  Supposedly it was initially 
shortened to 'cc' but since that was taken by the compiler, they used 
'dd' instead.)

If you want to copy a directory, your best bet is to use 'cp' or 
'rsync'.  Why the choice?  Well, 'cp' is an old-school Unix utility and 
it was never built to fully handle directories.  The GNU version of 'cp' 
(which is what you are using) *can* handle directories and permissions 
and the like and so it'll work just fine... but people who have been 
around Unix long enough (and those who work on disparate Unix and 
Unix-like systems), tend to avoid counting on GNU cp since there's no 
guarantee that it'll be on any given system.

'rsync', on the other hand, is nearly ubiquitous and it works awesome 
for copying directories.  It is, by far, the most common tool used for 
copying or backing up entire directory structures.

So you have a couple of choices to make. First, do you want to copy 
*everything* off of the old hard drive to a new one?  Or do you only 
want to copy off the home directory?

In either case, I recommend using 'rsync'.  Thar be dragons when using 
'dd' and it won't help you much in either case here.

So..

1. Mount your new USB drive and format it as ext3 or ext4.  You should 
be able to do that in a fairly GUI manner with any half-way modern Linux 
desktop.

2. Do you see where the USB drive is mounted?  I'll pretend it is 
/mnt/usb for this example.  Do the following if you are copying over 
just your home directory:

$ rsync -azvH /home/stormy /mnt/usb/

If you are copying over your entire hard drive, then:

$ sudo rsync -azvHx --exclude=/proc --exclude=/dev --exclude=/sys / 
/mnt/usb/

On 12/30/09 7:13 AM, betty wrote:
> i'm sure i know less than you, the advice was to use dd. is one better
> than the other?? i'm willing to use whatever will work to copy my home
> dir to the new computer so that all my settings are the same.
>
> what would be the command for cp?
> thx
> betty i
>
> Eric Cope wrote:
>> please excuse my ignorance, why would cp -r not work?
>> Eric
>>
>> On Tue, Dec 29, 2009 at 9:33 PM, betty<nicepenguin at webcanine.com
>> <mailto:nicepenguin at webcanine.com>>  wrote:
>>
>>      I installed the new drive into the new computer. I'm going to transfer
>>      the home directory to a usb drive and then to the new computer.
>>      This is the command i tried and the result i got.
>>
>>       stormy at stormy-desktop:~$ sudo dd if=/home/stormy of=/dev/sdc1
>>      bs=1024k
>>      [sudo] password for stormy:
>>      dd: reading `/home/stormy': Is a directory
>>      0+0 records in
>>      0+0 records out
>>      0 bytes (0 B) copied, 0.000942499 s, 0.0 kB/s
>>      stormy at stormy-desktop:~$
>>
>>      What is wrong there? i am such an idiot on command line stuff. aghhh.
>>      Thanks.
>>      betty i.
>>
>>      Joseph Sinclair wrote:
>>      >  First, I'd definitely recommend going with a new SATA drive on
>>      the new machine.  You'll find everything just works better and the
>>      added reliability of a newer drive makes for a lot less stress
>>      (although regular and frequent backups are definitely the best
>>      peace-of-mind tool).
>>      >
>>      >  For the data transfer there are 3 simple options:
>>      >  1) If you have, or can borrow, a large enough USB drive (flash
>>      or HDD), I'd copy everything (I prefer rsync, but dd is a good
>>      choice too) to the USB drive, then copy from that to the new computer.
>>      >  2) Temporarily install the old drive in the new machine on the
>>      ATA (CDROM) interface (if the new machine has an old-style ATA
>>      interface for the CD drives), and copy the data from one drive to
>>      the other (definitely use rsync here).
>>      >  3) Connect the two machines to an ethernet router/hub and use
>>      rsync to transfer the files over the ethernet connection.
>>      >
>>      >  However you end up doing the transfer, I'd definitely recommend
>>      retaining a separate backup of all of your personal data
>>      (pictures, documents, music, videos, etc...) as part of the
>>      process, if at all possible.
>>      >
>>      --
>>      betty i.
>>      www.webcanine.com<http://www.webcanine.com>
>>      information for people
>>      who care for dogs.
>>
>>      ---------------------------------------------------
>>      PLUG-discuss mailing list - PLUG-discuss at lists.plug.phoenix.az.us
>>      <mailto:PLUG-discuss at lists.plug.phoenix.az.us>
>>      To subscribe, unsubscribe, or to change your mail settings:
>>      http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss
>>
>>
>>
>>
>> --
>> Eric Cope
>> http://cope-et-al.com
>
>



More information about the PLUG-discuss mailing list