MSFN Forum: Diskpart recognizes disks differently - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Diskpart recognizes disks differently Rate Topic: -----

#1 User is offline   jmueske 

  • Group: Members
  • Posts: 3
  • Joined: 07-April 08

Posted 07 April 2008 - 04:52 PM

I'm using a UFD (USB Flash Drive) with WinPE 2.0 and ImageX to deploy an XPe image. Here's what I'm doing:

1) Install UFD and SATA hard disk into system with power off.
2) Power on and boot PC to BIOS boot drive menu with F12, select UFD with WinPE 2.0 (both SATA drive and UFD are considerd hard drives by the BIOS).
3) Use diskpart to prepare hard disk:
diskpart /s d:\script.txt

select disk 0
clean
create partition primary
select partition 1
active
exit

4) format c: /fs:ntfs /y /v:harddisk
5) d:\imagex.exe /apply d:\filename.wim 1 c:

I run into a problem when using a brand new harddisk compared to a previously initialized harddisk. Diskpart sees a previously initialized harddisk as "drive 0" and the UFD is "drive 1". Diskpart sees only the UFD as a "drive 0" when a brand new empty harddisk is installed. As you can imagine this messes up my diskpart script because it wipes my UFD clean when a new hard disk is installed.

Can I get diskpart to look at both drive states the same way without externally initializing each harddisk? Ideally my scripts can "autosense" the harddisk in both drive conditions and work properly accordingly. Any ideas?

Regards,
John

This post has been edited by jmueske: 21 May 2008 - 02:54 PM



#2 User is offline   zorphnog 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 427
  • Joined: 25-July 06

Posted 08 April 2008 - 07:11 AM

This has been covered many times. Search: +diskpart +script

#3 User is offline   jmueske 

  • Group: Members
  • Posts: 3
  • Joined: 07-April 08

Posted 21 May 2008 - 01:23 PM

Thanks for the tip. I've literally searched for hours and while I can find other diskpart issues, I cannot find one similar to my own. Can someone point me in the right direction, perhaps with a specific post?

Regards,
John

This post has been edited by jmueske: 21 May 2008 - 01:27 PM


#4 User is offline   WreX 

  • Junior
  • Pip
  • Group: Members
  • Posts: 84
  • Joined: 26-October 07

Posted 22 May 2008 - 09:45 AM

You could use a batch or similar file to utilize diskpart scripting to find what disk # your hard drive or UFD device is and create your clean and partition script accordingly. The easiest way is if you know the size of your UFD device will always be the same. Then you could:

1. Run a diskpart script that runs the "list disk" command and read the output
2. Look for the line with the size value of your UFD device, and find the "Disk #" value for that device
3. Create the diskpart script to clean and partition using the other disk #

Here's an example of a batch file for a 256MB UFD that shows up as 246MB in diskpart:
 
echo list disk > X:\ListDisk.txt
FOR /F "tokens=2,4" %%i IN ('diskpart /s X:\ListDisk.txt') DO @IF /i %%j == 246 SET UFDDISK=%%i
IF DEFINED UFDDISK IF %UFDDISK%==0 SET THEDISK=1
IF DEFINED UFDDISK IF %UFDDISK%==1 SET THEDISK=0
IF DEFINED UFDDISK echo select disk %THEDISK% > X:\PartHD.txt
IF DEFINED UFDDISK echo clean >> X:\PartHD.txt
...
IF DEFINED UFDDISK diskpart /s X:\PartHD.txt 


Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy