Modify Restore Image Script
-
Hi to all,
I modified the init.gz file system to fix automatically the mbr with ms-sys.Where is the script that does the repair of the image?
I want to put my code at the end of the script file.thanks,
menteora -
Any chance you can share your init.gz fix? No matter what I do to my windows 7 images, I always have to go repair them after I deploy.
-
[QUOTE]Where is the script that does the repair of the image?
[/QUOTE]
If you mean restore of the image, it is located at bin/fog inside of init -
[QUOTE]If you mean restore of the image, it is located at bin/fog inside of init [/QUOTE]
thanks, that’s what I meant.[QUOTE]Any chance you can share your init.gz fix? No matter what I do to my windows 7 images, I always have to go repair them after I deploy.
[/QUOTE]
Of course, I will share it when I will implement it in bin/fog file -
This is my work:
- I downloaded and compiled ms-sys ([url]http://ms-sys.sourceforge.net/[/url])
- I copied the ms-sys binary file into bin folder of init.gz file system
- I copied the library that use ms-sys into lib folder of init.gz file system (use [QUOTE]ldd /usr/local/bin/ms-sys[/QUOTE] to discover the dependencies)
- (optional) I copied the sfdisk binary into sbin folder to fix the boot flag (if is necessary after fix mbr)
- After this row in bin/fog:
[QUOTE]echo " * Image Restored";
done[/QUOTE]I inserted the following command:
[QUOTE]if [ “$osid” == “1” ]
then
echo " * Fix Windows Xp Mbr:“;
echo
ms-sys -m /dev/sda
echo
echo " * Restore Flag Boot:”;
sfdisk -A1 /dev/sda
fi[/QUOTE]As you can see, I tested it only in Windows Xp with a multipartition disk image.
I hope could be useful,
menteora -
[quote=“keltorsori, post: 1880, member: 607”]Any chance you can share your init.gz fix? No matter what I do to my windows 7 images, I always have to go repair them after I deploy.[/quote]
I forgot to say that ms-sys allows to fix the other operating systems:
[INDENT]-7, --mbr7 Write a Windows 7 MBR to device
-i, --mbrvista Write a Windows Vista MBR to device
-m, --mbr Write a Windows 2000/XP/2003 MBR to device
-9, --mbr95b Write a Windows 95B/98/98SE/ME MBR to device
-d, --mbrdos Write a DOS/Windows NT MBR to device[/INDENT]
You can try,
by
menteora -
I just wanted to add a comment. I’m not sure exactly what the ms-sys program does, but Fog essentially already does the same thing. Fog has the standard mbr’s for xp, vista, and 7 stored in init.gz. It restores them with the command
[B]dd if=$mbrfile of=$hd bs=512 count=1 &>/dev/null[/B]
It looks to me that ms-sys is restoring the same standard mbr, if you restore the standard mbr to a system that doesn’t use the standard mbr, such as a system with 2 or 3 partitions, then it probably won’t boot.
Just some thoughts. -
[quote=“jdd49, post: 2005, member: 623”]I just wanted to add a comment. I’m not sure exactly what the ms-sys program does, but Fog essentially already does the same thing. Fog has the standard mbr’s for xp, vista, and 7 stored in init.gz. It restores them with the command
[B]dd if=$mbrfile of=$hd bs=512 count=1 &>/dev/null[/B]
It looks to me that ms-sys is restoring the same standard mbr, if you restore the standard mbr to a system that doesn’t use the standard mbr, such as a system with 2 or 3 partitions, then it probably won’t boot.
Just some thoughts.[/quote]Hi jdd49,
ms-sys fix the mbr, don’t restore the standard one, it’s similar to windows recovery console fixmbr command.
I tested ms-sys on a Lenovo pc with 2 partitions (recovery and windows xp) and worked well.menteora
-
I checked out the source of that program, I am just trying to figure out why this works for you but yet the fog method doesn’t. It seems ms-sys restores only the first 446 bytes of the mbr, that is why your partition table stays intact enabling your multiple partitions to still work. Fog restores all 512 bytes which includes the partition table and then depending on your image type it gets deleted anyway and replaced with a new partition table. Seems strange that this solution works for you and fog on it’s own does not, like i said they are essentially doing the same thing. But hey, whatever works is what you should use.
-
Thanks for your support, is very interesting that you found.
Can I make some additional tests?menteora