Backing up - lost boot to windows, Q about mbr,grub2,ntfsclone
Hello,
This is not the continuation of the other topic, but it is related. Step 1 Computer with MBR, only one hard disk (sda) and the next partition table: Code:
/dev/sda1 extended 51.76 GiB sda5 had ArchLinux / sda6 had /home I did the next commands and store the results files in another external disk: Code:
sfdisk -d /dev/sda > /.../sda_sfdisk.ptab Step 2 I simulate that I change the computer and therefore the partitions in the system, to test if it is possible to recover the two systems + entry options (grub). I used Gparted, and this is the next partition table: Code:
/dev/sda1 ntfs win 50.78 Step 3 I "dump" the partitions in the proper place: Code:
ntfsclone --restore-image --overwrite /dev/sda1 /.../windows.ntfsclone * Remember that I put the flag "Boot" in the /dev/sda1 from Gparted, because in the previous system it was like that (in the /dev/sda2). I reboot, grub2 appears and Linux is perfect, buuuuut, windows not. What shows? Only a "_" blinking in white over the whole dark screen. Ok!, I know, the grub points to /dev/sda2, but now windows is in /dev/sda1. Now, I'm going to shows in ministeps all the processes that I have tried during the day, with no results: ministep 1 arch-chroot, restore grub2 with grub-mkconfig -o /boot/grub/grub.cfg reboot, still blinking in the windows 7 loader (/dev/sda1) I also check that the files in /dev/sda1 are about windows, and yes, correct. Also that in the menu of grub says really /dev/sda1. In the /dev/sda1 there are "folders" with Boot, I suppose that it is because of the flag boot that I wrote from Gparted. ministep 2 I have reboot from the USB Windows 7 installation, and instead of install, I go to the "Repair system". First It is detected in "a weird way", after "repair and restore" (only option there), it is recognised, (Windows 7 (recovery) -- xxxx GB used - C:/ ) then appears some options, I press "Repair system - the boot of the system.. reboot the same blinking. * I know that there is command prompt - where i can write this there (like /fixmbr and other, but I haven't tried yet) ministep 3 Again, from a live-cd: ntfsresize /dev/sda1 Everything goes correct / OK (I read about the size of the partition is not the same as the size of the filesystem, is because I did that) reboot nothing ministep 4 I have reboot from the USB Windows 7 installation, and instead of install, I go to the "Repair system". I press "Repair system - the boot of the system.. (AGAIN) But now it detects that has some "errors to repair", after the errors are repaired (probably caused because of the ntfsresize option), I reboot. the same blinking. ministep 5 I have tried to disable the boot flag from /dev/sda1 , so, no partitions with boot flag. Reboot... now, not even the grub. ministep 6 I have tried to activate the boot flag to /dev/sda5 (I know, weird test, but I had time) Reboot... now, not even the grub. So, I put again in /dev/sda1 to can access the grub. ministep 7 I try to put the same mbr that was before (when backing up). dd if=/.../sda.mbr of=/dev/sda bs=446 count=1 reboot... nothing ministep 8 ntfsfix --clear-bad-sectors /dev/sda1 ntfsfix --clear-dirty /dev/sda1 reboot... nothing ministep 9 boot to USB Windows 7 Repair Windows 7 Ultimate (recovery) 519999 MB (C:) win -> next command prompt write:bootrec /FixMbr This operation comlpeted successfully. reboot nothing load-> just is stopped in the BIOS "screen" (where you can access F2 for Setup or F4 for Recovery.) [note] bootrec /? show the different options: /FixMbr /FixBoot ministep 10 boot to USB windows 7 repair ...command prompt: write: bootrec /FixBoot This operation comlpeted successfully. Still...nothing is loaded. I have done arch-chroot and I see that the cfdisk is the same after these changes. The flag boot is still in sda1. Then: Code:
$ grub-install /dev/sda ministep 11 http://answers.microsoft.com/en-us/w...5-eb5c249cc838 Following that steps (Method 2) I do in command prompt of USB Windows 7 Repair.. Code:
$ C: I am going to paste here the grub.cfg part of Windows, maybe something is wrong with grub-mkconfig? I mean, not the program, but the result grub.cfg chainloader or something. Code:
menuentry 'Windows 7 (loader) (on /dev/sda1)' --class windows --class os $..... You can think "Why he is posting here things about Windows... if maybe is in that OS the problem?" But I am posting because I did "ntfsclone" and It should work correctly. So, maybe is something with the boot connection. Question 1 How to solve this problem? The only thing is how to "recover" and access Windows... because there are no errors, just the "_" blinking, like waiting for something. Question 2 I want to understand better how it works. I read some manuals from /usr/share/man/.. for grub, boot,... And also, in some "Theory" part I read that is not good use "extended partitions" for SWAP or DATA STORAGE. And inside of extended partitions, those partitions cannot be used as "Boot" flag, because it is difficult to access/calculate... Code:
BIOS ---> SDA --> MBR (Partition table (sfdisk access this), read the booteable flag, that is in /dev/sda1) ----> /dev/sda1 (Where to see, which sector? What reads? ---> ?? .-.-.> /dev/sda5/boot/grub/grub.cfg??? ---> linux? ---> /dev/sda5/?? Because I have been making tests, but without understanding really a lot how it works. I read some manuals, but there are steps that are not clear. Question 3 Any way to see what is written in the MBR? And how to modify it? Code:
dd if=/dev/sda of=/.../sda.mbr bs=512 count=1 |
Read the ntfsclone manpage - it specifically warns against changing partitions for Windows system partition. This is not a problem with Linux, or grub[2], or ntfsprogs. It is a problem with Windows, and its use of the registry.
There are all sorts of traps - it just isn't worth the grief - I long ago decided to leave it alone, and mess with Linux on separate disk(s). Linux is compliant enough to be able to move easily. |
Hi there,
I'm afraid I don't know what is causing your problem. Just a quick post to offer some resources that might help you understand the theory, though. Check out these pages: * http://www.ibm.com/developerworks/li...oot/index.html * http://en.wikipedia.org/wiki/Linux_startup_process Good Luck! |
ministep 12
I have found "relocntfs" that could solve the first sector boot problem. Then I found a new version called "ntfsreloc". Downloaded from. https://raw.github.com/pflanze/ntfsf...er/ntfsreloc.c compiled and finally executed: Code:
$ ./ntfsreloc -p /dev/sda1; echo "$?" When I reboot, it says: Code:
Checking file system on \\?\Volume{afsdfasdfsdfSdfsdfsdf} But I have still the questions 2 and 3. Thanks for your answers. I will have a look to those links, but so far I have read several things and I have some doubts on those 2 questions. Uf! The IBM link looks really great!! |
Congratulations - good to know it; and that it worked.
Q2: Linux bootloaders don't use the boot flag at all - it is ignored. Grub[2] (at least) can boot from primary or logical partitions equally. Same may apply to lilo, but I don't use it. The windows loaders (and some BIOS) require a boot flag on a primary partition. This is a Microsoft dictate. Q3: The MBR is primarily binary code - by definition unreadable (in an ASCII sense). The reference to thestarman info in that ntfsreloc site is as good as you're likely to get. |
Thank you all.
Finally, the "IBM" link was great! I also found this quite useful: http://www.multibooters.co.uk/multiboot.html <-- I see that is a little mess. To edit mbr, two options: "file" or "od -xa" to the img extracted with "dd" of the mbr sector. ;) |
All times are GMT -5. The time now is 07:34 PM. |