Author Topic: help needed about editing sector zero, mbr, partition list, hex editor  (Read 1934 times)

Offline nerdful1

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1575
  • Registered Linux User #444541
    • Nerdful Things
I poked around here a long time tonight about saving and restoring boot loaders, mbr etc, think in the past i complained about lost functionality in new pclos regarding saving mbr etc.

Until the end of 2007 pclos, It was a good utility on cdrom, and remasters were useful.

I have a scenario now, and when I look to PCLinuxOS, I find gaping holes in its use. Maybe it is because kde4 is still limited.

One example is try to find a disk editor, many missing from 2010. for example to replace a bit or so in the 0 sector of a hard drive.

I saved the 512, so as to include the partition info.

Anyway my problem:

I have a security video hard drive from a proprietary system I want to clone.

I was put to the task because i know a bit about Linux.

This system has some icky relationship with plugging into some usb cable to some windows software.

Anyway i used Ghost2003, the real ghost before symantec renamed drivecopy or something to ghost.

I did a ghost disk to disk from one 80G drive to another 80G.

The copy disk has all files and info, but will not boot it gets a grub error 17.

I spent the weekend on copying the 512 bits of mbr, messing with super grub disk etc.

Whenever I make a clone of the working drive to another either drive to drive or through ghost files, I get the grub error 17,.
I printed out and compared menus.lst etc.

I also tried doing dd if=mbr blah to file and of to drive etc.  

I read all old polack's stuff and linux.org etc.

It is repeatable, original drive boots, cloned one won't, all bios set to auto.

UUID stuff researched too.
« Last Edit: April 11, 2010, 09:46:30 PM by nerdful1 »
Promote open source.
Stars up!  Lights Down! Use sky and neighbor friendly outdoor lighting, and save energy.  Darksky dot org.
 ISF Professional that wants to keep black level in the sky.
Mythic Dragon V1.0 Desktop HTPC running PCLOS & Mythtv simultaneously.

Offline 7272andy

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1627
  • UK MLU
Can't help with the low level stuff, but I've used Partimage and Clonezilla successfully where ghost has failed

Regards
Andy


Bare Metal 1         Bare Metal 2
Intel Celeron 420M   Intel i5 540M
2GB Ram              4GB Ram
Intel 943GM          Radeon HD 5650 PCI Express
RT2573               RT2790
32bit KDE            32&64bit KDE

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Quote
I have a security video hard drive from a proprietary system I want to clone.

I was put to the task because i know a bit about Linux.

Do you actually need it cloned or do you need to get the contents from it ....  or more securely a copy of it?

If what you want to do is to clone the MBR and Partition table then I guess you know, but I would use

dd if=/dev/hdX  of=/dev/hdY bs=512 count=1


If I wished to clone the whole drive I also would use the dd command in a similar manner, maybe
dd if=/dev/hdX  of=/dev/sdY  bs=64k conv=notrunc,noerror

If I wanted to get the data off the HDD I would not boot from it but connect it as an additional drive.


Quote
Grub Error 17
                    Cannot mount selected partition
      This error is returned if the partition requested exists, but the
      filesystem type cannot be recognized by GRUB.

How is the drive partitioned?
What filesystem/s does it contain?
Does the original have Grub as bootmanager?
If not what does it use?

There really is too much information missing to be sure what the best approach would be.
Maybe if you tell us what you want to achieve rather than the manner you are going about it presently - cloning, we may have a better idea what to suggest.

At this point I don't know if you want the contents of the drive, or want a duplicate of the drive for some other purpose like extracting the contents without effecting the original, or maybe you want to boot the duplicate for some other reason ........

regards.

Offline nerdful1

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1575
  • Registered Linux User #444541
    • Nerdful Things
Thanks for the help.

I originally used Ghost2003 on my Nightowl cd, I made long ago and use a lot without problems.

The first step I took was to ghost the entire drive, not just the partition to a set of 2.xGig files. At the time I did not have another physical drive ready.

Later I ghosted an identical size drive from those image files.

It would start boot and fail with grub error 17. (both the image files, and the cloned drive pass Ghost's integrity check.)

So at this moment, I just finished making a file of each drives MBR:

dd if=/dev/hdc of=/home/guest/Desktop/orig.mbr bs=512 count=1 for the original drive.

dd if=/dev/hdc of=/home/guest/Desktop/clone.mbr bs=512 count=1 for the cloned drive

I then loaded 'hexeditor' I found in the synaptic repo for my ZEN live cd. (Yay PCLinuxOS to the rescue).

Both files are identical! But the original drive boots, the new one gets error 17.

I don't need to recover the data, the purpose is to make the system a spare drive in case the original goes south.
There is a lot of proprietary hardware around it, but I thought the drive looked typical. FAT32, grub loader etc.
There is some windows stuff on there as the drive holder is designed to be plugged in and read via usb on any windows box.

The drives are 80G, and part of this project was to explore the possibility of putting an IDE/flash drive to replace the hard drives, but wanted to make sure I didn't mess up the original system.

There is no provision for a cdrom or floppy on the system the drive lives on, but my present thought is to make a bootable usb stick and poke around the drives in the system rather than in my test tower.

But I am at square one with making a bootable usb, much as I want to learn that soon anyway.

Thanks, something to take our time waiting for 2010 :)

