tabs-not-spaces / Intune.USB.Creator

A module containing tools to assist with the creation of a bootable WinPE USB used to provision devices for enrollment to Intune.
GNU General Public License v3.0
131 stars 43 forks source link

Fatal Error at Setting Up Partition Table #30

Closed cmodom closed 3 years ago

cmodom commented 3 years ago

I've gotten this to work on some of our hardware, but I'm wondering if a 64 GB SSD isn't large enough to hold the image this creates, as I seem to be getting this message on those devices when imaging the drive:

Setting up partition table.. Fatal error. System.Runtime.InteropServices.SEHException (0x800004005): External component has thrown an exception.

After throwing this error, the USB drive is unusable and has to be recreated. That may not be related, but I found it interesting.

I'm new to this, but it seems to be working for my devices with newer devices with larger drives, but our environment has a mix of sizes.

Any insight is appreciated. This project is just what our team needs, so thanks for the great work.

tabs-not-spaces commented 3 years ago

There's nothing special about what the solution is doing at provisioning time - it's just shifting the windows 10 partition over to the hard drive.

To he totally honest, I don't have any devices with a primary disk smaller than 64gb to validate your scenario, so it's going to be very hard to repro.

Feel free to add transcript logging to the provisioning script to analyse what is going on - that's all I can suggest at this point.

On Sat, 27 Feb 2021, 7:30 am cmodom, notifications@github.com wrote:

I've gotten this to work on some of our hardware, but I'm wondering if a 64 GB SSD isn't large enough to hold the image this creates, as I seem to be getting this message on those devices when imaging the drive:

Setting up partition table.. Fatal error. System.Runtime.InteropServices.SEHException (0x800004005): External component has thrown an exception.

After throwing this error, the USB drive is unusable and has to be recreated. That may not be related, but I found it interesting.

I'm new to this, but it seems to be working for my devices with newer devices with larger drives, but our environment has a mix of sizes.

Any insight is appreciated. This project is just what our team needs, so thanks for the great work.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/tabs-not-spaces/Intune.USB.Creator/issues/30, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDA4LKOJWEVG7TTINABZ5TTBAAF7ANCNFSM4YJCBQPQ .

rawIce commented 3 years ago

I just experienced the same error on a device. In my case the error seems to be caused by the fact, that the storage driver of the disk of the computer you are trying to provision is missing in WinPE.

Therefore something breaks unexpectedly during the "Setting Up Partition Table" phase which also somehow seems to break the partition table of the USB stick.

Unfortunately I currently also don't have a solution for this, but I just wanted to share my observations.

tabs-not-spaces commented 3 years ago

Well, why not include the driver that you think is missing and try again?

On Wed, 19 May 2021, 7:54 pm rawIce, @.***> wrote:

I just experienced the same error on a device. In my case the error seems to be caused by the fact, that the storage driver of the disk of the computer you are trying to provision is missing in WinPE.

Therefore something breaks unexpectedly during the "Setting Up Partition Table" phase which also somehow seems to break the partition table of the USB stick.

Unfortunately I currently also don't have a solution for this, but I just wanted to share my observations.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tabs-not-spaces/Intune.USB.Creator/issues/30#issuecomment-843942264, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDA4LINLFXG55RZHIRZIQLTOODELANCNFSM4YJCBQPQ .

rawIce commented 3 years ago

First thanks a lot for your fast response! Yes, I already tried this, adding the driver works, now the disk is detected!

However now the main disk of the device is added after WinPE has initially started, therefore in diskpart the disk of the device is index 1, not 0.

In the provisioning script it seems like the disk index is hardcoded to be 0 for the main disk and 1 for the USB stick. In this scenario, the index numbers are inverted, so the diskpart script in Set-DrivePartition() uses the wrong disk. Therefore it tries to create partitions on the USB stick which obviously fails while creating the partition structure.

I was just able to confirm this by manually changing the disk index values in Invoke-Provision.ps1; using this workaround the provisioning worked smoothly!

It seems like in these scenarios the script should check whether the target device disk is in fact index=0. Maybe by sorting the disks of the device by size and choosing the largest one; however this approach also seems to be prone to errors e.g. when a device has a fast, smaller boot disk and a second larger data disk.

Maybe the user should just confirm the disk where Windows should be installed right after choosing which action the user wants to perform? Especially if the script detects that an additional driver has been loaded.

tabs-not-spaces commented 3 years ago

Hmm yeah, I've never run into hardware with this issue before - would you be able to write something up that tests the disks and returns the expected disk ID?

On Wed, 19 May 2021, 8:58 pm rawIce, @.***> wrote:

First thanks a lot for your fast response! Yes, I already tried this, adding the driver works, now the disk is detected!

However now the main disk of the device is added after WinPE has initially started, therefore in diskpart the disk of the device is index 1, not 0.

In the provisioning script it seems like the disk index is hardcoded to be 0 for the main disk and 1 for the USB stick. In this scenario, the index numbers are inverted, so the diskpart script in Set-DrivePartition() uses the wrong disk. Therefore it tries to create partitions on the USB stick which obviously fails while creating the partition structure.

I was just able to confirm this by manually changing the disk index values in Invoke-Provision.ps1; using this workaround the provisioning worked smoothly!

It seems like in this scenarios the script should check whether the target device disk is in fact index=0. Maybe by sorting the disks of the device by size and choosing the largest one; however this approach also seems to be prone to errors e.g. when a device has a fast, smaller boot disk and a second larger data disk.

Maybe the user should just confirm the disk where Windows should be installed right after choosing which action the user wants to perform? Especially if the script detects that an additional driver has been loaded.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tabs-not-spaces/Intune.USB.Creator/issues/30#issuecomment-843990174, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDA4LPKJKRMPWMH7ERVJ4DTOOKVJANCNFSM4YJCBQPQ .

rawIce commented 3 years ago

I think I came up with a working solution, wanna check it out? I only tested it on the single previously not working laptop next to me, but for me it seems like a good starting point...

https://github.com/rawIce/Intune.USB.Creator/commit/195100b54290324774516f0041ec05e3fc7e12ec#diff-cedded9429fe508765c9f0e62240bfde1a1f2af5167673d0f10d1dfe0eaf7433

tabs-not-spaces commented 3 years ago

This looks great - do you want to send it through as a PR and I'll test and merge?

On Thu, May 20, 2021 at 3:44 AM rawIce @.***> wrote:

I think I came up with a working solution, wanna check it out? I only tested it on the single previously not working laptop next to me, but for me it seems like a good starting point...

@.***

diff-cedded9429fe508765c9f0e62240bfde1a1f2af5167673d0f10d1dfe0eaf7433

https://github.com/rawIce/Intune.USB.Creator/commit/195100b54290324774516f0041ec05e3fc7e12ec#diff-cedded9429fe508765c9f0e62240bfde1a1f2af5167673d0f10d1dfe0eaf7433

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/tabs-not-spaces/Intune.USB.Creator/issues/30#issuecomment-844327469, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIDA4LJ7WGUYHX66MNOY5X3TOP2ILANCNFSM4YJCBQPQ .

rawIce commented 3 years ago

Fyi, I was able to test the script of the PR on two additional devices successfully.

tabs-not-spaces commented 3 years ago

closing as resolved.