LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 07-02-2006, 03:06 AM   #151
bennettr
LQ Newbie
 
Registered: Jun 2006
Location: I live in Bangkok Thailand
Distribution: Fedora Core 5 and core 3
Posts: 2

Rep: Reputation: 0

Quote:
Originally Posted by AwesomeMachine
OK, the best way to do what you want is to partition the new drive before you copy everything. You can make the partitions any way you want as long as there are enough of them. Sector 1 of drive 0, sda, hda contains the MBR. The MBR is 446 bytes, but there are signature bytes at the end of sector 1, "55 AA" that have to be there for anything to read the partitions. So, the exact mix of partitions is not the important thing, that is primary and logical. If you install MS Windows first it will install to an extended partition if you tell it to. I always put Windows in a logical drive on an extended partition, along with swap. Then I make two primary partitions for /home and /. I actually make / first, then /home, then the extended parttition, and then MS Windows partition, and finally swap. A DOS boot disk with a Partition Magic second emergency floppy disk works wonders. You just boot with the DOS floppy, or make a floppy image with dd and use cdrecord to make a cd out of it. Boot, take out that disk, and put in the second floppy of Partition Magic and type:

PQMAGIC

and there's you fully featured partition program, MS Windows and linux. PM 8.0 works for everything.

Since you want to keep the partition tables separate:

dd if=/dev/hda1 of=/dev/hdb1

These should be the / directories for linux.

Then do every partition. When you get done, boot from the linux install CD into rescue mode and tell it to fix everything, esp GRUB. Unless you use NTLDR to boot, but please don't do that. The rescue mode should fix the the first 429 bytes of sector 1, or boot strap code, without touching the partition table.

If you get hung up on doing an NTFS partition, which needs to be type "07" for MS Windows to even work, first write zeroes to all of the new disk:

dd if=/dev/zero of=/dev/hdb

Then partition. You can make the MS Windows partition linux type "83" and fix it later. Heres how you fix it so it's NTFS:

If it's in an extended partition:

dd if=/dev/hdb | hexdump -C | grep '00 83'

Look where it finds that on the terminal screen. Go there with dd:

dd if=/dev/hdb of=/directory/file.bin skip=10000 count=1

But figure out, by the offset in hexdump, where dd has to go. In the above example, dd is going to start at decimal offset 5,120,000. That's the default bs=512 times skip=10000. You're skipping 10000 blocks of 512 bytes, then recording a single sector, count=1. Hex offset is calculated with a calculator in linux, 5,120,000 d = 0x4e2000 h. Your screen is going to give you hex values, but dd works in decimal. You have to convert the hex offset where "00 83" are found to decimal so you can make dd go to the right spot. When you capture file.bin, open it with a hex editor and change "00 83" to "0007", then:

dd if=/directory/file.bin of=/dev/hdb seek=10000

That writes the new value to the extended partition.

If MS Windows is in a primary partition, is it partition 1, 2, 3, or 4?

0x1c2
0x1d2
0x1e2
0x1f2

Contain the partition type indicators for the drive. Do:

dd if=/dev/hdb of=/directory/file.bin count=1

That will record sector 1, the MBR, which contains the primary partition. Type "05" is extended, type "83" is linux, type "82" is linux swap, "01" is DOS, "07" is NTFS/HPFS. So, if your partitioning program doesn't make NTFS partitions, and you made a linux partition for MS Windows, change the corresponding type indicator:

location hex offset in sector 1:
0x1c2
or
0x1d2
or
0x1e2
or
0x1f2

with a hex editor. Screw it up afew times. Use fdisk -l in linux to see the aprtition is NTFS, and to see all your partitions. Now don't freak, just take it slow, easy, like you would with a really attractive, classy woman on a date. Give her what she wants, and she'll give you what you want. That's what linux is all about.

just one of them, depending on which primary partition, 1-4 you want to be NTFS, "07". Then, write the file back to the HDD. The partition is now NTFS type
********************************************************

Dear AwesomeMachine,
Thanks for your help - The the method I used to attempt the cloning. I'm using a desktop computer to do the cloning.