I first compared the menu.lst and other things I read about, but there are no changes.

So what tiny bit of data am I missing from one platter to another? I thought for sure reading the hex of each MBR would show me the difference.



Promote open source.
Stars up!  Lights Down! Use sky and neighbor friendly outdoor lighting, and save energy.  Darksky dot org.
 ISF Professional that wants to keep black level in the sky.
Mythic Dragon V1.0 Desktop HTPC running PCLOS & Mythtv simultaneously.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Well first of all the Grub error indicates that Grub is not happy with the filesystem on the partition you are trying to boot.

What filesystem is on that partition?
What is the Grub menu.lst entry for it?
Don't forget that the clone needs to be connected in similar manner to the original so that Grub does not get confused .......  else you may need to edit the Grub entry to point to the correct drive.
Again I am saying all this without having all the information ......  filesystem, partition layout, in what you are trying to boot the clone, is the original disk connected at the same time?

Making a USB bootable flash stick I can help with ......  so here you are ........
http://www.pclinuxos.com/forum/index.php/topic,62202.0.html

Yes it is manually done, but you will get to use a few Grub commands which may come in useful.

*****

Now for some assumptions .........  if you had the clone connected in addition to the original, I suggest you confirm the original is booting, shut down, and then replace the original with the clone .......  connected on the same cable as the original was.

If that doesn't work then deeper investigation may be needed.
The best method to do that is with another OS ........  another PC or a USB stick.

regards.

Offline nerdful1

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1575
  • Registered Linux User #444541
    • Nerdful Things
I just started a dd if=/dev/hdb of=/dev/hdc bs=32768 and will see what happens. Hopefully, being on separate ide channels, it will only take a couple hours.

In the meantime I have learned a lot more aqbout grub, and will check your usb boot link, something I've been itching to do.
Promote open source.
Stars up!  Lights Down! Use sky and neighbor friendly outdoor lighting, and save energy.  Darksky dot org.
 ISF Professional that wants to keep black level in the sky.
Mythic Dragon V1.0 Desktop HTPC running PCLOS & Mythtv simultaneously.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
I just started a dd if=/dev/hdb of=/dev/hdc bs=32768 and will see what happens. Hopefully, being on separate ide channels, it will only take a couple hours.

In the meantime I have learned a lot more aqbout grub, and will check your usb boot link, something I've been itching to do.

Here's another link for you .....  all you ever wanted to know about the dd command   ;)

I am not at all sure about this command .....
 dd if=/dev/hdb of=/dev/hdc bs=32768

If you want to clone hdb  TO  hdc   then a command similar to what I gave above would be better I believe.
dd will stop when it can do no more.

But have a read through the link above, there should be some suggestion for command options in there, for what you are trying to do.

regards.

EDIT
            I got more dd command links if you ever want them ....  after you have exhausted all in that one   :D
« Last Edit: April 12, 2010, 01:07:28 PM by JohnBoy »

Offline nerdful1

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1575
  • Registered Linux User #444541
    • Nerdful Things
I did the bs=32768 because many places I read, it said using the 64x512 equals a track, and should transfer a lot faster between drives with the same geometry.

Oh, forgot to mention, the original and cloned drives when doing fdisk -l were absolutely identical even the UUID's.

So maybe this direct dd will work.

I'd like to wean myself off Ghost anyway, as I hear the jamokes have messed with NTFS again, and DD doesn't give a hoot.

I have used DD in the past with forlorn and for some forensic stuff, even compressing and splitting into files.. Just this system is throwing curve balls.

Also I had made sure this time and in the past that the file system was checked. Ghost will tell me if it is dirty anyway.
Promote open source.
Stars up!  Lights Down! Use sky and neighbor friendly outdoor lighting, and save energy.  Darksky dot org.
 ISF Professional that wants to keep black level in the sky.
Mythic Dragon V1.0 Desktop HTPC running PCLOS & Mythtv simultaneously.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
It really seemed to me that all that should be required is an edit of the menu.lst to get the drive to boot.

Offline nerdful1

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1575
  • Registered Linux User #444541
    • Nerdful Things
Isn't errpr 17 before it even gets to that?

Anyway It too 2700 or so seconds to dd the drive, and now the clone boots.

Wish I could have troubleshot the booting so as to learn how in the case I no longer have an original drive, and say it won't boot off the image stored in files.

I will now remove the almost 80 gigs of video content, test, and dd it to a file, probably not needing to compress it, but also in split files to fit under FAT.

