/build/static/layout/Breadcrumb_cap_w.png
10/10/2019 101 views

I am having an issue when trying to image computers with SSD and SATA drives. When I run my image diskpart shows that disk0 is the SATA drive and disk1 is the SSD(M.2). I have made changes to the Create BIOS/UEFI Partitions to match my findings on the machine but the diskpart task seems to work but when it tries to apply the image it fails. I have also tried running the commands manually when the image apply task fails going step by step (same as the batch file) and it works fine so I know its not a syntax error. If I open the machine and disconnect the SATA drive and use the original Create BIOS/UEFI task it will image just fine because the system sets the SSD drive to disk0. Is anyone else have this issue and if so how did they fix it? Below is the pre-install task I am using.

Pre-Install Task

@echo off

wpeutil UpdateBootInfo

for /f "tokens=2* delims= " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET FIRMWARE=%%B

echo Firmware Type: %FIRMWARE%

echo Explanation of Firmware Type: (0x1 is BIOS, 0x2 is UEFI)

if %FIRMWARE%==0x1 goto BIOS

if %FIRMWARE%==0x2 goto UEFI

goto END


:UEFI

(

ECHO select disk 1

ECHO clean

ECHO convert gpt noerr

ECHO create partition efi size=200

ECHO assign letter=s

ECHO format quick fs=FAT32

ECHO Create partition msr size=128

ECHO create partition primary

ECHO assign letter=c

ECHO format quick fs=NTFS

ECHO exit

)>X:\Windows\System32\UEFI.txt

diskpart /s X:\Windows\System32\UEFI.txt

goto END


:BIOS

(

ECHO select disk 1

ECHO clean

ECHO create partition primary

ECHO select partition 1

ECHO assign letter=c

ECHO active

ECHO format quick fs=NTFS override

ECHO exit

)>X:\Windows\System32\BIOS.txt

diskpart /s X:\Windows\System32\BIOS.txt

goto END


:END



Answer Summary:
0 Comments   [ + ] Show comments

Comments


Answer Chosen by the Author

0

Ok so in case anyone was wondering I was able to figure it out after Kiyolaka brought to my attention to pause it and find out what was erroring out. Turns out the Disk 0 was being assigned C as a temp drive letter and it became an order of operations situation. What I needed to do was to format and assign a drive letter to Disk 0 before I did anything with Disk 1 and presto my machines' image to the SSD and the spindle disk gets formatted and partitioned as well. I have pasted the adjusted job below for others to reference. Thanks again to Kiyolaka for the help.

@echo off

wpeutil UpdateBootInfo

for /f "tokens=2* delims= " %%A in ('reg query HKLM\System\CurrentControlSet\Control /v PEFirmwareType') DO SET FIRMWARE=%%B

echo Firmware Type: %FIRMWARE%

echo Explanation of Firmware Type: (0x1 is BIOS, 0x2 is UEFI)

if %FIRMWARE%==0x1 goto BIOS

if %FIRMWARE%==0x2 goto UEFI

goto END


:UEFI

(

ECHO select disk 0

ECHO clean

ECHO convert gpt noerr

ECHO create partition primary

ECHO assign letter=e

ECHO format quick fs=NTFS

ECHO select disk 1

ECHO clean

ECHO convert gpt noerr

ECHO create partition efi size=200

ECHO assign letter=s

ECHO format quick fs=FAT32

ECHO Create partition msr size=128

ECHO create partition primary

ECHO assign letter=c

ECHO format quick fs=NTFS

ECHO exit

)>X:\Windows\System32\UEFI.txt

diskpart /s X:\Windows\System32\UEFI.txt

goto END


:BIOS

(

ECHO select disk 0

ECHO clean

ECHO convert gpt noerr

ECHO create partition primary

ECHO assign letter=e

ECHO format quick fs=NTFS

ECHO select disk 1

ECHO clean

ECHO create partition primary

ECHO select partition 1

ECHO assign letter=c

ECHO active

ECHO format quick fs=NTFS override

ECHO exit

)>X:\Windows\System32\BIOS.txt

diskpart /s X:\Windows\System32\BIOS.txt

goto END


:END

Answered 10/14/2019 by: rypalcovic
Yellow Belt

  • That works, another option (if you had to retain data) would be to edit the script slight with something like "IF EXIST "C:\" (echo REMOVE letter=C >X:\Windows\System32\BIOS.txt) And then change the larger portion to >>X:\Windows\System32\BIOS.txt so that it appends the text file rather then re-rwiting it.
    • Yes, that is good to know. Luckily I don't have to retain any data on PC labs.

Community Chosen Answer

3

That problem is at the BIOS level.  If the mechanical is in a lowered numbered sata socket then the SSD it will assume drive 0.  You can set the boot order in some bios's and also adjust the UEFI boot manager settings.  If these are dells the easiest thing to do is uncheck sata bus for the mechanical drive.  Do your imaging and then use the CCTK to reactivate that bus

Answered 10/10/2019 by: SMal.tmcc
Red Belt

  • I understand its a BIOS issue. The correction to my batch script compensates for that by changing it to disk 1 and not disk 0. The issue I am getting when I run it is that the diskpart runs so fast I can see if it errors and when I run a command to test if the partition is getting created it is not. Then I can run each individual command that I have in my batch script and it works flawlessly and then the task can be rerun for image apply and everything works fine. These are Dell machines but they are high-end XPS towers for our media department and I have not found anything in the BIOS that would indicate I can do either of your suggestions.
  • Maybe a custom Deployment with it's own formatting tasks and force it to the Apply Image task to target an specific disk??.....
  • This content is currently hidden from public view.
    Reason: Removed by member request For more information, visit our FAQ's.

All Answers

0

How many of these systems do you have total?

For troubleshooting, What I suggest doing is modifying the script as follows so that you can capture any errors and figure out where exactly the script is failing.


Put "REM" in front of @echo off so that you see all of the command output.

Place "pause" after :END so that the script will stay open, allowing you to see any error messages.

Add a redirect to the output of diskpart , piping it to a file which will allow you to read any errors that it may throws.


E.G.

diskpart /s X:\Windows\System32\BIOS.txt > X:\Windows\System32\DiskPartOutput.txt


I wish I could help with the Appliance's stock Diskpart Script.. I'm currently using a customized powershell one that I wrote before they merged the BIOS&UEFI Bat scripts into one task but I've kept it as I've thrown in some features such as forced ejection of USB media so that it does not get a conflicting volume assignment.   Right now I only have 5 or so precisions with multiple drives but I may at some point add logic to look for multiple drives and update the diskpart script with the correct disk ID if a spindle drive is disk 0 and a SSD is present in the system. Less effort at the moment for us to just pop the side panel and disconnect the spindle drive (As I wish to avoid having a forked imaging  task or complex scripting for a very small subset of systems).

Answered 10/13/2019 by: Kiyolaka
Orange Senior Belt

  • I currently have 20 machines that are setup like this. My main concern will be future setups and this is also a lab that may be re-imaged a few times a year. I wasn't aware that powershell could be run in a pre-boot environment.