• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login
    1. Home
    2. JJ Fullmer
    3. Posts
    • Profile
    • Following 5
    • Followers 4
    • Topics 55
    • Posts 947
    • Best 254
    • Controversial 0
    • Groups 3

    Posts made by JJ Fullmer

    • RE: FOG API add snapin, run task and then delete

      @chris-whiteley I just re-read your post and realized you want to deploy a single snapin task, not the all snapins task.

      I’d have to test it but I believe what you want is

      $json = (@{
        "taskTypeID"='13';
        "deploySnapins"='snapinName';
      } | ConvertTo-Json);
      New-FogObject -type objecttasktype -coreTaskObject host -jsonData $json -IDofObject $hostid;
      

      When doing the all snapins taks the tasktypeid is 12 and you set the deploySnapins to ‘-1’. @Tom-Elliott can help with confirming the syntax of the json required for a single snapin. But if your using my powershell module, then the New-FogObject command will take care of creating the task.

      If you look at the code for start-fogsnapins here https://github.com/darksidemilk/FogApi/blob/master/FogApi/Public/Start-FogSnapins.ps1 you’ll note that I also have some checks for existing snapin tasks on the host. You’d probably want to do something like that. I should probably make it so that little segment is its own function, like Test-SnapinTasks and should probably make a separate start-fogsnapin function for single snapin tasks. But hey you could always do a pull request if you want to give writing it a try. I don’t know when I’ll have time to do all that myself.

      posted in FOG Problems
      JJ FullmerJ
      JJ Fullmer
    • RE: FOG API add snapin, run task and then delete

      @sebastian-roth Hey that’s me!

      @Chris-Whiteley I do this all the time. So 100% yes you can do this. I even have some pre-built helper functions for it in the published powershell module FogApi.
      So step one is install and setup the fogapi powershell module (check the links in my signature)

      I actually do pretty much that exact process in my provisioning of machines.
      Check out

      • Set-fogsnapins for setting a list of snapins to a host https://fogapi.readthedocs.io/en/latest/commands/Set-FogSnapins/
        (I just noticed I forgot to remove the $dept parameter in that function, that was for my internal use, you can just ignore it)
      • Start-FogSnapins for starting the deploy all snapins task on a host
        https://fogapi.readthedocs.io/en/latest/commands/Start-FogSnapins/
      • Remove-FogObject for removing the snapins from a host, looks like I haven’t published a helper function for removing the snapins just yet.
        https://fogapi.readthedocs.io/en/latest/commands/Remove-FogObject/
        • here’s an example of how you would remove the snapins. To remove them you have to remove the snapinassociation object.
      #create a list/array of the snapins you want to remove
      $snapinsToRemove = @('snapin','names','here'); 
      
      #get all the snapin associaion objects
      $AllAssocs = (Get-FogObject -type object -coreObject snapinassociation).snapinassociations
      
      # Get the snapins associated with your host
      $AllHostSnapins = Get-FogAssociatedSnapins -hostId $hostID;
      
      #get the ids of the snapins you want to remove, from the list of snapins attached to your host.
      $snapinIds = ($AllHostSnapins | Where-Object name -in $snapinsToRemove).id
      
      #Get a list of the snapinassociation ids that match your host id and are in the list of snapin ids attached to your host
      $assocsToRemove = $allAssocs | Where-Object { $_.hostID -eq $hostID -AND $_.snapinID -in $snapinIds}
      
      # loop through the found associations and remove them
      $assocsToRemove | ForEach-Object {
          Remove-FogObject -type object -coreObject snapinassociation -IDofObject $_.id;
      }
      

      That should do the trick.

      posted in FOG Problems
      JJ FullmerJ
      JJ Fullmer
    • RE: Copy ipxe.efi to uefi partition?

      @greg-plamondon That is one of the reasons I set this up, we have some wifi only devices, setting them to default boot to lan just doesn’t work. Also users get confused and or complain about the time it takes for the lan boot. So I set up a custom boot manager and got the best of all worlds.

      I did recently accidentally (so sadly not sure how to recreate it) find that the windows boot manager does still have a gui mode. So you could theoretically create this functionality without the use of third party tools. I discovered it when I imaged a computer that had 2 drives. I imaged the nvme in a desktop that had a old spinning drive that still had a windows install on it and windows saw the old spinning drive’s install first and kept booting to that. At some point I had a windows boot menu that showed both windows options. So there is still a way to add custom boot entries to the windows boot manager. Probably a mix of enabling the timeout in bcd bootmgr settings and then adding a custom boot option. So you could theoretically make it so you see an option for straight windows boot and straight fog ipxe.efi file boot. Personally I like using grub, but just wanted to let people know it’s an option someone could try to figure out.

      posted in Windows Problems
      JJ FullmerJ
      JJ Fullmer
    • RE: Lenovo L13 yoga 'Maybe the usb cable is bad' error when trying to register

      @sebastian-roth Well yes I see that now. It just felt like a familiar problem from whenever I change kernels. Should have just restarted and tried again before assuming something was broken though.

      posted in Hardware Compatibility
      JJ FullmerJ
      JJ Fullmer
    • RE: Lenovo L13 yoga 'Maybe the usb cable is bad' error when trying to register

      @george1421 Well, perhaps it was a one time glitch or updating the bios solves the issue.

      After surfaces image I have them install the latest driver pack that includes a bios update. After that happened and I tried to re-create the problem, the problem didn’t happen. I can share the video with all the log output if you still want it.

      posted in Hardware Compatibility
      JJ FullmerJ
      JJ Fullmer
    • RE: Lenovo L13 yoga 'Maybe the usb cable is bad' error when trying to register

      @george1421 I will got my log level to 7 and scheduled it to do an inventory task, I’ll take a video and we’ll see if it does it again on this 5.10.12 kernel

      posted in Hardware Compatibility
      JJ FullmerJ
      JJ Fullmer
    • RE: Lenovo L13 yoga 'Maybe the usb cable is bad' error when trying to register

      @george1421 well it got to

      bzImage....1%
      

      I actually had it sitting for a couple of hours. I just manually added the host in the gui and got it started imaging with the kernel you made here.
      I’ll put it back to the default kernel and see what I can do.

      posted in Hardware Compatibility
      JJ FullmerJ
      JJ Fullmer
    • RE: Copy ipxe.efi to uefi partition?

      @george1421 I’m pretty sure bootmgfw.efi is a bootmanager like refind and grub, it just doesn’t have a gui. And it chains bootx64.efi to boot to windows. From what I remember, trying to manually boot to bootx64.efi to get into windows doesn’t work, or doesn’t always work. So you want to use bootmgfw.efi to get into windows.
      There’s probably a way to enable a gui on the windows 10 bootloader like you could in windows 7 and 8 and add additional boot options to it, but I haven’t found anything that works reliably or that would be easy to maintain. So I just started using different bootloaders which eradicated any issues I ever had with the windows bootloader randomly breaking and with added bonuses of not needing to try to get keystrokes in fast enough during initial boot to get to bios settings or fog.

      posted in Windows Problems
      JJ FullmerJ
      JJ Fullmer
    • RE: Lenovo L13 yoga 'Maybe the usb cable is bad' error when trying to register

      @george1421 @Tom-Elliott
      Just as an fyi related to this post. I just updated to the latest kernel from Tom (5.10.12 64bit) and it does not load up on a surface. Trying to get it just to go to the full inventory screen from the pxe menu it gets to 1% after about 15 minutes and just sits there. The kernel has been fine for all other machines just the surfaces have an issue (thus far in my testing anyway). Perhaps we can add whatever George did to the default kernel build to make sure surface’s stay supported?

      posted in Hardware Compatibility
      JJ FullmerJ
      JJ Fullmer
    • RE: Copy ipxe.efi to uefi partition?

      @greg-plamondon Sorry I’ve been rather busy and hadn’t checked the forums in a bit.

      Firstly a sidenote on what @Sebastian-Roth posted last. My understanding (from lots of trial and error, testing, and reading of microsoft docs) bootmgfw.efi is the bootmgr at the firmware level for windows. It uses the bcd entries (that you can modify with bcdedit to then load the specified efi file to boot the OS, which I think is something like bootx64.efi.

      So, I have a lot of information in my brain on this so let’s see if I can simplify.

      TL;DR

      Perhaps the quick answer to your question is

      • make a symlink on the fog server to be able to download the ipxe.efi file ln -s /tftpboot/ipxe.efi /var/www/html/ipxe.efi
      • Mount the efi partition to drive letter A in windows mountvol A: /S
      • Download the ipxe file using powershell Invoke-WebRequest -Uri "http://fogserver/ipxe.efi" -OutFile "A:\EFI\ipxe-latest.efi";
      • (untested bit, but would probably work) Set the bcd to use ipxe as a bootmanager bcdedit /set "{bootmgr}" path "\EFI\ipxe-latest.efi"
        • You can revert this back to default with bcdedit /set "{bootmgr}" path "\efi\Microsoft\Boot\bootmgfw.efi"
      • Dismount the efi partition Mountvol A: /D

      Brain dump of detailed info

      I used to use rEFInd as my bootloader for my machines, but it has compatibility issues on some hardware so I found a different solution. I now use grub2win. But I still utilize Refind sometimes manually because it has a uefi shell, so when it is compatible it’s useful.

      So first let me explain a wee bit on uefi shells from my understanding.
      Basically, uefi has a shell, but not all computers have one built in. If you can boot to refind from a usb then you can access the shell.
      The syntax for changing directories in the shell is fs#: where # is the disk/partition number seen by uefi 0-(number of partitions -1).
      You can then use ls and cd to navigate and you can execute .efi boot files and load efi drivers i.e. load driverName.efi.
      Playing with the uefi shells is how I figured out that if you pop ipxe.efi on to a usb or somewhere on the local disk, you can run it from the efi shell and it boots to fog (provided your network is already configured for pxe booting to fog). Some Bios/uefi firmwares also have options for ‘booting to file’ or other custom boot options where you can achive the same idea of navigating to an efi file and booting to it.

      So here’s a rundown of how I automate that process.

      • I use chocolatey package manager and have a package made for installing grub2win
      • I have a custom powershell module provisioning system that’s started via firstlogoncommands of my unattend.xml
      • Within some of the first steps of provisioning I have it install my custom grub2win package (I have also tried to embed it in the image, but I believe sysprep/windows install changes the boot order on you, so I just make sure it runs, you could also do this with a setupcomplete.cmd system or whatever you use the run scripts after an image is completed)

      So here’s what my custom package does, it looks like a lot here but it’s basically just installing a boot manager, copying some files, and editing the bcd.

      Install grub2win

      You can get a grub2win installer here https://sourceforge.net/projects/grub2win/
      You download and extract the zip file. The setup.exe from the zip will then download the latest install files to %LocalAppData%\temp\grub2win.setup.exe.{buildNumber}\install
      It will auto start a gui setup, but I leave that be and go copy the install folder from the temp folder to be a part of my package. Once I have the install folder out of the local appdata temp directory, I close the install wizard that popped up.

      Configure grub

      In that install folder, you’ll need to edit the file at winsource\basic.cfg
      You can also use the built in gui tools to edit this after installing, but I find it easier to just make the config changes beforehand.

      Here’s what my custom menu entries look like, you’ll at least need the windows and fog menu entries.

      #
      #  Menu Entry 0       Windows 10
      #
      #  ** Grub will boot this entry by default **
      #
      menuentry   'Windows 10                                             Hotkey=w'   --hotkey=w    --class windows   --class icon-arrowwin  {
           set gfxpayload=auto
           set efibootmgr=/efi/Microsoft/Boot/bootmgfw.efi
           getpartition  file  $efibootmgr  root
           if [ ! -z $reviewpause ] ; then
      	 echo GNU Grub will load the Windows EFI Boot Manager at disk address $root
               g2wsleep  
               echo 
           fi
           chainloader $efibootmgr
           savelast 0 'Windows 10'
           echo GNU Grub is now loading  Windows 10
      }
      
      #
      #  Menu Entry 1       FOG
      #
      menuentry   'FOG                                                    Hotkey=f'   --hotkey=f    --class chainfile   --class icon-fog  {
           set gfxpayload=auto
           set chainbootmgr=/efi/ipxe-latest.efi
           getpartition  file  $chainbootmgr  root
           chainloader $chainbootmgr
           savelast 1 'FOG'
           echo GNU Grub is now loading  FOG via ipxe
      }
      
      #
      #  Menu Entry 2       Boot to your EFI firmware setup
      #
      menuentry   'Boot to your EFI firmware setup                        Hotkey=b'   --hotkey=b    --class bootfirmware   --class icon-bootfirmware  {
           g2wutil fwsetup
      }
      
      #
      #  Menu Entry 3       Boot Information and Utilities
      #
      menuentry   'Boot Information and Utilities                         Hotkey=i'   --hotkey=i    --class bootinfo   --class icon-bootinfo  {
           clear
          set pager=0
          set grub2win_chosen='0  -   Windows Boot Manager'
          set grub2win_lastbooted=no
          export gfxmode
          export grub2part
          export grub2win_chosen 
          export grub2win_lastbooted
          export grub2win_version
          export grub2win_procbits
          export grub2win_bootmode
          export grub2win_efiboot
          export grub2win_efilevel
          configfile $prefix/g2bootmgr/gnugrub.bootinfo.cfg
      }
      
      #
      #  Menu Entry 65      Shutdown the system
      #
      menuentry   'Shutdown the system                                    Hotkey=s'   --hotkey=s    --class shutdown   --class icon-shutdown  {
           clear
           set pager=1
           echo
           echo Grub is shutting down your machine
           echo
           sleep -i -v 2
           halt
           # If halt fails, display an error message
           echo Grub Shutdown is not supported by your firmware
      }
      

      I put all that at the bottom, that’s my entire menuentries section.

      Then at the top of the basic.cfg file (as in the very first uncommented line) I have Set default=0 to default to the windows bootloader.

      Packaging and silent install

      Then I make a chocolatey package (if you don’t have chocolatey you could probably achieve the same idea with a fog snapin pack). Basically you need all the files from the install folder, for a quick example we’ll pretend I copied the install files to C:\install To install grub2win silently I would run

      C:\install\winsource\grub2win.exe Autoinstall Quiet EFIAccess Shortcut=no Drive=C: RunFromEFI=yes SetAsDefault
      

      This will extract some files to C:\grub2win and copy neccesarry files to the EFI partition.

      I also do some theme customization and add the refind efi shell tools, but I’m not going to get into that here right now.

      Mount The EFI drive and copy down the ipxe.efi file

      I have a powershell function called Mount-Efi that does this with some other functions that help it too with some error checking and making sure it’s not already mounted. But the most important bit is this bit

      $mountLtr='A:'
      $mountVol = "C:\Windows\System32\mountvol.exe";
      Start-Process -FilePath $mountVol -Wait -NoNewWindow -ArgumentList @($mountLtr, '/S'); 
      

      That’s all to make it pretty in powershell, you can also just run the command natively mountvol A: /S where the /S is telling it to mount your efi partion, and the A: is saying to use A: as your path. This isn’t exposed to the gui file explorer, but you can then cd A:\ and you’re in the efi partion in powershell/cmd and can do whatever you want.

      Getting ipxe.efi

      To simplify this process and always have the latest version. I have a symlink on my fogserver to be able to grab the ipxe.efi file with a quick download.
      On the fogserver I create this with ln -s /tftpboot/ipxe.efi /var/www/html/ipxe.efi I can then download from http://fogserver/ipxe.efi. So after I’ve installed grub2win and then mounted the efi partition. I run this powershell command to download the ipxe file to efi and have it be named ipxe-latest.efi

              Invoke-WebRequest -Uri "http://fogserver/ipxe.efi" -OutFile "A:\EFI\ipxe-latest.efi";
      

      Now it is where my grub config will look for it if I choose to boot to fog.

      Test that grub2win installed correct

      I do a check in the efi partition that the kernel and binary files for grub2win are in the right place.
      You should ssee all the files that were in the folder g2bootmgr from the grub2win install folder at (assuming you mounted efi to A) A:\EFI\Grub2Win\g2bootmgr particularly you want to see the gnugrub.kernel*.efi boot file.

      Edit the windows bcd

      This is the series of steps I run through to edit the bcd. (I have powershell functions for each to keep it simple to run internally, but I’ll just share the basic commands to make it less confusing to read through). Essentially I have an end result of pointing the default windows bootmgr bcd entry to the grub efi boot file.

      Remove boot entry added by grub2win

      Grub2win adds its own entry to bcd and it does often work. But I have a handful of devices that it doesn’t work as expected on, so I remove it and edit the default windows one, which helps with devices that don’t let you change the boot order within windows.

      First you need to get the bcd entry for grub2win

      $searchString = "Grub2Win EFI - 64 Bit";
      $grubEntry = ($bcdEntry.ToString().split([Environment]::NewLine) | Where-Object { $_ -match 'id' }).Replace("identifier","").trim(); 
      

      Then you need the guid of that entry

      $guid = ($grubEntry.ToString().split([Environment]::NewLine) | Where-Object { $_ -match 'id' }).Replace("identifier","").trim();
      

      Now you can remove the entry

      bcdedit /set "{fwbootmgr}" displayorder $guid /remove
      
      # you can also view/confirm its removal before and after with
      bcdedit /enum "{fwbootmgr}"
      

      Edit where the bootmgr points

      This is where we change the default bcd entry to use grub instead of the windows bootloader. Theoretically you could also use this to always boot to pxe, but I wouldn’t recommend that.

      $path = "\EFI\Grub2Win\g2bootmgr\gnugrub.kernel64.efi"
      bcdedit /set "{bootmgr}" path $path
      

      The code above is just using string manipulation to get the guid out of the output of the above enum command. If doing it manually you could highlight, copy, paste.

      Make sure the altered boot manager is the first boot option

      I’m pretty sure this is the command windows uses during sysprep to reset the boot order to boot to windows first instead of whatever you had set in the bios for install (i.e. pxeboot)

      bcdedit /set "{fwbootmgr}" displayorder "{bootmgr}" /addfirst
      

      Remove runOnce boot options

      Sometimes grub2win or windows bcd or something else during this process adds a runOnce option. Theoretically you could use the runOnce option to force the computer to boot to the network on next reboot but it’ll go back to normal after that.
      However, since I’m creating a default here and want to see it work as it always will, I remove any entries if the exist.

      bcdedit /deletevalue "{fwbootmgr}" bootsequence
      

      Dismount efi partition and you’re done

      Lastly you can dismount the efi partition with this command. Next time you restart you’ll have grub as a bootmgr with options for booting to fog or windows.

      mountvol A: /D
      

      Putting it all together.

      Here’s what my chocolatey package looks like

      • parent folder named custom-grub
        • custom-grub.nuspec
      <?xml version="1.0" encoding="utf-8"?>
      <package xmlns="http://schemas.microsoft.com/packaging/2015/06/nuspec.xsd">
        <metadata>
          <id>custom-grub</id>
          <version>2004.2.207.5</version>
          <title>custom-grub</title>
          <authors>jfullmer</authors>
          <copyright>2019</copyright>
          <tags>custom-grub admin</tags>
          <description>
            Installs the customized arrowhead grub bootloader for easy booting to fog bios setup or a uefi shell when needed 
            To update the config that gets installed, edit the sources\winsource\basic.cfg file
            The basic theme is overridden with the customized theme complete with company logo background
            the boot options are to boot to windows 10, fog via ipxe, firmware/bios setup, or the refind boot manager for when a uefi shell is needed.
            In the future options for windows 10 safe mode and other boot modes should be added as a submenu. 
          </description>
        </metadata>
        <files>
          <file src="tools\**" target="tools" />
        </files>
      </package>
      
        • tools folder
          • chocolateyinstall.ps1
      $packageName  = 'custom-grub'
      $toolsDir     = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
      $sources	  = "$toolsDir\sources";
      $fileLocation = "$sources\winsource\grub2win.exe"
      
      $packageArgs = @{
        packageName   = $packageName
        softwareName  = 'custom-grub*'
        file          = $fileLocation
        fileType      = 'exe'
        silentArgs    = "Autoinstall Quiet EFIAccess Shortcut=no Drive=C: RunFromEFI=yes SetAsDefault "
        validExitCodes= @(0)
        url           = ""
        destination   = $toolsDir
      }
      
      Import-Module "$toolsDir\Functions.psm1" -force;
      
      Set-Location "C:\"
      Mount-EFI;
      $EfiMnt = Get-EfiMountLetter;
      
      Remove-OldGrubFiles -EfiMnt $EfiMnt;
      Add-EfiTools -sources $sources -EfiMnt $EfiMnt
      Dismount-EFI;
      
      Install-ChocolateyInstallPackage @packageArgs
      
      Mount-EFI;
      $EfiMnt = Get-EfiMountLetter;
      
      Test-BootMgrBinary -sources $sources -EfiMnt $EfiMnt
      Add-AdlGrubTheme -sources $sources -EfiMnt $EfiMnt;
      
      Write-Verbose "adding grub boot manager to bios boot order and fixing built-in bootmgr to use grub boot manager"
      Remove-FwBootEntry;
      Set-BcdBootMgrPath;
      Set-FirstFwBootOption;
      Remove-RunOnceBootOptions;
      
      Dismount-EFI;
      
      Remove-Item -Force -Recurse $sources;
      return;
      
          • functions.psm1
      function Remove-OldGrubFiles {
          [CmdletBinding()]
          param (
              $EfiMnt
          )
          
          process {
              Write-Verbose "removing any current grub files for fresh install"
              if ((Test-Path "C:\grub2")) {
                  #grub2 path already exists remove it
                  "Removing C:\grub2" | OUt-HOst;
                  Remove-Item -Force -Recurse C:\grub2;
              }
      
              if ((Test-Path "$EfiMnt\EFI\grub2win")) {
                  "Removing old grub2 EFI Files" | Out-host;
                  Remove-Item -Force -Recurse "$EfiMnt\EFI\grub2win";
              }    
          }
      }
      
      function Add-AdlGrubTheme {
          [CmdletBinding()]
          param (
              $sources,
              $EfiMnt
          )
      
          process {
              Copy-Item "$sources\themes\*" "C:\grub2\themes\" -force -recurse;
              Copy-Item "$sources\themes\*" "$EfiMnt\EFI\Grub2win\themes\" -force -recurse;
          }
      }
      
      function Add-EFITools {
          [CmdletBinding()]
          param (
              $Sources,
              $EfiMnt
          )
      
          process {
              Write-Verbose "Adding efi binary tools and drivers"
              New-Dir "$EfiMnt\EFI\Tools\";
              New-Dir "$EfiMnt\EFI\boot\";
              Copy-Item "$sources\refind\tools\*" "$EfiMnt\EFI\Tools\" -Force;
              Copy-Item "$sources\refind\boot\*" "$EfiMnt\EFI\boot\" -Force -Recurse;
              Write-Verbose "downloading latest fog ipxe file"
              Invoke-WebRequest -Uri "http://arrowfog/ipxe.efi" -OutFile "$EfiMnt\EFI\ipxe-latest.efi";
          }
      }
      
      function Test-BootMgrBinary {
          [CmdletBinding()]
          param (
              $Sources,
              $EfiMnt
          )
          process {
              if (!(Test-Path "$EfiMnt\EFI\Grub2Win\g2bootmgr\gnugrub.kernel*.efi")) {
                  Write-Verbose "boot manager binary is missing, re-copying the grub boot binary files";
                  Copy-Item "$sources\g2bootmgr\*" "$EfiMnt\EFI\Grub2Win\g2bootmgr\" -force;
              }
          }
      }
      
      function Get-BCDEntry {
          [CmdletBinding()]
          param (
              $searchString = "Grub2Win EFI - 64 Bit"
          )
          process {
              return (bcdedit /enum all | select-string $searchString -Context 5,1); #get the grub bootmgr entry from all bcd options
          }
      }
      
      function Get-BcdGUID {
          [CmdletBinding()]
          param (
              $bcdEntry = (Get-BCDEntry)
          )
          process {
              return ($bcdEntry.ToString().split([Environment]::NewLine) | ? { $_ -match 'id' }).Replace("identifier","").trim(); #get the guid of the grub bootmgr entry
          }
      }
      
      function Remove-FwBootEntry {
          [CmdletBinding()]
          param (
              $bcdEntry = (Get-BCDEntry)
          )
          process {
              $guid = Get-BcdGUID -bcdEntry $bcdEntry;
              $fwboot = bcdedit /enum "{fwbootmgr}"
              if ($null -ne $guid) {
                  if ($fwboot -match $guid) {
                      return (bcdedit /set "{fwbootmgr}" displayorder $grubID /remove); #remove the grub boot manager created by the installer from boot order as it isn't universally compatible
                  } else {
                      "guid was not in {fwbootmgr}" | OUt-Host;
                  }
              } else {
                  "guid not found" | OUt-Host;
                  return $null;
              }
          }
      }
      
      function Set-BcdBootMgrPath {
          [CmdletBinding()]
          param (
              $path = "\EFI\Grub2Win\g2bootmgr\gnugrub.kernel64.efi"
          )
          process {
              return (bcdedit /set "{bootmgr}" path $path)  #set the default bootmanager to the grub efi file path
          }
      }
      
      function Set-FirstFwBootOption {
          [CmdletBinding()]
          param (
              $bootOptionName = "{bootmgr}"
          )
          process {
              return (bcdedit /set "{fwbootmgr}" displayorder $bootOptionName /addfirst); #set the edited bootmanager to the first boot option
          }
      }
      
      function Remove-RunOnceBootOptions {
          [CmdletBinding()]
          param (
          )
          process {
              $fwboot = bcdedit /enum "{fwbootmgr}"
              if ($fwboot -match "bootsequence") {
                  $result = (bcdedit /deletevalue "{fwbootmgr}" bootsequence); #remove any run once boot options
              } else {
                  $result = "bootsequence value not present";
              }
              return $result;
          }
      }
      
      function Dismount-Efi {
          <#
              .SYNOPSIS
              Dismounts the EFI system partition if it is currently mounted
              
              .DESCRIPTION
              Gets the efi partition mount letter and dismounts it with the mountvol tool
              
          #>
              
              [CmdletBinding()]
              param ()
                  
              process {
                  $mountLtr=(Get-EfiMountLetter)
                  if ($null -eq $mountLtr) {
                      Write-Debug "EFI Partition is not mounted";
                      return $null
                  } else {
                      $mountVol = "C:\Windows\System32\mountvol.exe";
                      return Start-Process -FilePath $mountVol -Wait -NoNewWindow -ArgumentList @($mountLtr, '/D');
                  }
              }    
          
          }
      
      
          function Get-EfiMountLetter {
              <#
                  .SYNOPSIS
                  If the EFI partition is mounted this returns the current drive letter
                  
                  .DESCRIPTION
                  Runs the mountvol.exe tool and parses out the string at the end of the output
                  that states if and where the EFI system partition is mounted
                  
              #>
                  
                  [CmdletBinding()]
                  [Alias('Get-EfiMountLtr','Get-EfiMountPath')]
                  param (   
                  )
                  
                  process {
                      $mountVol = "C:\Windows\System32\mountvol.exe";
                      #test if mountvol already has mounted a EFI partition somewhere and dismount it
                      $mountVolStr = (& $mountVol)
                      $currentEfiMountStr = ($mountVolStr | Select-String "EFI System Partition is mounted at");
                      if ($null -ne $currentEfiMountStr) {
                          #get the substring starting at the index of the character before ':' in the drive name
                          $currentEfiMountLtr = $currentEfiMountStr.ToString().Substring(($currentEfiMountStr.ToString().indexOf(':'))-1,2); 
                          if ($null -ne $currentEfiMountLtr) {
                              return $currentEfiMountLtr;
                          }
                      }
                      Write-Debug "EFI partition is not currently mounted"; 
                      return $null
                  }
                  
              
              }
      
          • sources folder
            • Contents of install folder with altered basic.cfg file from the install grub2win step. I also have customizations to the theme (like a fog icon) and have some other customizations, but the ones I described here are all you need to make it function.

      Hopefully that is helpful information. Probably more information than you ever wanted.

      posted in Windows Problems
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @btoffolon Does this machine image fine with the original init?
      You can also try a different bzImage. I’m using 5.618RT3 made by @george1421 found here https://forums.fogproject.org/topic/15017/lenovo-l13-yoga-maybe-the-usb-cable-is-bad-error-when-trying-to-register/18?_=1610731427661

      I may have forgotten that I was using a different bzImage kernel when I started testing for this…

      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: How to delete images from FOG

      @sebastian-roth I will probably put this in https://docs.fogproject.org/en/latest/management/image-management.html# in a new subsection for deleting images.

      posted in FOG Problems
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @sebastian-roth

      Windows 8.1

      Image captured and deployed with new init
      Did deploy test from larger 128 GB source VM and it had no problem deploying to 60 GB VM

      d1.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/nvme0n1
      unit: sectors
      first-lba: 34
      last-lba: 268435422
      sector-size: 512
      
      /dev/nvme0n1p1 : start=        2048, size=      614400, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=6D92B4A9-E0B4-4DED-8C4C-E271AA36B06F, name="Basic data partition", attrs="RequiredPartition GUID:63"
      /dev/nvme0n1p2 : start=      616448, size=      204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2410B705-A7CB-4CE5-A393-8B3919C909D1, name="EFI system partition", attrs="GUID:63"
      /dev/nvme0n1p3 : start=      821248, size=      262144, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=58F556FE-7D3B-44EA-A846-C0848DB743CB, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/nvme0n1p4 : start=     1083392, size=   267350016, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=364F4B4F-4D49-4955-A5EB-9CDE151EEBF7, name="Basic data partition"
      

      d1.minimum.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/nvme0n1
      unit: sectors
      first-lba: 34
      last-lba: 268435422
      sector-size: 512
      
      /dev/nvme0n1p1 : start=        2048, size=      614400, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=6D92B4A9-E0B4-4DED-8C4C-E271AA36B06F, name="Basic data partition", attrs="RequiredPartition GUID:63"
      /dev/nvme0n1p2 : start=      616448, size=      204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2410B705-A7CB-4CE5-A393-8B3919C909D1, name="EFI system partition", attrs="GUID:63"
      /dev/nvme0n1p3 : start=      821248, size=      262144, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=58F556FE-7D3B-44EA-A846-C0848DB743CB, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/nvme0n1p4 : start=     1083392, size=    17806622, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=364F4B4F-4D49-4955-A5EB-9CDE151EEBF7, name="Basic data partition"
      
      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @sebastian-roth I’m working on a windows 8.1 w/update image (since windows 7 isn’t supported anymore)
      Will let you know the results

      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @sebastian-roth Do we also need to do some testing with this init on older versions of windows to be sure it doesn’t break anything there?
      And Other OS’s too? Like maybe at least 1 linux distro

      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @sebastian-roth

      The smaller to larger worked fine as well.
      here are all the d1.partition and d1.minimum.partitions I have (will update this post tomorrow with the recaptured first image) so it’s all in one spot

      1909 image

      for reference of old windows partition table
      This was NOT created with the new init, included this for comparison.

      d1.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/sda
      unit: sectors
      first-lba: 34
      last-lba: 134217694
      sector-size: 512
      
      /dev/sda1 : start=        2048, size=     1083392, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=75A55945-9352-4F30-A330-67878EC28FA1, name="Basic data partition", attrs="RequiredPartition GUID:63"
      /dev/sda2 : start=     1085440, size=      202752, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=D1336408-C5B3-446F-BE78-725587F7224D, name="EFI system partition", attrs="GUID:63"
      /dev/sda3 : start=     1288192, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=C9F8E03C-928A-4233-9837-49CE510E39B0, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/sda4 : start=     1320960, size=   132894720, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=D7729B0D-A7B4-4E1F-A9F5-F06FAAAE6141, name="Basic data partition"
      

      d1.minimum.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/sda
      unit: sectors
      first-lba: 34
      last-lba: 134217694
      sector-size: 512
      
      /dev/sda1 : start=        2048, size=     1083392, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=75A55945-9352-4F30-A330-67878EC28FA1, name="Basic data partition", attrs="RequiredPartition GUID:63"
      /dev/sda2 : start=     1085440, size=      202752, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=D1336408-C5B3-446F-BE78-725587F7224D, name="EFI system partition", attrs="GUID:63"
      /dev/sda3 : start=     1288192, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=C9F8E03C-928A-4233-9837-49CE510E39B0, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/sda4 : start=     1320960, size=    45462454, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=D7729B0D-A7B4-4E1F-A9F5-F06FAAAE6141, name="Basic data partition"
      

      20H2 smaller image

      partitions of image from 60 GB VM

      d1.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/nvme0n1
      unit: sectors
      first-lba: 34
      last-lba: 125829086
      sector-size: 512
      
      /dev/nvme0n1p1 : start=        2048, size=      204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2C465DF5-10FD-4883-B323-423E3D10FB2E, name="EFI system partition", attrs="GUID:63"
      /dev/nvme0n1p2 : start=      206848, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=7AFE394E-47A0-43FE-A06E-7AFD7286E200, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/nvme0n1p3 : start=      239616, size=   124567040, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=4A0FF43A-6E31-4AC9-8446-073E07C63AA8, name="Basic data partition"
      /dev/nvme0n1p4 : start=   124806656, size=     1021952, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=AEF97419-7B7D-4EC5-8C19-FF8C0217A965, attrs="RequiredPartition GUID:63"
      

      d1.minimum.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/nvme0n1
      unit: sectors
      first-lba: 34
      last-lba: 125829086
      sector-size: 512
      
      /dev/nvme0n1p1 : start=        2048, size=      204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2C465DF5-10FD-4883-B323-423E3D10FB2E, name="EFI system partition", attrs="GUID:63"
      /dev/nvme0n1p2 : start=      206848, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=7AFE394E-47A0-43FE-A06E-7AFD7286E200, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/nvme0n1p3 : start=      239616, size=    21331078, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=4A0FF43A-6E31-4AC9-8446-073E07C63AA8, name="Basic data partition"
      /dev/nvme0n1p4 : start=    21571584, size=     1021952, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=AEF97419-7B7D-4EC5-8C19-FF8C0217A965, attrs="RequiredPartition GUID:63"
      

      20H2 Larger image

      Partitions of image from 128 GB VM

      d1.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/nvme0n1
      unit: sectors
      first-lba: 34
      last-lba: 268435422
      sector-size: 512
      
      /dev/nvme0n1p1 : start=        2048, size=      204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2C465DF5-10FD-4883-B323-423E3D10FB2E, name="EFI system partition", attrs="GUID:63"
      /dev/nvme0n1p2 : start=      206848, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=7AFE394E-47A0-43FE-A06E-7AFD7286E200, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/nvme0n1p3 : start=      239616, size=   267173376, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=4A0FF43A-6E31-4AC9-8446-073E07C63AA8, name="Basic data partition"
      /dev/nvme0n1p4 : start=   267412992, size=     1021952, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=AEF97419-7B7D-4EC5-8C19-FF8C0217A965, attrs="RequiredPartition GUID:63"
      

      d1.minimum.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/nvme0n1
      unit: sectors
      first-lba: 34
      last-lba: 268435422
      sector-size: 512
      
      /dev/nvme0n1p1 : start=        2048, size=      204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2C465DF5-10FD-4883-B323-423E3D10FB2E, name="EFI system partition", attrs="GUID:63"
      /dev/nvme0n1p2 : start=      206848, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=7AFE394E-47A0-43FE-A06E-7AFD7286E200, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/nvme0n1p3 : start=      239616, size=    21351120, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=4A0FF43A-6E31-4AC9-8446-073E07C63AA8, name="Basic data partition"
      /dev/nvme0n1p4 : start=    21592064, size=     1021952, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=AEF97419-7B7D-4EC5-8C19-FF8C0217A965, attrs="RequiredPartition GUID:63"
      
      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @sebastian-roth I did not see this before I overwrote the test image, so I don’t have the d1.minimum.partitions, but I still can for the 60 GB image if you want that just to see what the init wrote. I can re-capture the larger vm after I finish the test for smaller to larger and get that for you, I’ll just post it tomorrow.

      The 10 GB was the fog gui, everything expanded as it should in windows.

      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @sebastian-roth I’m doing tests using just vms, so it’s possible that physical hardware could respond differently.
      Here are my results.

      I created an image successfully from a 128 GB VM, it was 10 GB in size after being resized (all I did was enter audit mode after installing windows and then captured)

      I deployed it to a VM with a 60GB drive and had no issues.

      I did confirm that the new init was used at boot for both. There was a bunch of extra output that happened to fast to catch on the capture before the gparted screens showed up, but everything worked fine.

      Here is my d1.partitions

      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/nvme0n1
      unit: sectors
      first-lba: 34
      last-lba: 268435422
      sector-size: 512
      
      /dev/nvme0n1p1 : start=        2048, size=      204800, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=2C465DF5-10FD-4883-B323-423E3D10FB2E, name="EFI system partition", attrs="GUID:63"
      /dev/nvme0n1p2 : start=      206848, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=7AFE394E-47A0-43FE-A06E-7AFD7286E200, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/nvme0n1p3 : start=      239616, size=   267168294, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=4A0FF43A-6E31-4AC9-8446-073E07C63AA8, name="Basic data partition"
      /dev/nvme0n1p4 : start=   267409408, size=     1021952, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=AEF97419-7B7D-4EC5-8C19-FF8C0217A965, attrs="RequiredPartition GUID:63"
      

      Just to be safe, I will also test this in reverse with the init, Going to capture the 60 GB image and deploy it to the 128 GB VM, especially since that’s what I usually do.

      Also, just for reference, here is the d1.partitions from our 1909 image. It looks like windows started putting the data partition at partition 3 instead of 4, kinda weird, that would make expanding disks for the main data drive more difficult, I wonder what the reasoning for that is.

      [root@arrowfog Base-Stable]# cat d1.partitions
      label: gpt
      label-id: 68156B04-B4FE-40EF-96CC-747C33F75E54
      device: /dev/sda
      unit: sectors
      first-lba: 34
      last-lba: 134217694
      sector-size: 512
      
      /dev/sda1 : start=        2048, size=     1083392, type=DE94BBA4-06D1-4D40-A16A-BFD50179D6AC, uuid=75A55945-9352-4F30-A330-67878EC28FA1, name="Basic data partition", attrs="RequiredPartition GUID:63"
      /dev/sda2 : start=     1085440, size=      202752, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B, uuid=D1336408-C5B3-446F-BE78-725587F7224D, name="EFI system partition", attrs="GUID:63"
      /dev/sda3 : start=     1288192, size=       32768, type=E3C9E316-0B5C-4DB8-817D-F92DF00215AE, uuid=C9F8E03C-928A-4233-9837-49CE510E39B0, name="Microsoft reserved partition", attrs="GUID:63"
      /dev/sda4 : start=     1320960, size=   132894720, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7, uuid=D7729B0D-A7B4-4E1F-A9F5-F06FAAAE6141, name="Basic data partition"
      
      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: Move partitions on GPT layouts - need people to test

      @Sebastian-Roth I just re-read through this as I’m starting work on our 20H2 image.
      We actually purposely make our base image from a smaller disk already of around 64 GB and it usually shrinks down to around 20 GB when captured. Then we deploy to things with larger drives.

      So just to be clear, I need to create the image from a new VM or physical machine that has a larger drive? i.e. expand the drive to something like 256 or 512 and then capture (where it will resize down to the usual 20ish GB or probably less for this test cause I’ll just install windows and that’s it) and then deploy to something with a 64 or 128 sized drive where it will resize.

      Why are people creating images from things with drives larger than what they are deploying to?

      Or is this testing a different type of image?

      posted in General
      JJ FullmerJ
      JJ Fullmer
    • RE: Lenovo L13 yoga 'Maybe the usb cable is bad' error when trying to register

      @george1421 I was also now able to use this lenovo usb-c adapter to pxe boot other non-lenovo devices I previously wasn’t able to.
      So bonus points for that.
      This is on the 5.6 rt3 kernel

      posted in Hardware Compatibility
      JJ FullmerJ
      JJ Fullmer
    • 1 / 1