Jump to content











Photo
- - - - -

Hddimage - Batch command to create a hard disk image


  • Please log in to reply
38 replies to this topic

#26 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 28 June 2010 - 08:58 AM

I know I might be asking a little bit too much, but how difficult would it be to add a command line switch to create a "contiguous image" as opposed to just "an image" (possibly fragmented) ? (NB: I am really asking about the feasibility, not about who, when, etc... :cheers: )

That would be very useful, e.g. when booting direct from the file with GRUB4DOS instead of booting from RAM. Obviously it is always possible to defragment the image with contig, but I thought it would be nicer to make sure it is contiguous in the first place...

More generally, when copying an image file from A to B, is there anyway to ask windows to make sure the destination is not fragmented ? or any utility like xxcopy that can do so ?


Not that I know of, but one could call CONTIG from the batch:

....
MOVE /Y HDDIMAGE.$$$ "%~nx1"
CONTIG "%~nx1"
MOVE /Y HDIMGPLN.$$$ "%~n1.PLN"
....


Another possibility is to create the file contiguous:
http://technet.micro...s/bb897428.aspx

To make a new file that is defragmented upon creation, use Contig like this:

Usage: contig [-v] [-n filename length]


I see that oriensol creates the files as HDDIMAGE.$$$ and then MOVEs it:

...

"%~dp0fsz.exe" HDDIMAGE.$$$ %Filesize% > nul
"%~dp0dsfi.exe" HDDIMAGE.$$$ 0 512 "%~dp0MBRFILE.$$$" > nul
CALL :MAKEPLN "%Targetfile%" HDIMGPLN.$$$
IF EXIST "%~nx1" ECHO Deleting %1
MOVE /Y HDDIMAGE.$$$ "%~nx1"
MOVE /Y HDIMGPLN.$$$ "%~n1.PLN"
ECHO.
ECHO Created hard-disk image %1 (Size=%Filesize%, Sectors=%TotSectors%, Cylinders=%MAXCyl%)
...


I am not seeing the reason for this, but this could work B):

...

%~d1
cd %~p1
"%~dp0contig.exe" -n HDDIMAGE.$$$ %Filesize% > nul
"%~dp0dsfi.exe" HDDIMAGE.$$$ 0 512 "%~dp0MBRFILE.$$$" > nul
CALL :MAKEPLN "%Targetfile%" HDIMGPLN.$$$
IF EXIST "%~nx1" ECHO Deleting %1
REN /Y HDDIMAGE.$$$ "%~nx1"
REN /Y HDIMGPLN.$$$ "%~n1.PLN"
ECHO.
ECHO Created hard-disk image %1 (Size=%Filesize%, Sectors=%TotSectors%, Cylinders=%MAXCyl%)
...

REN and MOVE should be equivalent in this usage.


:cheers:
Wonko

#27 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 28 June 2010 - 09:44 AM

Thanks Wonko.

The move (vs. ren) just happened :cheers: No special reason.

Is contig redistributable?

#28 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 28 June 2010 - 10:06 AM

Is contig redistributable?


Is there ANY doubt about it? :cheers:
EULA.TXT:

....
2. SCOPE OF LICENSE. The software is licensed, not sold. This agreement only gives you some rights to use the software. Sysinternals reserves all other rights. Unless applicable law gives you more rights despite this limitation, you may use the software only as expressly permitted in this agreement. In doing so, you must comply with any technical limitations in the software that only allow you to use it in certain ways.

You may not:

* work around any technical limitations in the binary versions of the software;
* reverse engineer, decompile or disassemble the binary versions of the software, except and only to the extent that
applicable law expressly permits, despite this limitation;
* make more copies of the software than specified in this agreement or allowed by applicable law, despite this limitation;
* publish the software for others to copy;
* rent, lease or lend the software;
* transfer the software or this agreement to any third party; or
* use the software for commercial software hosting services.
...


BUT, Wincontig is :cheers: AND it allows for command line usage:
http://wincontig.mdtzone.it/en/faq.htm
only it cannot create the fie and thus can be used as a "post-processor" ONLY :cheers:.

Cannot say if there is anything else capable of creating a contiguous file. B)

B)
Wonko

#29 Doodoo

Doodoo

    Frequent Member

  • Advanced user
  • 345 posts

Posted 28 June 2010 - 10:17 AM

Thanks Wonko for the great research !
Here is how I see it:

  • Why not distribute wincontig with HDDimage
  • If a non-fragmented image is required with /contiguous then:
  • Check if contig.exe is available on the path. If so, use it to create a contiguous image.
  • If not available, fall back to use wincontig, and defrag the created image


#30 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 28 June 2010 - 10:17 AM

I guess the best solution is to use contig, if it is available! That way, the user can download contig to get the feature, which can be enabled by default.

Not sure what happens though, if there isn't enough contiguous free space.

By the way, I haven't always had success with contig/wincontig in getting a continguous file defragmentation, even though space was available.

#31 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 28 June 2010 - 12:10 PM

I thought I will check out contig -n.

I could create a 'contiguous file' larger than the available free space in the partition! I would prefer to leave the situation as is! :cheers:

#32 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 28 June 2010 - 02:12 PM

Well, you could "forcefully" defrag the whole drive before running the .cmd, but wouldn't that fall in the "automagically" that our friends at MS so much love? B)

Checking if there is enough free space before creating the file is trivial, that's not the problem, but actually understanding IF running contig or wincontig will properly create a defragged, contiguous file is more like gambling. :cheers:


:fine:
Wonko

#33 DarkPhoeniX

DarkPhoeniX

    Frequent Member

  • Team Reboot
  • 452 posts
  • Location:In the middle of nowhere
  • Interests:Interesting Things
  •  
    South Africa

Posted 12 August 2010 - 03:45 AM

Here is a mod to the files to easily run the the oriensol's hddimage.cmd batch script
im not a expert script-er but my mod works
it will automatically mount the drive image too
Just run the "easyrun.bat"
all needed files is included

This is a launcher by FireBloodPhoenix



Adapted from Jaclaz's mbrbatch/mkimg batches

To be run with oriensol's hddimage.cmd batch script

This script was made to be mainly used for the 

MS_DaRT erd05 (winXP_86x) .dsk image,for grub4dos

The drive Will mount on Q; only!

The Drive will be formated in NTFS

Only tested on Windows XP Runtime
Download it here:
http://www.mediafire...8dudff1p4w7573w

#34 oriensol

oriensol

    Frequent Member

  • Advanced user
  • 216 posts
  •  
    India

Posted 10 November 2010 - 09:14 PM

Updated first post with link to download the version 6 file from mediafire.

#35 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 19 February 2011 - 08:57 AM

Attached a 0.7 version ALPHA with code to generate a random disk signature.

Talked about here:
http://reboot.pro/13731/page__st__174

Edited to remove version 0.7 ALPHA, see below for version 0.8.

:confused1:
Wonko

#36 L A M A

L A M A

    Silver Member

  • Advanced user
  • 540 posts
  •  
    United Nations

Posted 19 February 2011 - 01:54 PM

all right... :confused1: i think i've a huge collection of these...

#37 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 19 February 2011 - 05:51 PM

HOLD YOUR HORSES!

ANY version of hddimage up to and including version 0.07 ALPHA is poorly written :angry7: and NOT properly verified :mellow:.

It will give WRONG CHS Ecyl for anything above roughly 2 Gb. ;)

Details are given starting here:
http://reboot.pro/13731/page__st__243

Attached version 0.08 UNofficial ALPHA, with the above issue hopefully fixed :crazyrocker: .

:(
Wonko

Attached Files



#38 pscEx

pscEx

    Platinum Member

  • Team Reboot
  • 12707 posts
  • Location:Korschenbroich, Germany
  • Interests:What somebody else cannot do.
  •  
    European Union

Posted 19 February 2011 - 08:09 PM

@Wonko

I use your batch succesfully in one of my scripts since a long time. :crazyrocker:
(I never tried to understand the batch, and because I currently do not have the magic crystal ball, I do not know why the batch works for me ... :mellow: )
Can you please tell me, whether (and if yes, why) it is reasonable to have the disk signature in a HDD image added to a WinBuilder created PE?

Peter ;)

#39 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 16066 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 19 February 2011 - 08:13 PM

@Wonko

I use your batch succesfully in one of my scripts since a long time. :crazyrocker:
(I never tried to understand the batch, and because I currently do not have the magic crystal ball, I do not know why the batch works for me ... :mellow: )
Can you please tell me, whether (and if yes, why) it is reasonable to have the disk signature in a HDD image added to a WinBuilder created PE?

Peter ;)

WHICH BATCH?

hddimage is NOT mine (and it was ALSO wrong - for partitions above a given size - till a few minutes ago).

As soon as a volume on a disk is accessed/mounted by a 2K/XP or later, IF there is NO Disk Signature, THEN one is created and written to it, so in most cases it is NOT a problem.

In some it is, see the referenced thread where the problem was pointed out:
http://reboot.pro/13731/page__st__174

:(
Wonko




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users