I have a 40.0 GB HD installed as the primary on the first IDE controller of the desktop computer. Its running RedHat Linux 9.0.

The 40.0 GB HD from my HP laptop computer is installed as the slave on the first IDE controller.

The 100.0 GB is the primary on the second IDE controller

I issues this command to start the process: dd if=/dev/hdb of=/dev/hdd bs=4096 (sometimes is bs=2048)

The following diagram is the state of the system after many cloning attempts using differnt "bs" values

[root@bangkok ~]# fdisk -l


********* HP Laptop computer's HD ************

Disk /dev/hda: 40.0 GB, 40007761920 bytes =====> this is the HD from the HP Laptop
255 heads, 63 sectors/track, 4864 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 902 7245283+ 7 HPFS/NTFS
/dev/hda4 903 4864 31824765 f W95 Ext'd (LBA)
/dev/hda5 903 915 104359+ 83 Linux
/dev/hda6 916 2062 9213246 83 Linux
/dev/hda7 2063 3082 8193118+ 83 Linux
/dev/hda8 3083 3337 2048256 83 Linux
/dev/hda9 3338 3592 2048256 83 Linux
/dev/hda10 3593 3719 1020096 82 Linux swap / Solaris
/dev/hda11 3720 3900 1453851 83 Linux
/dev/hda12 3901 4283 3076416 7 HPFS/NTFS
/dev/hda13 4284 4864 4666851 7 HPFS/NTFS
omitting empty partition (7)

Disk /dev/hdb: 100.0 GB, 100030242816 bytes ======> I was never able to get further than this!!
255 heads, 63 sectors/track, 12161 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hdb1 * 1 902 7245283+ 7 HPFS/NTFS
/dev/hdb4 903 4864 31824765 f W95 Ext'd (LBA)
/dev/hdb5 903 915 104359+ 83 Linux
/dev/hdb6 916 2062 9213246 83 Linux
[root@bangkok ~]#


Some error messages from: /var/log/messages

Jun 28 12:32:54 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }

Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352488, high=1, low=5575272, sector=22352488

Jun 28 12:33:10 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352488
Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }

Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352490, high=1, low=5575274, sector=22352490

Jun 28 12:33:10 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352490
Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }

Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352492, high=1, low=5575276, sector=22352492

Jun 28 12:33:10 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352492
Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }
Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352494, high=1, low=5575278, sector=22352494

Jun 28 12:33:10 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352494
Jun 28 12:33:10 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }

Jun 28 12:33:22 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352496, high=1, low=5575280, sector=22352496

Jun 28 12:33:22 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352496
Jun 28 12:33:23 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }
Jun 28 12:33:23 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352648, high=1, low=5575432, sector=22352648

Jun 28 12:33:23 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352648
Jun 28 12:33:23 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }

Jun 28 12:33:23 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352650, high=1, low=5575434, sector=22352650

Jun 28 12:33:23 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352650
Jun 28 12:33:23 Lab-linux kernel: hdb: read_intr: status=0x59 { DriveReady SeekComplete DataRequest Error }
Jun 28 12:33:23 Lab-linux kernel: hdb: read_intr: error=0x40 { UncorrectableError }, LBAsect=22352652, high=1, low=5575436, sector=22352652

Jun 28 12:33:23 Lab-linux kernel: end_request: I/O error, dev 03:40 (hdb), sector 22352652
Jun 28 13:14:24 Lab-linux gconfd (root-1215): Received signal 1, shutting down cleanly
Jun 28 13:14:24 Lab-linux gconfd (root-1215): Exiting

*************************************

Some questions:
I have tried this cloning procedure using "dd" many times and the program always stops at the same place, between partition (boundaries) six(hda6) and seven(hda7) - I would think that a file system bit stream duplicator should not be concerned with partition boundaries - is this statement true??

