<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2270034590797592412</id><updated>2011-07-30T17:46:20.869-07:00</updated><category term='linux'/><category term='flash'/><category term='windows'/><category term='reverse engineering'/><category term='catalyst'/><category term='x86_64'/><category term='mingw'/><category term='fedora 9'/><category term='dual boot'/><category term='java'/><category term='ati'/><category term='mbr'/><title type='text'>Somewhat technical musings</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://cbisnett.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://cbisnett.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Chris Bisnett</name><uri>http://www.blogger.com/profile/03986163301678844575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2270034590797592412.post-607493998645949844</id><published>2011-03-29T15:53:00.000-07:00</published><updated>2011-04-09T22:28:56.981-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='mingw'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><title type='text'>Compiling Windows Executables on Linux</title><content type='html'>&lt;span style="font-family:arial;"&gt;For me Windows is like that girl that you want to forget about but you can't because she seems to be everywhere and too many people like her.  As a software engineer you can't just leave windows behind because too many people still rely on it.  If only there were a way that I could continue to use Linux but easily provide the same software for Windows.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;What I'm talking about is cross compiling.  It simply refers to compiling software to run on a target system that is different from the system running the compiler.  This has been common in the Linux community and the embedded development communities for years.  I'm going to describe the steps to installing cross compilers for Windows 32-bit and 64-bit on Fedora 14.  I'm also going to show how to set-up Eclipse projects and create build configurations that will use the cross compilers to generate binary files that will run on Windows.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Thanks to Eric van Pienbroek and some other volunteers, Fedora 15 will be shipped with the MinGW64 (Minimum GNU tools for Windows x64) cross compiling toolchain.  Until then you can install the compilers using the repository file from &lt;a href="http://fedoraproject.org/wiki/MinGW/CrossCompilerFramework"&gt;the Cross Compiler Framework wiki page&lt;/a&gt;.  Alternatively this can be done from the command line with the following:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;cd /etc/yum.repos.d&lt;/div&gt;&lt;div class="command"&gt;sudo wget http://build1.openftd.org/fedora-cross/fedora-cross.repo&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Now that the repository is set-up you can install the toolchain using the following command:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;sudo yum install mingw32-gcc mingw32-gcc-c++ mingw64-gcc mingw64-gcc-c++&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Congratulations you can now compile Windows executables from your Fedora machine!  All of your favorite GCC tools are provided for working with Windows executables such as strip, nm, ar, and even GDB!  All tools are prefixed with &lt;span class="userInput"&gt;i686-w64-mingw32-&lt;/span&gt; or &lt;span class="userInput"&gt;x86_64-w64-mingw32-&lt;/span&gt;.  You can even build code using autoconf tools using the &lt;span class="userInput"&gt;mingw32-configure&lt;/span&gt; and &lt;span class="userInput"&gt;mingw64-configure&lt;/span&gt; tools.  Continue reading if you want to learn how to set-up Eclipse projects to cross compile using your newly installed cross toolchain.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Open Eclipse and select new C++ project.  For the project type select 'Empty Project' and 'Linux GCC' for the toolchain.  While Eclipse does provide options 'Cross-Compile Project' and 'Cross GCC' I have found both lacking full support.  For example, if you select a Cross GCC toolchain Eclipse will ask you for the prefix of the tool chain which in our case would be &lt;span class="userInput"&gt;i686-w64-mingw32-&lt;/span&gt;.  In the project options under 'C/C++ Build'-&gt; 'Tool Chain Editor' you can select the tools you want to use to build the project and there are a few listed such as 'Cross G++ Compiler' and 'Cross GCC Compiler' but there is no cross archiver or cross assembler, even though these tools are supplied by the MinGW toolchain.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;For this reason I suggest selecting the 'Linux GCC' toolchain.  Then open the project options and under 'C/C++ Build' -&gt; 'Settings' add the prefix &lt;span class="userInput"&gt;i686-w64-mingw32-&lt;/span&gt; (or &lt;span class="userInput"&gt;x86_64-w64-mingw32-&lt;/span&gt; for 64-bit executables) to each tools command.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Because these binaries are built with the MinGW32/64 they require &lt;span class="userInput"&gt;libgcc_s_sjlj-1.dll&lt;/span&gt; to be distributed with the binary.  The DLL can be found in the &lt;span class="userInput"&gt;/usr/i686-w64-mingw32/sys-root/mingw/bin&lt;/span&gt; (or &lt;span class="userInput"&gt;/usr/x86_64-w64-mingw32/sys-root/mingw/bin&lt;/span&gt;) directory.  The extra DLL is required to for setjmp/longjmp C exception handling and is approximately 500K in size.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;If you're not too worried about the size of your binaries you can have the linker statically link in this code, that way you won't have to distribute the shared DLL with your binary.  To do this you need to tell the linker to statically link the binary.  Open the project properties in Eclipse and select 'C/C++ Build' -&gt; 'Settings' then select the 'Miscellaneous' option of the linker.  Add the &lt;span class="userInput"&gt;-static&lt;/span&gt; option to the 'Linker flags' text box.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;When building binaries with C++ you will also be required to distribute &lt;span class="userInput"&gt;libstdc++-6.dll&lt;/span&gt; with your binary.  This is the standard C++ library and is quite large (~6MB).  Like &lt;span class="userInput"&gt;libgcc_s_sjlj-1.dll&lt;/span&gt; it can be statically compiled into your binary with the &lt;span class="userInput"&gt;-static&lt;/span&gt; option to the linker.  The resulting size of your binary will depend on how much of the standard library you happen to utilize.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Now that you can build Windows executables and DLL without leaving Linux, get out there and try it out!  If you find that this is helpful don't forget to thank Erik van Pienbroek and the rest of the Fedora MinGW64 special interest group for all their hard work that has made this possible.  If I have enough time and there is enough interest I will post about how to use GDB to debug the Windows binaries built with the MinGW64 toolchain.&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2270034590797592412-607493998645949844?l=cbisnett.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cbisnett.blogspot.com/feeds/607493998645949844/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2270034590797592412&amp;postID=607493998645949844&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/607493998645949844'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/607493998645949844'/><link rel='alternate' type='text/html' href='http://cbisnett.blogspot.com/2011/03/compiling-and-debugging-windows.html' title='Compiling Windows Executables on Linux'/><author><name>Chris Bisnett</name><uri>http://www.blogger.com/profile/03986163301678844575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2270034590797592412.post-5202214434603901529</id><published>2010-06-27T09:10:00.000-07:00</published><updated>2010-06-28T05:54:29.741-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='java'/><category scheme='http://www.blogger.com/atom/ns#' term='reverse engineering'/><category scheme='http://www.blogger.com/atom/ns#' term='flash'/><title type='text'>Decompressing Flash Files</title><content type='html'>&lt;span style="font-family:arial;"&gt;For those of you who know me, you know that I te&lt;/span&gt;&lt;span style="font-family:arial;"&gt;nd to jump from interest to interest.  Lately my interest has been reverse engineering, probably since I'm going to the ReCon conference in July.  Anyway while surfing my RSS feeds the other day I came across a post that talked about an &lt;a href="http://www.hex-rays.com/contest2009/#2" target="new"&gt;SWF disassembler plug-in for IDA Pro&lt;/a&gt; and yesterday I had some free time to play around with it.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;After looking at the sample file provided I decided I wanted to look at a real flash application.  Since I had Pandora running in the background I figured that it would be a perfect since I always wondered if I could extend the client or create my own.  After a quick look at the page source I found the location of the SWF file.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;&lt;br /&gt;&amp;lt;EMBED src="https://www.pandora.com:443/radio/tuner_9_1_0_0_pandora.swf"&lt;br /&gt;quality=high&lt;br /&gt;bgcolor=#FFFFFF&lt;br /&gt;allowscriptaccess=always...&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;Using wget I downloaded the file and opened it up in IDA Pro.  Unfortunately the SWF plug-in for IDA won't show any code because the file has been compressed and the plug-in does not know how to decompress the file.  You can tell it's been compressed because the signature is CWS instead of FWS.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; width: 549px; height: 199px;" src="http://4.bp.blogspot.com/__inZIgDzfJ4/TCd_T5Ub9xI/AAAAAAAAABI/96CZiXoBwck/s1600/compressed.JPG" alt="" id="BLOGGER_PHOTO_ID_5487494650755020562" border="0" /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;After a little googleing I found a ton of sites that offered me flash decompilers but I wasn't about to pay $80+ and the free options smelled of adware.  After a little more searching I came across a blog post about &lt;/span&gt;&lt;a style="font-family: arial;" href="http://kaioa.com/node/87" target="new"&gt;Improving SWF Compression&lt;/a&gt;&lt;span style="font-family:arial;"&gt;.  In the post he describes how to compress SWF files and even provides an archive with tools and source.  Since his intention was to use ZIP utilities to compress the SWF data he dumped the data out into a file, then zipped it and reinserted it into a compressed SWF file.  Looking at his source it was easy to tweak it a little to extract the data from a compressed SWF file, decompress it, and recreate an uncompressed file that could be read by IDA's SWF plug-in.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; width: 575px; height: 225px;" src="http://2.bp.blogspot.com/__inZIgDzfJ4/TCeGamZ6WwI/AAAAAAAAABQ/QuEj097g30A/s1600/uncompressed.JPG" alt="" id="BLOGGER_PHOTO_ID_5487502462518188802" border="0" /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;The source code can be found here: &lt;/span&gt;&lt;a style="font-family: arial;" href="http://www.box.net/shared/veceqa96t6" target="new"&gt;SWFDecompress.java&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold; font-family: arial;"&gt;Updated:&lt;/span&gt;&lt;span style="font-family: arial;"&gt;  Added the link to the SWF plug-in.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial;"&gt;On a side not I also discovered that you can embed the Pandora player in your own webpages, &lt;a href="javascript:void(0)" onclick="tuner=document.getElementById('tuner');if(tuner.style.display=='none'){tuner.style.display='block';}else{tuner.style.display='none';}"&gt;Click Here&lt;/a&gt; to see (click again to hide).&lt;/span&gt;&lt;br /&gt;&lt;span id="tuner" style="display: none;"&gt;&lt;embed src="https://www.pandora.com:443/radio/tuner_9_1_0_0_pandora.swf" quality="high" bgcolor="#FFFFFF" allowscriptaccess="always" wmode="opaque" menu="false" name="radio" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="_tunervar_port=80&amp;amp;_tunervar_itunesurl=http%3A%2F%2Fclick.linksynergy.com%2Ffs-bin%2Fstat%3Fid%3DFLenzF8lvbI%26offerid%3D78941%26type%3D3%26subid%3D0%26tmpid%3D1826&amp;amp;_tunervar_host=www.pandora.com&amp;amp;_tunervar_proxyHost=www.pandora.com&amp;amp;_tunervar_twitterConsumerSecret=yZxdXindienimpOh8AEP44RJtDPsngrQTWCdipAq0&amp;amp;_tunervar_width=640&amp;amp;_tunervar_fbApiKey=ca44798cf7067942a82579c2c720f7dd&amp;amp;_tunervar_sport=443&amp;amp;_tunervar_proxyPort=80&amp;amp;_tunervar_skin=pandora&amp;amp;_tunervar_amazonaffiliateid=savagebeast-20&amp;amp;_tunervar_height=630&amp;amp;_tunervar_shost=www.pandora.com&amp;amp;_tunervar_st=1&amp;amp;_tunervar_autocompleteHost=autocomplete.pandora.com&amp;amp;_tunervar_autocompletePort=80&amp;amp;_tunervar_zone=prod" align="" width="640" height="630"&gt;&lt;/embed&gt;&lt;br /&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2270034590797592412-5202214434603901529?l=cbisnett.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cbisnett.blogspot.com/feeds/5202214434603901529/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2270034590797592412&amp;postID=5202214434603901529&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/5202214434603901529'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/5202214434603901529'/><link rel='alternate' type='text/html' href='http://cbisnett.blogspot.com/2010/06/decompressing-flash-files.html' title='Decompressing Flash Files'/><author><name>Chris Bisnett</name><uri>http://www.blogger.com/profile/03986163301678844575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/__inZIgDzfJ4/TCd_T5Ub9xI/AAAAAAAAABI/96CZiXoBwck/s72-c/compressed.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2270034590797592412.post-7295351207856244897</id><published>2008-06-20T18:10:00.000-07:00</published><updated>2008-06-21T11:26:47.665-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='catalyst'/><category scheme='http://www.blogger.com/atom/ns#' term='ati'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='fedora 9'/><category scheme='http://www.blogger.com/atom/ns#' term='x86_64'/><title type='text'>Catalyst 8.6 on Fedora 9 x86_64</title><content type='html'>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For those of us with ATI video cards running Linux, ATI is supporting us with a Linux version of their Catalyst drivers.&amp;nbsp;&amp;nbsp;They can be downloaded by going to the &lt;a href="http://ati.amd.com/support/driver.html"&gt;ATI driver download page&lt;/a&gt; and selecting Linux x86_64 and the video card make and model.&amp;nbsp;&amp;nbsp;From there you can download the self-extracting archive which will either install the driver or build a package.&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;It is always a good idea to install from a package since they are easier to update and remove than by hand.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Unfortunately there are a few errors in the package and it will not build correctly on Fedora 9.&amp;nbsp;&amp;nbsp;I was able to fix these errors and get the package to build although, I cannot use the driver since it has not been updated to work with the XOrg server contained in the Fedora 9 distro.  But downgrading the XOrg server is another post.&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Once you have downloaded the self-extracting archive we must extract the files so that we can patch them.&amp;nbsp;&amp;nbsp;To do this we use the --extract option of the archive.&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;./ati-driver-installer-8-6-x86.x86_64.run --extract ati&lt;/div&gt;&lt;/div&gt;Now that the files are extracted we must patch the .spec file that is used to specify the package build instructions.&amp;nbsp;&amp;nbsp;Use &lt;a href="http://www.box.net/shared/xfe2gqa04c"&gt;ATI-fglrx.spec-tmpl.patch&lt;/a&gt; to patch the file fixing errors with files being included in the package but not listed as part of the installed files as well as an invalid changelog entry.&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;patch ./ati/packages/Fedora/ATI-fglrx.spec-tmpl &amp;lt; ./ATI-fglrx.spec-tmpl.patch&lt;/div&gt;&lt;/div&gt;Next we must patch the a script used to create the directory structure for the package.  There were some issues with the directories for the x86_64 build.&amp;nbsp;&amp;nbsp;&lt;a href="http://www.box.net/shared/87v5rbbk8w"&gt;ati-packager.sh.patch&lt;/a&gt; will fix these errors allowing the package to build.&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;patch ./ati/packages/Fedora/ati-packager.sh &amp;lt; ./ati-packager.sh.patch&lt;/div&gt;&lt;/div&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Now that the files have been patched we can now build the package.&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;cd ati&lt;/div&gt;&lt;div class="command"&gt;./ati-installer.sh 8-6 --buildpkg Fedora/F9&lt;/div&gt;&lt;/div&gt;If all works out as planned you should see messages about 5 different packages created.  Congratulations you have successfully build the Fedora 9 package!  Now you can use yum to install the packages.&lt;div class="commandGroup"&gt;&lt;div class="command"&gt;su&lt;/div&gt;&lt;div class="command"&gt;yum localinstall --nogpgcheck ATI-fglrx-8.501-1.f9.x86_64.rpm&lt;/div&gt;&lt;div class="command"&gt;yum localinstall --nogpgcheck ATI-fglrx-control-center-8.501-1.f9.x86_64.rpm&lt;/div&gt;&lt;div class="command"&gt;yum localinstall --nogpgcheck ATI-fglrx-IA32-libs-8.501-1.f9.x86_64.rpm&lt;/div&gt;&lt;div class="command"&gt;yum localinstall --nogpgcheck kernel-module-ATI-fglrx-2.6.25.4-30.fc9.x86_64-8.501-1.f9.x86_64.rpm&lt;/div&gt;&lt;div class="command"&gt;exit&lt;/div&gt;&lt;/div&gt;*Note - The ATI-fglrx-devel-8.501-1.f9.x86_64.rpm file is only required for development.&lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;As I said at the beginning of the post even after successfully building the Fedora 9 package, it will not work on the default Fedora 9 distro.&amp;nbsp;&amp;nbsp;For the driver to work the XOrg server must be downgraded.&amp;nbsp;&amp;nbsp;I have seen a few guides that describe how to downgrade the XOrg server to the version that came with Fedora 8 but I have not yet attempted this myself.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2270034590797592412-7295351207856244897?l=cbisnett.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cbisnett.blogspot.com/feeds/7295351207856244897/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2270034590797592412&amp;postID=7295351207856244897&amp;isPopup=true' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/7295351207856244897'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/7295351207856244897'/><link rel='alternate' type='text/html' href='http://cbisnett.blogspot.com/2008/06/catalyst-86-on-fedora-9-x8664.html' title='Catalyst 8.6 on Fedora 9 x86_64'/><author><name>Chris Bisnett</name><uri>http://www.blogger.com/profile/03986163301678844575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2270034590797592412.post-5412199670192301454</id><published>2008-06-08T10:25:00.000-07:00</published><updated>2008-06-21T11:59:08.643-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='dual boot'/><category scheme='http://www.blogger.com/atom/ns#' term='linux'/><category scheme='http://www.blogger.com/atom/ns#' term='windows'/><category scheme='http://www.blogger.com/atom/ns#' term='mbr'/><title type='text'>Fixing the MBR</title><content type='html'>&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;This weekend I decided that I was going to load Fedora 9 onto my laptop and dual boot with Windows XP.&amp;nbsp;&amp;nbsp;First of all I have a Toshiba Satellite A305-S6843 which is a great laptop and has never given me any problems.&amp;nbsp;&amp;nbsp;I comes with an Intel T8100 (2.1 GHz), 4 GB RAM, 2x200 GB HD and an ATI Mobility Radeon HD 3470.&amp;nbsp;&amp;nbsp;It originally came with Windows Vista but after only a month I was fed up with it and paid the $140 for the OEM Windows XP Pro x64.&amp;nbsp;&amp;nbsp;I installed XP on the first 200GB HD leaving the second hard drive open.&amp;nbsp;&amp;nbsp;So this weekend I decided that I would load Fedora 9 onto the second hard drive.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;After much frustration and searching (thats another story) I was able to get the live fedora 9 CD to boot and installed the OS that way.&amp;nbsp;&amp;nbsp;Apparently I wasn't paying attention and told it to install grub on the boot sector for the second drive.&amp;nbsp;&amp;nbsp;So when I restarted it booted directly into windows as if nothing had happened.&amp;nbsp;&amp;nbsp;I was able to press F12 and use the BIOS's built-in boot manager to select the second hard drive and boot into linux that way.&amp;nbsp;&amp;nbsp;For a while that was fine but then I decided that I would load grub into the MBR so that I could easily select which OS to boot.&amp;nbsp;&amp;nbsp;I did it using the grub-install command&lt;div class="commandGroup command"&gt;grub-install /dev/sda1&lt;/div&gt;Oops!&amp;nbsp;&amp;nbsp;I just overwrote the boot sector of the windows partition.&amp;nbsp;&amp;nbsp;Consequently this also made it impossible to mount the ntfs partition or boot at all.&amp;nbsp;&amp;nbsp;When trying to boot the MBR all that was displayed was 'GRUB'.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;At this point I was pretty sure that I had lost everything on the windows drive and would have to re-install Windows.&amp;nbsp;&amp;nbsp;I just happened to stumble across a post by a guy who had a similar problem and he described how he fixed it using the Windows 98 SE boot disk.&amp;nbsp;&amp;nbsp;This gave me the idea to use the Windows install CD and the recovery console.&lt;br /&gt;&lt;u&gt;Solution&lt;/u&gt;&lt;table border="0" cellpadding="0" cellspacing="10"&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 1:&lt;/td&gt;&lt;td&gt;Insert the Windows XP install CD and restart the computer.&lt;br /&gt;&lt;i&gt;If your computer uses SATA with AHCI you will either need to set it to compatability mode in the BIOS or create a slipstream disk with the SATA drivers&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 2:&lt;/td&gt;&lt;td&gt;When the setup finishes loading drivers it will ask you if you want install the Windows XP operating system or if you want to use the Recovery console.&amp;nbsp;&amp;nbsp;Press R to enter the recovery console.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 3:&lt;/td&gt;&lt;td&gt;Use the fixmbr command to fix the master boot record.&lt;div class="commandGroup command"&gt;fixmbr&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 4:&lt;/td&gt;&lt;td&gt;Use the fixboot command to fix the boot sector of the drive.&lt;div class="commandGroup command"&gt;fixboot c:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 5:&lt;/td&gt;&lt;td&gt;Exit the Recover console to restart the computer.&lt;div class="commandGroup command"&gt;exit&lt;/div&gt;&lt;i&gt;If you set the SATA to compatability don't forget to set it back in the BIOS.&lt;/i&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top; vertical-align: top;"&gt;Step 6:&lt;/td&gt;&lt;td&gt;Boot into Linux and bring up the terminal.&amp;nbsp;&amp;nbsp;Run the grub console.&lt;div class="commandGroup command"&gt;grub&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 7:&lt;/td&gt;&lt;td&gt;Set the root linux partition using the root command.&amp;nbsp;&amp;nbsp;The root partition is set using the hard drive number.&amp;nbsp;&amp;nbsp;For my system linux was installed on the second hard drive (hd1) and the first partition on that hard drive (0).&lt;div class="commandGroup command"&gt;root (hd1,0)&lt;/div&gt;You'll know you selected the correct partition when the grub console responds telling you it found the filesystem ext2fs.&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 8:&lt;/td&gt;&lt;td&gt;Tell grub to setup the MBR.&lt;div class="commandGroup command"&gt;setup (hd0)&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td style="white-space: nowrap; vertical-align: top;"&gt;Step 9:&lt;/td&gt;&lt;td&gt;The /etc/grub/grub.conf file will probably need to be edited to reflect the correct hard drives and paths.&amp;nbsp;&amp;nbsp;I am not going to get into this here because there are plenty of tutorials on the internet about how to do this.&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;That should allow you to use grub to boot into both Windows XP and Linux.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/2270034590797592412-5412199670192301454?l=cbisnett.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://cbisnett.blogspot.com/feeds/5412199670192301454/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=2270034590797592412&amp;postID=5412199670192301454&amp;isPopup=true' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/5412199670192301454'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2270034590797592412/posts/default/5412199670192301454'/><link rel='alternate' type='text/html' href='http://cbisnett.blogspot.com/2008/06/fixing-mbr.html' title='Fixing the MBR'/><author><name>Chris Bisnett</name><uri>http://www.blogger.com/profile/03986163301678844575</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>
