From owner-freebsd-questions@FreeBSD.ORG Fri Nov 2 18:19:17 2012 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 5FD6B84D for ; Fri, 2 Nov 2012 18:19:17 +0000 (UTC) (envelope-from bourne.identity@hotmail.com) Received: from blu0-omc3-s4.blu0.hotmail.com (blu0-omc3-s4.blu0.hotmail.com [65.55.116.79]) by mx1.freebsd.org (Postfix) with ESMTP id 145858FC08 for ; Fri, 2 Nov 2012 18:19:16 +0000 (UTC) Received: from BLU0-SMTP96 ([65.55.116.74]) by blu0-omc3-s4.blu0.hotmail.com with Microsoft SMTPSVC(6.0.3790.4675); Fri, 2 Nov 2012 11:19:10 -0700 X-Originating-IP: [223.181.226.187] X-EIP: [SVmYdFADOHNQQiMQ6b4GUdmyCFvLVCBfrdRfzebv2L4=] X-Originating-Email: [bourne.identity@hotmail.com] Message-ID: Received: from [127.0.0.1] ([223.181.226.187]) by BLU0-SMTP96.blu0.hotmail.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Fri, 2 Nov 2012 11:19:04 -0700 Date: Fri, 2 Nov 2012 23:48:51 +0530 From: Manish Jain User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20120907 Thunderbird/15.0.1 MIME-Version: 1.0 To: Leslie Jensen Subject: Re: My freebsd partition changed by Windows chkdsk (Leslie Jensen) References: <5093CF85.4080708@eskk.nu> In-Reply-To: <5093CF85.4080708@eskk.nu> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 02 Nov 2012 18:19:10.0236 (UTC) FILETIME=[8DCA65C0:01CDB926] Cc: freebsd-questions@freebsd.org X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Nov 2012 18:19:17 -0000 On 02-Nov-12 19:19, Leslie Jensen wrote: > > > Manish Jain skrev 2012-11-02 14:39: >>> That I trusted the chkdsk program to do what I told it to do was in >>> retrospect a bit naive ;-) I do have a backup although it's not as >>> recent as I would have liked. >>> >>> Can you think of any way to perhaps recover the data from the freebsd >>> partition? >> >> I trust that you by now have discovered that your trust was never >> breached >> by Microsoft (for once). Microsoft firmly believes that Windows is >> the only >> OS that should reside on a PC's disk. Therefore running chkdsk with >> force >> was only an invitation to Microsoft to run amok. >> >> BTW, the reason I replied to this message was not to provide you with a >> solution but with a trivial yet good bit of precaution I use on my own >> dual-boot PC, wherein ad4s1 is NTFS/Windows and ad4s2 is my FreeBSD >> slice. >> Right after installation of FreeBSD, I ran : >> >> dd if=/dev/ad4 of=ad4.512 bs=512 count=1 >> dd if=/dev/ad4s2 of=ad4s2.512 bs=512 count=1 >> dd if=/dev/ad4s2a of=ad4s2a.512 bs=512 count=1 >> >> No matter how Windows screws up the MBR or FreeBSD's slice, >> recovering from >> the situation is simple enough. >> >> Regards >> >> Manish Jain >> bourne.identity@hotmail.com >> >> >> _______________________________________________ >> freebsd-questions@freebsd.org mailing list >> http://lists.freebsd.org/mailman/listinfo/freebsd-questions >> To unsubscribe, send any mail to >> "freebsd-questions-unsubscribe@freebsd.org" > > > Thank you for your comment. > I must admit that I do not fully understand what it is you do. > Will you explain the details, Please? > Thanks > /Leslie > > Hello Leslie, Sorry if my comment sounded a bit cryptic. The first 512 bytes of any hard-disk reside outside of any slice and contain the master boot record. If you installed Windows first and FreeBSD second and opted for the FreeBSD (a.k.a. Easy) Boot Manager, the disk's first 512 bytes will contain 446 bytes of Boot Manager code (which the BIOS executes to give you the F1/F2/F3/F4 choices), 64 bytes containing the disk's slice layout (maximum 4 slices) and 2 bytes for a BIOS checksum. It is very easy to lose the MBR. If, instead of chkdsk, you were to run the fixmbr command, Windows will put its own code into the 446 bytes. That code is capable of only one thing - booting drive C: When you ran chkdsk /f, Windows changed the slice-type of your FreeBSD slice from FFS (ID=165) to NTFS (ID=7) in the MBR. Only Microsoft knows why chkdsk is permitted to do that. Once that happens, you would REALLY like to fix the MBR. One way to do it is to to run the reverse of the first command : dd if=ad4.512 of=/dev/ad4 bs=512 count=1 This assumes 1) you can boot into FreeBSD or Linux or have a GParted bootable CD, and 2) you saved your original MBR as ad4.512 and have access to it, possibly on a USB pendrive that you can mount. Just as the disk's first 512 bytes reside outside of any slice, every slice's first 512 bytes reside outside any partition in that slice and consequently outside the filesystems in that slice. This sector contains the boot code (a.k.a. boot record) needed to boot the OS on that slice. Windows will generally be nice enough to first read the boot.ini file, which gives us the option of booting FreeBSD from Windows' boot.ini : dd if=/dev/ad4s2 of=ad4s2.512 bs=512 count=1 Copy out ad4s2.512 to drive C:, and put this in your boot.ini : c:\ad4s2.412="Boot FreeBSD instead" Of course, you have to substitute your correct numbers in the ads{N} notation. For me, is 4 and {N} is 2. The ad4s2a.512 file contains the first sector in your FreeBSD / partition and is meaningful to the loader more than to us mortals. If everything else fails, you might like to give the following a try : 1) Boot from your FreeBSD CD/DVD, enter the slice editor and change the type of your FreeBSD slice back to 165. Do not press Q. Press W instead. Conform with Yes to the warning, and then press Ctrl+Alt+Del to abort the installation. 2) Boot from your FreeBSD CD/DVD again, and run boot0cfg -B in an emergency shell. I hope my message sounds less cryptic now. I personally don't have anything against running chkdsk or fixmbr, AS LONG AS I have backed up the important sectors. Regards Manish Jain bourne.identity@hotmail.com