Thanks for the help, right now I am burning gnome 2010 to disk. I'll try to get to like gnome. It was awful on the U***** I tried.
But at least now, a working updateable 2010!

In the meantime, reading about how to make usb bootable gnome 2010.
Promote open source.
Stars up!  Lights Down! Use sky and neighbor friendly outdoor lighting, and save energy.  Darksky dot org.
 ISF Professional that wants to keep black level in the sky.
Mythic Dragon V1.0 Desktop HTPC running PCLOS & Mythtv simultaneously.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: help needed about editing sector zero, mbr, partition list, hex editor
« Reply #10 on: April 12, 2010, 04:19:20 PM »
Isn't errpr 17 before it even gets to that?

Anyway It too 2700 or so seconds to dd the drive, and now the clone boots.

Hey, that's great!


Quote
Wish I could have troubleshot the booting so as to learn how in the case I no longer have an original drive, and say it won't boot off the image stored in files.

Not sure what you mean here, sorry.

Quote
I will now remove the almost 80 gigs of video content, test, and dd it to a file, probably not needing to compress it, but also in split files to fit under FAT.

For copying content from one drive to another I recommend rsync, or one of its front-ends ......  Grsync or LuckyBackup. That checks each file when copied to ensure there is no corruption.

Quote
Thanks for the help, right now I am burning gnome 2010 to disk. I'll try to get to like gnome. It was awful on the U***** I tried.
But at least now, a working updateable 2010!

In the meantime, reading about how to make usb bootable gnome 2010.

If there is anything unclear in that link I gave you just ask.

Offline nerdful1

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1575
  • Registered Linux User #444541
    • Nerdful Things
Re: help needed about editing sector zero, mbr, partition list, hex editor
« Reply #11 on: April 12, 2010, 06:05:55 PM »
I meant that I wanted to find the smoking gun. Why it wouldn't boot, the mbr files and uuid were identical etc.

Regarding the usb boot project, I just formatted in a windows machine a hp v125w 4gb key.

Reason was it was not recognized by PCC in 2010 gnome. It didn't help.

The key is able to be seen with file managers, it shows up as sdb in the pcc hardware, but when clicking on it, the disk partition manager in pcc only sees the sda primary drive.

If i double click the sdb line in the pcc hardware list, it opens to the sda drive and partitions.

But that is a horse of a different color, so I will marked this thread solved soon, after wrapping up a few things.

Thanks!
Promote open source.
Stars up!  Lights Down! Use sky and neighbor friendly outdoor lighting, and save energy.  Darksky dot org.
 ISF Professional that wants to keep black level in the sky.
Mythic Dragon V1.0 Desktop HTPC running PCLOS & Mythtv simultaneously.

Offline Was_Just19

  • Hero Member
  • *****
  • Posts: 6852
  • MLU
Re: help needed about editing sector zero, mbr, partition list, hex editor
« Reply #12 on: April 12, 2010, 06:20:12 PM »
I meant that I wanted to find the smoking gun. Why it wouldn't boot, the mbr files and uuid were identical etc.

It may have been the UUIDs at fault.
I would have suggested changing those to /dev/sdX or whatever to test that.

Quote
Regarding the usb boot project, I just formatted in a windows machine a hp v125w 4gb key.

Reason was it was not recognized by PCC in 2010 gnome. It didn't help.

The key is able to be seen with file managers, it shows up as sdb in the pcc hardware, but when clicking on it, the disk partition manager in pcc only sees the sda primary drive.

If i double click the sdb line in the pcc hardware list, it opens to the sda drive and partitions.

But that is a horse of a different color, so I will marked this thread solved soon, after wrapping up a few things.

Thanks!

The disk does not need to be seen as such to be able to be worked on, initially.
Use
fdisk -l
to get details of the partition layout ......  it may need to be deleted and recreated.
Again it would be  dd  512  to delete the MBR/partition table, and fdisk /dev/sdX to work on recreating it --- called I think a DOS Label or such. fdisk can then be used to create partitions as you wish also.
After that it should be OK.

***

I have had several sticks with a weird MBR?partition table .......  it may be something to allow access by a Mac or such, I don;t really know, but when I recreated a DOS boot label and partitions they are all working correctly since.

In any case have a look at what fdisk reports about the device.

regards.

Offline nerdful1

  • PCLinuxOS Tester
  • Hero Member
  • *******
  • Posts: 1575
  • Registered Linux User #444541
    • Nerdful Things
Re: help needed about editing sector zero, mbr, partition list, hex editor
« Reply #13 on: April 12, 2010, 06:32:03 PM »
Thanks, I started a thread on it. I'll look into other than PCC to get it kick started.
Promote open source.
Stars up!  Lights Down! Use sky and neighbor friendly outdoor lighting, and save energy.  Darksky dot org.
 ISF Professional that wants to keep black level in the sky.
Mythic Dragon V1.0 Desktop HTPC running PCLOS & Mythtv simultaneously.