Problem involving *DD* command
copied an 80gig hard drive to an 80gig partition created on a 500gig hard drive. Used this command
80g hd = /dev/sda 500g hd = /dev/sdc; Partition sdc1 exists. added partition sdc2 executed command dd if=/dec/sda of=/dev/sdc2 here is the fdisk partition table for /dev/sdc2 Code:
Abitbox:~ # fdisk /dev/sdc2 Code:
mount /dev/sdc2 /media/sdc2 If I try Code:
mount /dev/sdc2/sdc2p10 /media/sdc2p10 Quote:
|
Quote:
|
That is not the first person who wrongly think that dd is good for copy files
dd does not copy files dd copies only blocks of data which means file fragments If you use cp or similar command to copy files instead the program is designed to fail gracefully if the copied file has not been completly copied for some reason, also I think it is better for the destination drive because it will be much less fragmented than with dd |
device-mapper
if you've got device-mapper on your system, you could try using that.
it may have automatically seen the sub-partitions on boot. have a look in /dev/mapper and see if those partitions show up. then you can just do "mount /dev/mapper/sdc2p1 /eg/mount/point" |
Hi,
Quote:
Code:
excerpt from 'man dd'; |
Regardless of what the man page says, it's not going to magically understand that the OP is starting with a disk(if=/dec/sda) but wants to convert it to a filesystem on the destination partition(of=/dev/sdc2). What's going to happen is that an image of the drive is going to be plopped at /dev/sdc2 with no way to access it. It would work with dd if=/dev/sda of=/dev/sdc, but that's not what's asked for. "dd" is probably the most confusing command on *nix, and I'm surely not an expert, but I don't see a way for "dd" to do what is asked. If it is necessary that all partitions on /dev/sda need to be copied to partition /dev/sdc2, then a series of filecopies is needed.
For example: Code:
mount /dev/sda1 /source OTOH, if it's wanted to make a copy of /dev/sda on /dev/sdc, then that is possible by doing a "dd" copy and then fixing the partitions in /dev/sdc. I believe there is an example of doing this in this introductory thread on the use of "dd": http://www.linuxquestions.org/questi...ght=dd+command |
The system I tried to copy, was corrupted and although it would boot it would not do much else. fsck found three of the file systems corrupted and tried to 'fix' them; the filesystems were '/' , '/var' , and '/home'. When I booted with a suse live-cd and mounted /dev/sda6 (which is '/var') - it was empty - so the fsck had obviously orphaned quit a bit of data.
I wanted to save as much data as possible for reference after re-installing linux. After reviewing one of the threads in this forum ("Learn the DD command") I decided to use "dd" rather than "partimage" (which I've never had a lot of success with) The original data no longer exists, Linux has been re-installed into that space; I am now in the process trying to rebuild what I had. |
Do you actually see /dev/sdc2p10 when you do an "ls /dev"? If so, did you try the following?
Code:
# mount -t auto /dev/sdc2p10 /mnt Code:
# mount -t auto -o loop /dev/sdc2 /mnt One final option is to get another drive and dd sdc2 to that drive, such as: Code:
dd if=/dev/sdc2 of=/dev/sdd |
Quote:
Code:
# fdisk /dev/sdc2 Quote:
I took a look at "device-mapper" as suggested above by "mcl". I was not able to get a good enough understanding of device-mapper |
What you have done is put an image of the entire sda drive into the partition at sdc2. The first 512 bytes of that image are the master boot record, followed by the first partition on sda, then the second partition on sda, etc.
You cannot mount this; it just won't mount. I am pretty sure that the partition sdc2 won't mount either because you have hosed the partition boot record. If you run testdisk on this hard drive (sdc), it will find your partitions - including those you imaged in from sda - and may be able to build you a working partition table. In fact, I would expect this to work so long as sdc1 is defined as a physical partition. It won't work if sdc1 is an extended partition. After it gives you a working partition table, then you can try mounting those partitions and see what you see. edit: Before you do this, I would suggest that you re-image the entire sdc2 to some other hard drive for safekeeping. Testdisk will rewrite the sdc partition table and this will cause you to lose the information on the starting point of your current image. Should something go wrong, this could leave you in bad shape. For that matter, if you re-image correctly to some other HD, you could then correctly use dd to just move your partitions to the new HD. I use dd for this kind of thing all the time. In spite of the comments others here have made about dd, I find it to be extremely useful for this kind of thing. particularly when I am trying to recover off of a hard drive that is failing or failed. You do have to know what you are doing though. |
From my notes on various commands and things:
-------------------------------------------------------------------------------------------------------- Sizing partitions, determining start and end using linux fdisk, and organizing so dd can image fdisk -l will give an output that specifies the # heads, the # of sectors/track, and the number of cylinders on the drive. For each partition, fdisk will list the starting cylinder and the ending cylinder, and the size in sectors; by default the formatting tools will use cylinder boundaries. Linux uses sectors that are 1024 bytes, which is 2 - 512 byte blocks. dd wants the starting sector and the size of the partition, in appropriate units. Default size for dd is blocks of 512 bytes. To get the starting sector of the partition, take the end cylinder of the previous partition. Multiply that number by the number of sectors/track, then by the number of heads. This gives the first sector of the last track of the previous partition. Now add in the number of sectors/track to this number and the result is the first sector of the first track of the first cylinder of the next partition. To get the size of the partition, subtract the beginning cylinder from the end cylinder and add one (to get the cylinder count). Then multiply this number by the sectors/track and the # heads. Then subtract the sectors/track from the result to get the total sectors in the partition. The size of the partition may also be determined in sectors by taking the size listed by fdisk (in "blocks"), multiplying it by 2, and adding 1. Alternatively, sfdisk -l -sf /dev/sd# will give the start block and size directly |
Quote:
|
Quote:
Before you drop this, I have an idea and thought I'd check it with you. Normally dd copies an image, and I'm pretty sure you can copy the image of a drive to an iso and then open that with loop. If he were to dd /dev/sdc2 to an iso file, would that iso mount with loop and be the original drive that was copied? Or do I understand even less than I think I do of dd? :) Of course, it all depends on having enough disk space. 80GB is an awfully big iso. |
Quote:
The problem is that he has not imaged a partition but a drive. You can't mount a drive, only a partition on a drive. This is true even if the drive has only one partition. I note that fdisk did pick up the partitions in sdc2. That suggests that there might be a way to mount them as they sit, but I don't know what that way would be exactly. You'd have to study mknod I think, and find a way to make a node in /dev for the partitions in the partition. Then they'd mount. Not sure how to do that though. |
jiml8 and Quakeboy02:
Thank your for the comments - much appreciated. jiml8 - after reading you last post, I had, what may be an obtuse thought: I am going to try and copy the partition /dev/sdc2 with dd creating an iso file, which I believe you indicated could be mounted. EDIT-re-read the last two posts with my head on streight, and I think this is what you stated would not work another thought I had was to try and create an LVM on /dev/sdc2; but it looked like all of the data would be lost. gary |
All times are GMT -5. The time now is 05:25 AM. |