Sunday, February 20, 2011

DD just works

About 8 hours into using my cloned hard drive everything seems fine. My virtual machines provided by VirtualBox are fine; I've updated 2 and deleted one.

In all the years I've used computers this is the first time I've cloned a hard drive. Usually I wait until the hard drive dies, buy another hard drive, and recover from backups. To just make a complete, at this point, apparently perfect copy of a hard drive with a bunch of partitions to another hard drive is just TOO painless.

I started off trying to use an 8 Gig USB stick. That particular device will not boot. $20 for another USB stick; dang I just spent $62 for the new hard drive and cable! Well burn a 25 cents CD.

Which I did and then booted into the live cd with the existing hard drive and the new one installed. The new one had nothing zero on it.

I started out with this:

ubuntu@ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bffd0

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1824 14647296 83 Linux
/dev/sda2 1824 14468 101561345 5 Extended
/dev/sda5 1824 5471 29295616 83 Linux
/dev/sda6 5472 13982 68358144 83 Linux
/dev/sda7 13982 14468 3905536 82 Linux swap / Solaris

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table


That's a great command line. The sudo and password bit is because root privileges are required to run fdisk which then lists the drives detected by the system. In my queries of the network (googling) I found instructions on how to do this with an Ubuntu Live media and the dd command.

Now I'm familiar with both I haven't used dd since I made boot floppies. Back then it was something like
dd if=pathtofilename of=/dev/fd0
But now with the information I have I can use dd to copy the entire contents of /dev/sda to /dev/sdb. Do NOT copy and paste! Change the values of /dev/sdx to match your system.

Now here is the biggie. Do this wrong and well I'll see you in a month or whenever you get a new install of any os. Input file, Output file; so I did, while running the liveCD,
ubuntu@ubuntu:~$ sudo dd if=/dev/sda of=/dev/sdb
Device sda had about 50 gigs of data on its 160 G capacity. Here's what I had after the dd command completed, 5739 seconds later.

ubuntu@ubuntu:~$ sudo dd if=/dev/sda of=/dev/sdb
312581808+0 records in
312581808+0 records out
160041885696 bytes (160 GB) copied, 5739.27 s, 27.9 MB/s
ubuntu@ubuntu:~$

ubuntu@ubuntu:~$ sudo fdisk -l

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bffd0

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1824 14647296 83 Linux
/dev/sda2 1824 14468 101561345 5 Extended
/dev/sda5 1824 5471 29295616 83 Linux
/dev/sda6 5472 13982 68358144 83 Linux
/dev/sda7 13982 14468 3905536 82 Linux swap / Solaris

Disk /dev/sdb: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bffd0

Device Boot Start End Blocks Id System
/dev/sdb1 * 1 1824 14647296 83 Linux
/dev/sdb2 1824 14468 101561345 5 Extended
/dev/sdb5 1824 5471 29295616 83 Linux
/dev/sdb6 5472 13982 68358144 83 Linux
/dev/sdb7 13982 14468 3905536 82 Linux swap / Solaris

Disk /dev/sdg: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System
ubuntu@ubuntu:~$


Disk /dev/sdg is another USB stick that I used to save things to while using the liveCD. But there it is; two identical drives except for their overall size of course. Here is the output of the fdisk list command now.


mark@flounder:~$ sudo fdisk -l
[sudo] password for mark:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000bffd0

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1824 14647296 83 Linux
/dev/sda2 1824 14468 101561345 5 Extended
/dev/sda5 1824 5471 29295616 83 Linux
/dev/sda6 5472 13982 68358144 83 Linux
/dev/sda7 13982 14468 3905536 82 Linux swap / Solaris

Disk /dev/sdf: 1012 MB, 1012924416 bytes
32 heads, 61 sectors/track, 1013 cylinders
Units = cylinders of 1952 * 512 = 999424 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Device Boot Start End Blocks Id System


See how important the exact paths or filenames are? What was /dev/sdg is now /dev/sdf which contains my notes taken during the liveCD session. Please read the man page for dd. You have been warned.

I used a mix of GUI, the liveCD ran Gnome, and command line, it was all command lines in a terminal.

Tuesday, February 15, 2011

New Year's Resolution

I resolved to post once a month about Ubuntu. I failed in January.

Oh well, there has been a lot going on in my daily life. I got a part-time job for D-L Construction. Part time; I've averaged 16 hours a week over the last 4 weeks. And a guy named Jim had to die for me to get this job. So it is not the greatest job in the world or my area.

The whole job thing is, well I could write a novella on my experiences over the last five years. But I won't.

Today I splurged and spent $62 at Intrex. I bought a 500 Gig SATA hd and data cable. I hope to use this to clone the hd of the machine I'm using now; take that hd and revive spinach (spinach has at least one bad hd). Right now I only have one working computer. This is just soooo unacceptable.

However, since I'm working making sawdust this may take a few days.