Boot-Repair – A simple tool to repair frequent boot issues

Discussion in 'all things UNIX' started by lotuseclat79, May 23, 2014.

Thread Status:
Not open for further replies.
  1. lotuseclat79

    lotuseclat79 Registered Member

    Joined:
    Jun 16, 2005
    Posts:
    5,097
    Boot-Repair – A simple tool to repair frequent boot issues.

    -- Tom
     
  2. Palancar

    Palancar Registered Member

    Joined:
    Oct 26, 2011
    Posts:
    1,594

    Do you know if this tool can be used to create a duplicate linux boot flash? I use 14.04 but I place /boot on a usb flash to mount my OS. My 14.04 is fully LUKS encrypted. I would use this program to create a SECOND backup boot flash in case the original gets lost/damaged. I backup the linux partition but I need a better way to create a second boot flash to store in case the original has any issues.

    Is there some other tool that would be convenient for this purpose? I would like to create the backup boot flash while I have access to Linux. It would be much tougher if the /boot original gets lost since its LUKS encrypted and locked otherwise.
     
  3. lotuseclat79

    lotuseclat79 Registered Member

    Joined:
    Jun 16, 2005
    Posts:
    5,097
    Hi Palancar,

    The simple way I used to save my butt in such a situation has always been to become root, and use the dd command to save the critical boot sectors into a file on another device and visa versa where two or more disks are involved. That way you can use the reverse dd command to reconstitute the boot sectors to their original state when everything was working.

    I know I still have some old files around that describe in detail what I did. Let me look for them and I'll post them in this thread.

    -- Tom
     
  4. lotuseclat79

    lotuseclat79 Registered Member

    Joined:
    Jun 16, 2005
    Posts:
    5,097
    Hi Palancar,

    Here is what I did. My original system had only two disks (now four):

    To save MBRs:
    To copy the entire MBR of the Linux FC3 disk to a file:
    dd if=/dev/sdb of=/root/Mbrs/sdbmbr bs=512 count=1

    To copy the entire MBR of the WinXP Pro SP2 disk to a file:
    dd if=/dev/sda of=/root/Mbrs/sdambr bs=512 count=1

    The new contents of the WinXP Pro SP2 MBR were simply saved to another file name from Ubuntu with the command:
    dd if=/dev/sda of=/root/Mbrs/chk1sdambr bs=512 count=1

    Then, issue the following command to see the contents of the saved vs new MBRs:
    cat sdambr | xxd > sdambr.xxd; cat chk1sdambr | xxd > chk1sdambr.xxd

    A diff command lets you view the textual dumps from the .xxd files

    And finally, to restore the original WinXP Pro SP2 MBR contents:
    dd if=/root/Mbrs/sdambr of=/dev/sda bs=512 count=1

    To restore only the partition table, skipping boot loader code:
    dd if=/root/Mbrs/sdb1mbr of=/dev/sdb2 bs=1 skip=446 count=66

    Note: About the MBR:
    1) MBR is first 512 bytes
    2) Boot loader is in first 446 bytes
    3) Partition table is in next 64 bytes
    4) last two byes identify that sector as MBR

    -- Tom
     
  5. Palancar

    Palancar Registered Member

    Joined:
    Oct 26, 2011
    Posts:
    1,594
    I appreciate your trying to help out. My issue is that my entire drive is encrypted and TrueCrypt has the SDA mbr/bootloader section of the drive used. I cannot use /boot on sda unless I am willing to remove the encryption on the windows partitions and/or move the TC bootloader to a removable media. Either way I am required to use one form of removable media to make it all work. It works slick, only to mount my linux crypt I use /boot on a flash. I have a little program (Image USB) that I use to copy out the exact contents of the current /boot flash even including the UUID and everything. It works and is roughly acceptable.

    I was thinking this program might seem a little more slick and professional if the Linux OS itself re-wrote /boot to any media I selected. My current scenario allows for recovery and mounting the OS if needed. It just doesn't have that "cool full of features" feel to it. I do full sector based backups of the actual Linux OS.
     
Loading...
Thread Status:
Not open for further replies.