delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/05/03/11:56:26

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <42779F1A.70005@hones.org.uk>
Date: Tue, 03 May 2005 16:56:10 +0100
From: Cliff Hones <cliff AT hones DOT org DOT uk>
User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: impossible to restore MBR using dd
References: <42778C30 DOT 4000909 AT echotech DOT ch> <427792D7 DOT 8030605 AT hones DOT org DOT uk> <42779CFC DOT 7020502 AT echotech DOT ch>
In-Reply-To: <42779CFC.7020502@echotech.ch>
X-IsSubscribed: yes

Matthias Bertschy wrote:
> Cliff Hones wrote:
> 
>> Matthias Bertschy wrote:
>> 
>>> Hello,
>>>
>>> Cygwin version: 1.5.12
>>> Windows XP Professional: Ver 5.1 Build 2600 Service Pack 2
>>>
>>> I am trying to use Cygwin's dd command as a post Windows XP install
>>> command to restore our custom GRUB to the MBR after an unattended
>>> installation.
>>> For safety reasons, I would like to restore only the first 446 bytes of
>>> the MBR to keep the existing partition table.
>>>
>>> The command line to use would normally be:
>>>   dd if=boot.MBR of=/dev/sda bs=446 count=1
>>> -->    dd: writing '/dev/sda': No space left on device
>>>         1+0 records out
>>>         0+0 records in
>>> (I also tried with bs=512 and I get the same output)
>>>
>>> After reading:
>>> http://sourceware.org/ml/cygwin/2001-01/msg00193.html
>>> I decided to try the following:
>>>   mount -s -b -f //./physicaldrive0 /dev/hd00
>>>   dd if=boot.MBR of=/dev/hd00 bs=446 count=1
>>> -->   dd: opening '/dev/hd00': Invalid argument
>>> (even if I change the device /dev/xxx name, I get the same output)
>>>
>>> I even tried directly:
>>>   dd if=boot.MBR of=//./physicaldrive0 bs=446 count=1
>>> -->   dd: opening '//./physicaldrive0': Invalid argument
>>>
>>> After so many unefficient tries, I decided to read from it, just to see:
>>>   dd if=//./physicaldrive0 bs=446 count=1
>>> -->   dd: reading '//./physicaldrive0': Is a directory
>>>         0+0 records out
>>>         0+0 records in
>>>
>>> So here is the:
>>>   QUESTION1: Does anyone know how to write into MBR from Windows XP
>>> using Cygwin's dd ?
>>>   QUESTION2: I am doing somathing wrong since dd sees
>>> //./physicaldrive0 as a directory ?
>>>
>>> Any help would be appreciated.
>>
>> Using /dev/sda should work.
>>
>> -- Cliff
>>
> Hello Cliff,
> 
> Thanks for your help... However, if you read carefully the beginning of
> the mail, that's the first thing I tried:
> 
> The command line to use would normally be:
>   dd if=boot.MBR of=/dev/sda bs=446 count=1
> -->    dd: writing '/dev/sda': No space left on device
>         1+0 records out
>         0+0 records in
> 
> I don't really understand why there is "No space left on device"... the
> same command under Linux works like a charm.
> 
> If anyone else has got an idea?

I gave it a quick test with bs=512 and it works fine.  It seems you can't
write partial sectors - which is perfectly reasonable, as if allowed
the driver would have to read the sector, update part and then write back.

So I suggest you try the following:

 dd if=/dev/sda of=bootsect bs=512 count=1
 dd if=boot.MBR of=bootsect bs=1 count=446
 dd if=bootsect of=/dev/sda bs=512 count=1

-- Cliff

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019