By the way, if I clone the PC's HD(80.0GB) to the 100.0GB Target HD, the cloning works and I'm able to boot from the 100.0 GB HD using both the PC and the Laptop computers. (the PC's HD only has linux RedHat 9.0 installed.)

Since the OSs and the data on the HP HD are less than 40.0 GB, what value should "bs" be in order to use a minimum amount of space on the 100.0GB HD? (speed is an issue-see the last question below)

Does the program stop when the destination drive is much larger than the source drive and all the data on the source drive has been transferred or does it try to use the entire destination drive?

In reference to partitioning and installing the OSs on the new HD, this is not an option they are already installed on the 40.0GB HD. I need to transfer everything to a larger HD drive first.

My strategy is to clone the 40.0GB HD first and fix the partition after the cloning is successful - even fdisk program says that the partition are in the wrong order. I can't afford to lose any data. The system works fine, right now.

In reference to "I always put Windows in a logical drive on an extended partition, along with swap.", Why?

Partition Magic is a useful program, but its unforgiving when it is checking a system with partition errors, it wont proceed. Many times I use it just for a quick error check of a mixed HD (OSs) environment. In my opinion, the Linux fdisk and sfdisk are better programs for identifying and fixing problems in a mixed OS system environment, .

Let say I had no problem with the partitions on the 40.0GB HD, what command(s) would you suggest to clone this drive to the 100.0GB HD using minimum space and maximum speed?

I'm looking forward to your response /Bennett
 
Old 07-03-2006, 11:11 AM   #152
cruiserparts
Member
 
Registered: Jun 2005
Posts: 31

Rep: Reputation: 15
Having trouble copying large (mostly empty) disk to smaller disk

This thread is extrememly helpful. thanks for the effort.

To make a long story short, I have an old 20gig ide drive that is working fine, but probably getting tired. It is the boot disk and houses the centos linux os. Most of it is empty; only about 7 gigs is being used. I am trying to put everything on an 18.2 gig scsi drive. At first i tried just dd the whole drive /dev/hda to /dev/sdd, this gave me No space left on device errors. Then I partitioned /dev/sdd to have a boot and ext3 partiion. I dd the boot parition and it did clone.

I can't seem to get the /dev/hd2 partion to copy over. I have read this thread and tried several things.

Any ideas on how to solve this problem? Below is my output.

Thanks.
___________________________________________________

[root@centos ~]# dd if=/dev/hda2 skip=1 of=/dev/sdd2 seek=1 bs=4k conv=notrunc,noerror
dd: writing `/dev/sdd2': No space left on device
4417875+0 records in
4417874+0 records out
[root@centos ~]# dd if=/dev/hda2 skip=1 of=/dev/sdd2 seek=1 bs=4096 conv=notrunc,noerror
dd: writing `/dev/sdd2': No space left on device
4417875+0 records in
4417874+0 records out
[root@centos ~]# man dd
[root@centos ~]# dd if=/dev/hda2 skip=1 of=/dev/sdd2 seek=1 bs=4096 conv=noerror
dd: writing `/dev/sdd2': No space left on device
4417875+0 records in
4417874+0 records out
 
Old 07-04-2006, 01:46 AM   #153
thloh85
Member
 
Registered: Apr 2006
Location: Earth
Distribution: BLFS customized
Posts: 160

Rep: Reputation: 31
Great article...
Thankyou!!!!!!
 
Old 07-05-2006, 09:54 AM   #154
cruiserparts
Member
 
Registered: Jun 2005
Posts: 31

Rep: Reputation: 15
Quote:
Originally Posted by cruiserparts
This thread is extrememly helpful. thanks for the effort.

To make a long story short, I have an old 20gig ide drive that is working fine, but probably getting tired. It is the boot disk and houses the centos linux os. Most of it is empty; only about 7 gigs is being used. I am trying to put everything on an 18.2 gig scsi drive.
<snip>

[root@centos ~]# dd if=/dev/hda2 skip=1 of=/dev/sdd2 seek=1 bs=4096 conv=noerror
dd: writing `/dev/sdd2': No space left on device
4417875+0 records in
4417874+0 records out
Anybody?? I tried again. Reminder that hda is 20g with about 11 empty gigs and sda is 18.2g This time I used:
dd if=/dev/hda of=/dev/sda conv=noerror
I got the error message above.

Just to see what happened I rebooted with both hda and sda in the machine. I got a warning that there were identical paritions and that linux was going to use sdd1 and sdd2 (from the new drive) and not the hda partitions (I'm not sure why). Centos (linux) started up and I coudl see all the files, but nothing mounted correctly, mdadm, fstab, etc. I'm not sure what was going on?

I'm warry about continuing until i get the dd error resolved. Anybody know how to get a good copy under these conditions?
 
Old 07-08-2006, 01:17 PM   #155
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
Smile

Quote:
Originally Posted by bennettr
********************************************************
I have tried this cloning procedure using "dd" many times and the program always stops at the same place, between partition (boundaries) six(hda6) and seven(hda7) - I would think that a file system bit stream duplicator should not be concerned with partition boundaries - is this statement true??
It is, and not. It depends what you are doing with it. If it doesn't work the first time, you don't have to keep trying the same thing over and over. The only time dd is not concerned with partitions is when the disk is not partitioned. There aren't really partition boundaries on the disk. All the partition info is in the MBR, except if you have an extended partition, of which you are allowed two, I think.

Quote:
Originally Posted by bennettr
By the way, if I clone the PC's HD(80.0GB) to the 100.0GB Target HD, the cloning works and I'm able to boot from the 100.0 GB HD using both the PC and the Laptop computers. (the PC's HD only has linux RedHat 9.0 installed.)

Since the OSs and the data on the HP HD are less than 40.0 GB, what value should "bs" be in order to use a minimum amount of space on the 100.0GB HD? (speed is an issue-see the last question below)
You really haven't taken advantage of what is already written in this thread. leaving out 'conv=notrunc' is the only thing which will reduce an image size.

Quote:
Originally Posted by bennettr
Does the program stop when the destination drive is much larger than the source drive and all the data on the source drive has been transferred or does it try to use the entire destination drive?
I asked you to partition both drives before you use dd, and leave out 'conv=notrunc'. That is the only way this will work.

Quote:
Originally Posted by bennettr
In reference to partitioning and installing the OSs on the new HD, this is not an option they are already installed on the 40.0GB HD. I need to transfer everything to a larger HD drive first.

My strategy is to clone the 40.0GB HD first and fix the partition after the cloning is successful - even fdisk program says that the partition are in the wrong order. I can't afford to lose any data. The system works fine, right now.

In reference to "I always put Windows in a logical drive on an extended partition, along with swap.", Why?
Because MS Windows is a spyware trojan, first and foremost, and then an operating system. With MS Windows XP there is an underlay filesystem, which is built by libraries of MIL code, a map, and a c++ compiler during boot. It is then destroyed before the gui appears. This filesystem is all metadata, keeping track of you. When you use MS Windows XP, there is a file called NTUSER.DAT. There is also a mirror copy of this file, which is inaccessible to the user. NTUSER.DAT is little known to be a registry file, but it is. It contains literally everything about the user. Picture this: Your overclocking, and your system crashes 17 times in a row because of corrupted memory contents. So, you tune it down a little, and it works. But, MS Windows XP keeps track of all those system crashes and profiles you as an overclocker. Guess what MS already knows? If you have expensive hardware, and overclock, you don't buy software. You steal it. So, because NTUSER.DAT keeps track of how you use your machine, and you can also be assumed to be male because women don't overclock, MS knows you are a thief. Well, MS isn't really concerned with small time thieves, but you are being labeled. Verisign Corporation is hard wired into MS Windows XP. Every time your IP makes any transaction, Verisign Corporation records the exact time, in microseconds, source IP, destination IP, and computer finger print, which is hal.dll.

MS Windows error reporting works like this:

You're busy, so you don't report 50 errors in a row. Then, you're not so busy, and you report 1 error. You just reported 51 errors because MS has put a delay loop in the error reporting interface, so people think it takes a really long time to report an error, but it is actually enough time for thousands of error reports to be transmitted. Now, MS can not collect any personally identifying info. That means your full name, birthdate, Social Security number, street address, and telephone number are off limits. MS is legally free to collect every bit of other info on your whole machine. IP address was ruled in federal court to 'NOT' be personally identifying information. Most isp's also have public lists of all their IP's in use, who is using them, with full names, addresses, and telephone numbers. You usually need to opt out of being listed manually, over the telephone, with someone at your isp in order not to be listed.

That is only the tip of the iceburg. If people knew what MS Windows does to them they would smash their hard drive with a sledge hammer and never touch a computer again. But, you can finesse the system. If your smart you can appear to be someone totally different than who you are. Like if you've got a souped up box, and the bios is set really wrong(dork). Or, everytime you use a program, you close it before opening anything else(dork). Or, you use pink baby pigs as wallpaper(girl). Or, whenever you leave your machine, you always leave your browser on the yahoo stock quotes(rich). Or, when you type in the serial number for Windows, you have it totally memorized, and you've practiced entering it, so when the time comes it only takes you one second to enter the whole 25 digit number that you are supposed to be reading as you type(phenom, accountant, clerical worker).

I might write a book on how to fool MS Windows, but if you're going to look at porno, no one is going to be convinced with the pink wallpaper. The point of all this is social engineering. With gobs of data about everyone, corporations can socially engineer people so they consume more goods and services. Taking The Name of Jesus Christ away from television, which has been a long time now, is social engineering to get people to buy more stuff. God satisfies, but sellers want people who consume. So, you get rid of God, and the people can't get enough stuff. That was discovered through similar, but much smaller scale information gathering.

Quote:
Originally Posted by bennettr
Partition Magic is a useful program, but its unforgiving when it is checking a system with partition errors, it wont proceed. Many times I use it just for a quick error check of a mixed HD (OSs) environment. In my opinion, the Linux fdisk and sfdisk are better programs for identifying and fixing problems in a mixed OS system environment, .

Let say I had no problem with the partitions on the 40.0GB HD, what command(s) would you suggest to clone this drive to the 100.0GB HD using minimum space and maximum speed?
There is not one command. You need to do each partition separately.

Quote:
Originally Posted by bennettr
I'm looking forward to your response /Bennett
Well, there it is.

Last edited by AwesomeMachine; 07-08-2006 at 01:30 PM.
 
Old 07-08-2006, 01:39 PM   #156
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
I'm glad you liked my post

Quote:
Originally Posted by cruiserparts
This thread is extrememly helpful. thanks for the effort.
You are quite welcome

Quote:
Originally Posted by cruiserparts
To make a long story short, I have an old 20gig ide drive that is working fine, but probably getting tired. It is the boot disk and houses the centos linux os. Most of it is empty; only about 7 gigs is being used. I am trying to put everything on an 18.2 gig scsi drive. At first i tried just dd the whole drive /dev/hda to /dev/sdd, this gave me No space left on device errors. Then I partitioned /dev/sdd to have a boot and ext3 partiion. I dd the boot parition and it did clone.

I can't seem to get the /dev/hd2 partion to copy over. I have read this thread and tried several things.

Any ideas on how to solve this problem? Below is my output.

Thanks.
___________________________________________________

[root@centos ~]# dd if=/dev/hda2 skip=1 of=/dev/sdd2 seek=1 bs=4k conv=notrunc,noerror
dd: writing `/dev/sdd2': No space left on device
4417875+0 records in
4417874+0 records out
[root@centos ~]# dd if=/dev/hda2 skip=1 of=/dev/sdd2 seek=1 bs=4096 conv=notrunc,noerror
dd: writing `/dev/sdd2': No space left on device
4417875+0 records in
4417874+0 records out
[root@centos ~]# man dd
[root@centos ~]# dd if=/dev/hda2 skip=1 of=/dev/sdd2 seek=1 bs=4096 conv=noerror
dd: writing `/dev/sdd2': No space left on device
4417875+0 records in
4417874+0 records out
Leave notrunc out of the command. If it still won't work, fill the free space with zeros

dd if=/dev/zero > /home/sam/bigfile.file

When dd says no more room left on device

rm /home/sam/bigfile.file

then dd without notrunc Notrunc writes all the free space. Leaving out notrunc compresses zeroed sectors.
 
Old 07-10-2006, 09:17 AM   #157
doofus
LQ Newbie
 
Registered: Mar 2004
Posts: 2

Rep: Reputation: 0
I've noticed that a lot of the dd examples here use a block size of 4096 (dd ... bs=4096 ...).

Is this for performance reasons? Does this block size have anything to do with the current system's page size? If I were using a different architecture with a different page size would I use that specific page size instead for the block size?

Cool thread BTW!
 
Old 07-12-2006, 12:47 PM   #158
dtz
LQ Newbie
 
Registered: Sep 2004
Distribution: Debian 3.1, kernel 2.6.8
Posts: 2

Rep: Reputation: 0
I'm running Debian stable and want to try upgrading to testing or unstable. If things don't work out, I want to have a snapshot of stable I can roll back to like nothing happened. From this thread I know how to make an image of my root dir. What else do I need to image? I'm guessing the mbr. Is it always just 446 bytes? And what about the loader code, partition table and whatever else is at the start of a disk? In the future I'll test one of the BSDs on this partition so this'll be useful info then as well.

Thanks AwesomeMachine for writing such an extensive tutorial!
 
Old 07-12-2006, 04:19 PM   #159
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
Quote:
Originally Posted by doofus
I've noticed that a lot of the dd examples here use a block size of 4096 (dd ... bs=4096 ...).

Is this for performance reasons? Does this block size have anything to do with the current system's page size? If I were using a different architecture with a different page size would I use that specific page size instead for the block size?

Cool thread BTW!
bs=4096 or 4k seems to work much faster than 2048 or 8192, with modern equipment, copying hard drive partitions. It's called: a sweet spot at bs=4k.
 
Old 07-12-2006, 04:44 PM   #160
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
Smile

Quote:
Originally Posted by dtz
I'm running Debian stable and want to try upgrading to testing or unstable. If things don't work out, I want to have a snapshot of stable I can roll back to like nothing happened. From this thread I know how to make an image of my root dir. What else do I need to image? I'm guessing the mbr. Is it always just 446 bytes? And what about the loader code, partition table and whatever else is at the start of a disk? In the future I'll test one of the BSDs on this partition so this'll be useful info then as well.

Thanks AwesomeMachine for writing such an extensive tutorial!
First of all, You're Welcome. The man and info documentation for dd was so bad compared to how good of a program it is, as I found more and more uses for dd, I gathered together enough info for a tutorial. God really helped me, too.

Ok, for people reading this thousands of years from now, I'm going to make it clear sector 63 starts partition 1. You can do:

fdisk -lu

Disk /dev/sda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors
Units = sectors of 1 * 512 = 512 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 63 16787924 8393931 83 Linux
/dev/sda2 16787925 147557024 65384550 83 Linux
/dev/sda3 147573090 163959389 8193150 7 HPFS/NTFS
/dev/sda4 163959390 234420479 35230545 f W95 Ext'd (LBA)
/dev/sda5 163959453 168152354 2096451 82 Linux swap / Solaris
/dev/sda6 168152418 234404414 33125998+ 83 Linux

This is one of my partition tables. Yours will be different.. But lets say we're using this one. Then, the root parttition ends at sector 167 879 24. I put spaces in the number so it can be read. Here's the command:

dd if=/dev/sda count=16787924 of=/home/sam/partitionimagewithMBR.img

to copy the existing partition, and the first 63 sectors of the drive.

simply reverse the arguments for if and of to put the image file back. /home should always be a separate partition from /, and much bigger than /. That way you can image the / partition to /home, format /, install a new os, and if you get messed up you can boot with:

http://www.efense.com/helix

and dcfldd the / partition image back.

The important thing is you don't feel pressure. So, I'll just tell you, 'If you mess this up, all life on earth will cease'.
 
Old 07-12-2006, 09:03 PM   #161
dtz
LQ Newbie
 
Registered: Sep 2004
Distribution: Debian 3.1, kernel 2.6.8
Posts: 2

Rep: Reputation: 0
Okay just to make sure I have this straight since I don't want to destroy the world:
Code:
# fdisk -lu
Disk /dev/hda: 40.0 GB, 40000000000 bytes
255 heads, 63 sectors/track, 4863 cylinders, total 78125000 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/hda1              63       80324       40131    6  FAT16
/dev/hda2           80325      610469      265072+  82  Linux swap / Solaris
/dev/hda3          610470    11100914     5245222+  83  Linux
/dev/hda4        11100915    78124094    33511590   83  Linux
hda3 is the root, hda4 is /home.
I'd use
dd if=/dev/hda3 of=/home/me/root.image bs=4096 conv=notrunc,noerror
dd if=/dev/hda of=/home/me/mbr.image count=62
to backup the root and the boot portion respectively.
Correct?

Last edited by dtz; 07-12-2006 at 09:05 PM.
 
Old 07-13-2006, 02:32 AM   #162
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
Yes, that will work, also.
 
Old 07-13-2006, 02:33 AM   #163
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Original Poster
Rep: Reputation: 162Reputation: 162
Yes, that will work, also.
 
Old 07-14-2006, 02:24 PM   #164
Copy
LQ Newbie
 
Registered: Jun 2006
Posts: 9

Rep: Reputation: 0
Hello again.

This thread continues to become better and better with time. Cheers, Awesome!

I have another question. Here goes:
I'm trying to clone Windows 9x partitions, and, as I mentioned earlier in the thread, I don't have any large hard disks available so I'm trying to backup my partitions to files instead of to the raw disk itself. The disk I want to clone is 120GB in capacity, but only has 18 or so GB of used space. I've run into a problem, however. I'm using the 'count=x' option to control the size of the files I'm making so that I can split the partitions into pieces that will fit nicely onto DVDs... But instead of truncating the empty space on the partition, dd just obediently copies as many blocks as I tell it to, even if they're empty. I know this is true, because dd didn't stop cloning even after it had passed all the used space on the partition, and all the files I made were exactly the same size--none were smaller. I definetly am not using the 'conv=notrunc' option... So my question is, if I use the 'count=x' option, does dd simply not truncate empty space? And if so, how do I use dd (or is there a better way) to clone my partitions but split the clones up into files of an arbitrary size that I specify? Here's the exact command I'm using:

dd if=/dev/hda of=/mnt/mydir/hda1_piece1_07-14-2006.ddclone bs=4096 count=1147460 conv=noerror

dd if=/dev/hda of=/mnt/mydir/hda1_piece2_07-14-2006.ddclone bs=4096 count=1147460 skip=1147460 conv=noerror

...and so on...

Thanks a million in advance for your time and help!
Cheers!
 
Old 07-14-2006, 11:51 PM   #165
OlivierB
LQ Newbie
 
Registered: Jul 2006
Posts: 3

Rep: Reputation: 0
dd -> segmentation fault

Hi,

I am trying to copy my old 40Gb disk to a brand new 80Gb one, so as to keep my old OSes (winXP & Mandrake9.1) and add a brand new Ubuntu.
Here is the process I followed:

1- I partitionned the new disk with Partition Magic (PM) to make sure the partitionning is the same for the copies of old partitions.
Note: I tried to copy partitions with PM, but it fails (error 510 whatever the partition).

2- Then I install Ubuntu on the free space.

3- From Ubuntu, I use dd to copy the old partitions to my new disk.

It seems to have worked properly (good number of blocks read, and files are accessible), but each time dd was ending with a segmentation fault.
Any idea why dd was segmenting ?

Regards,
olivier
 
  


Reply

Tags
backup, best, clonezilla, cloning, command, data, dd, disk, drive, duplicate, erase, explanation, formatting, ghost, hard, image, iso, memory, ping, popular, recover, recovery, rescue, search, security, stick, upgrade, usb, wipe


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Learn The DD command AwesomeMachine Linux - Newbie 17 08-17-2006 04:22 AM
The best way to learn? iz3r Programming 7 02-06-2005 11:00 PM
Best way to learn Linux from the command line patpawlowski Linux - General 2 03-01-2004 03:37 PM
I want to learn C. KptnKrill Programming 14 12-18-2003 01:03 PM
Best way to learn.... InEeDhElPlInUx Linux - Newbie 5 10-11-2003 01:02 AM


All times are GMT -5. The time now is 01:05 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration