Jump to content

Welcome to MSFN Forum
Register now to gain access to all of our features. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more. This message will be removed once you have signed in.
Login to Account Create an Account


Photo

Diskpart error when imaging Win7

diskpart win7 imaging

  • Please log in to reply
5 replies to this topic

#1
ImageN00B

ImageN00B
  • Member
  • 2 posts
  • OS:Windows 7 x86
  • Country: Country Flag

I am attempting to run a light-touch to unattended imaging process from a USB, however i run into an error.

 

I am running an error during the assignment of a drive letters several lines into my batch script.

I have a 2 part imaging system that i call a batch file, and it runs through and is supposed to apply my wim as an image.

 

During the part that it calls to for diskpart as part of my imaging i get an error.

 

The initial batch is as follows:

 

diskpart /s part2.txt

copy u:\test.wim d:

x:\imagex.exe /apply d:\test.wim 1 d:

d:\windows\system32\bcdboot d:\windows

exit

 

During the diskpart it calls to a text file for the diskpart commands noting:

 

select disk 0

clean

create partition primary size=80

select partition 1

format fs=ntfs label="system" quick

assign letter=C

active

create partition primary

select partition 2

format fs=ntfs label="windows" quick

assign letter=D

select disk 1

select partition 1

assign letter=U

exit

 

It goes throught the script all the way until it tries to assign drive letter D, then it throws an error.

 

Virtual Disk Service error:

The specified drive letter is not free to be assigned.

 

Thusly bunking my entire automation.

 

Everything works flawlessly if i run the entire diskpart section by hand, however it will not work in a diskpart batch.

 

HELP!?!?!

 

 

 

 




How to remove advertisement from MSFN

#2
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,385 posts
  • OS:none specified
  • Country: Country Flag
It is not at all clear to me your setup and the actual disk order.
And it seems to me like you are installing the Windows to the D: drive (while normally this is done to the C: one).

Can you try to explain/detail the general idea and setup?

If you boot from the USB, normally that device would be disk 0 (first disk) and the internal disk would be "shifted" to disk 1 but disk order in PE's is somewhat not "reliable", disk order (and consequently drive lettering) may change.

It is very possible that this happens, as a rule of thumb it would be "better" to check the environment (and disk order and drive letters already assigned) at the time you run diskpart.exe.

Something *like* this:
http://www.msfn.org/...to-your-liking/
http://www.msfn.org/...etter-shifting/
is normally useful.

As a side note (and only marginal) there is no need to have a separate diskpart script, it is possible to embed it in the same batch file, see (JFYI):
http://www.msfn.org/...-file/?p=817142
http://www.msfn.org/...-file/?p=817388


jaclaz

#3
ImageN00B

ImageN00B
  • Member
  • 2 posts
  • OS:Windows 7 x86
  • Country: Country Flag

I'll clarify...

 

I created a WAIK-based WINPE bootable UDF to USB, i placed my two scripts onto the USB, along with my image (captured) WIM file.

 

So i'm booting to the USB, and by default from what i'm seeing on 5 different computers, is that setting the booting the USB as DISK 1, by the configs of the WINPE.

 

I run the batch at launch by typing in "part1" which executes the batch file.

Line 1 of the file calls to the DISKPART script, but by the time it attempt to quick format the drive and assign it as "D", it reboots.

(I have no idea why, as i've not called to do so in the script)

 

If i follow the scripts line for line, it works perfectly. If i execute the batch, it blows up and reboots to the computers.

I REALLY don't want to have to do this manually, as everything i've seen online says you can do this through scripts.

 

I'm just not seeing it.

HELP!?!?



#4
jaclaz

jaclaz

    The Finder

  • Developer
  • 14,385 posts
  • OS:none specified
  • Country: Country Flag

Good, but still you didn't answer my questions.

Is there a specific reason why you want/need to install the windows on "D:"?

 

Anyway, when you have this kind of strange issues, try to separate things as much as possible (there will be time enough later to re-assemple them together) and insert in the middle some checks.

Example:



diskpart /s clean.txt
ECHO clean.txt ran
mountvol | FIND ":\"
PAUSE
diskpart /s part11.txt
ECHO part11.txt ran
mountvol | FIND ":\"
PAUSE
diskpart /s part01.txt

ECHO part01.txt ran
mountvol | FIND ":\"
PAUSE
diskpart /s part02.txt

ECHO part02.txt ran
mountvol | FIND ":\"
PAUSE
copy u:\test.wim d:
x:\imagex.exe /apply d:\test.wim 1 d:
d:\windows\system32\bcdboot d:\windows
exit

clean.txt:



select disk 0
clean
exit

part11.txt



select disk 1
select partition 1
assign letter=U
exit

part01.txt:



select disk 0
create partition primary size=80
select partition 1
format fs=ntfs label="system" quick
assign letter=C
active
exit

part02.txt:



select disk 0
create partition primary
select partition 2
format fs=ntfs label="windows" quick
assign letter=D
exit

And see what happens.

 

Notwithstanding your successful experiments, if not downright criminal :w00t: :ph34r:  I find EXTREMELY dangerous to select a disk and "clean" it with diskpart in an automated setup without first checking if it is the "right" disk :whistle:.

 

jaclaz



#5
gustavo21

gustavo21

    Newbie

  • Member
  • 25 posts
  • OS:Windows 7 x86
  • Country: Country Flag

Good, but still you didn't answer my questions.

Is there a specific reason why you want/need to install the windows on "D:"?

 

 

Hi! I allways install Windows in C:, never did de system part.

 

Basicaly, i do this:

 

diskpart

sel disk 0

clean

create part pri

sel part 1

assign letter c:

active

exit

 

format c: /q /y /fs:ntfs /v:Windows

 

imagex /apply x:\windows.wim 1 c:

c:\windows\system32\bcdboot c:\windows /s c:

exit

 

 

Work great, never had a problem. I just have another script more complex because many notebooks have cdrom like disk 1 or some card reader also. 

 

Saludos!



#6
gustavo21

gustavo21

    Newbie

  • Member
  • 25 posts
  • OS:Windows 7 x86
  • Country: Country Flag

I think your problem is the computer, type list disk in diskpart and make sure you are selectic the correct disks.







Also tagged with one or more of these keywords: diskpart, win7, imaging

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users



How to remove advertisement from MSFN