• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    FOS not mounting drive for post download scripts.

    Scheduled Pinned Locked Moved
    General
    3
    5
    455
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rodluz Developer
      last edited by

      Hello, I am having an issue when deploying one of my images. After Partclone is done, my post download scripts start, however it seems that the $part variable is not set correctly so the /ntfs directory only has Recovery and System Volume Information and is not mounting my ntfs partition.

      I haven’t changed anything of the mounting part from fog.postdownload.

      dots "Running post download scripts."
      
      mkdir /ntfs &>/dev/null
      ntfs-3g -o force,rw $part /ntfs
      
      echo "Mounting Device";
      
      if [ "$?" = 0 ]; then
              echo "Done"
              debugPause
              . ${postdownpath}getMachineModel
      ...
      ...
      

      I’m pretty sure it’s something with the specific image I am using, since I tried a different image and I don’t have that problem. I don’t know how my new image could be affecting this, but I didn’t do anything different for the “bad” image.

      I’m not sure what I should try to figure out what the issue is.
      I was able to mount the /dev/sda3 partition manually using ntfs-3g -o force,rw /dev/sda3 /ntfs

      1 Reply Last reply Reply Quote 0
      • R
        rodluz Developer
        last edited by

        I did a few more tests and realized that the $part variable is also not set on the image that is working, so probably not that. The other thing I realized, my working image has the NTFS partition on /dev/sda4 but the “bad” image has it on /dev/sda3. Not sure why the new image is different.

        A bit more context, in case it could be the issue:

        • The “good” image is Windows 10 Version 1909
        • The “bad” image is Windows 10 Version 20H2
        george1421G 1 Reply Last reply Reply Quote 0
        • george1421G
          george1421 Moderator @rodluz
          last edited by george1421

          @rodluz From either a windows computer or debug mode on FOS Linux, can you show the partition layout differences between these two different OS’.

          The code for the postdownload script might need to be revised as Microsoft revises the layout of the disk structure.

          If in FOS Linux (FOG Debug mode) we would need this information
          lsblk
          fdisk -l

          And just for clarity you are using this tutorial for your postinstall scripts? https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

          1 Reply Last reply Reply Quote 0
          • S
            Sebastian Roth Moderator
            last edited by

            @rodluz said in FOS not mounting drive for post download scripts.:

            The “good” image is Windows 10 Version 1909
            The “bad” image is Windows 10 Version 20H2

            This is a known change Microsoft did. They added another partition at the end of the disk. Think it’s a recovery partition they added but I am not sure from the top of my head.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            1 Reply Last reply Reply Quote 0
            • R
              rodluz Developer
              last edited by

              @george1421 @Sebastian-Roth So I modified my postdownload scripts to manually mount the correct drive if the code that was originally there didn’t do it. It is working for me so I am adding my post download scripts below in case anyone comes across this thread and finds it helpful for them. This works for me in my environment, but may not work for everyone.

              I took inspiration from the getHardDisk() function in https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/usr/share/fog/lib/funcs.sh

              The scripts are a bit of a mess but working

              fog.postdownload

              #!/bin/bash
              ## This file serves as a starting point to call your custom postimaging scripts.
              ## <SCRIPTNAME> should be changed to the script you're planning to use.
              ## Syntax of post download scripts are
              #. ${postdownpath}<SCRIPTNAME>
              
              clearScreen;
              
              dots "Running post download scripts."
              
              mkdir /ntfs &>/dev/null
              ntfs-3g -o force,rw $part /ntfs
              
              echo "Mounting Device";
              
              if [ "$?" = 0 ]; then
                      if [ ! -d "/ntfs/Windows" ]; then
                              . ${postdownpath}mountLargestPartition
                      fi
              
                      echo "Done"
                      debugPause
              
                      . ${postdownpath}getMachineModel
                      . ${postdownpath}getPlatformVersion
                      . ${postdownpath}fog.drivers
                      . ${postdownpath}fog.unattend
              
                      if [ -z "$auditMode" ]; then
                              . ${postdownpath}fog.bcu
                      fi
              
                      echo "Unmounting Device";
                      umount /ntfs;
                      debugPause
              else
                      echo "Failed to mount device";
                      sleep 30;
                      debugPause
              fi
              

              mountLargestPartition

              #!/bin/bash
              
              dots "Running the manual mount script"
              
              drive=$(lsblk -dpno KNAME -I 3,8,9,179,202,253,259 | uniq | sort -V)
              driveCleaned=${drive//'/dev/'/} #Remove `/dev/` from variable
              
              partition=""
              partSize=0
              
              # Get the largest partition
              while IFS= read -r line; do
                      tempPartSize=$(blockdev --getsize64 /dev/$line)
              
                      if [ $tempPartSize -gt $partSize ]; then
                              partSize=$tempPartSize
                              partition="/dev/$line"
                      fi
              done < <(ls /dev | grep -E "${driveCleaned}[a-zA-Z0-9]+")
              
              umount /ntfs &> /dev/null
              ntfs-3g -o force,rw $partition /ntfs
              

              getMachineModel

              #!/bin/bash
              
              dots "Retrieving Machine Model"
              
              machine=$(dmidecode -s system-product-name) # Gets machine model
              machine="${machine// /_}"  # Replace spaces with underscores
              
              echo "${machine}"
              debugPause
              

              getPlatformVersion

              #!/bin/bash
              
              dots "Retrieving Platform Version from Registry"
              
              # Create a registry file to be able to search the ReleaseId from
              # reged -x gives out an abort error message but from all my testing it still works.
              reged -x /ntfs/Windows/System32/config/SOFTWARE HKEY_LOCAL_MACHINE\\SOFTWARE \\ /out.reg &> /dev/null || true
              
              if [ -f /out.reg ]
              then
                      PlatformVersion=$(cat /out.reg | grep 'ReleaseId')
                      PlatformVersion=${PlatformVersion:13:4} # Grab only actual the ReleaseId. Full text looks like "ReleaseId"="1909"
                      echo "${PlatformVersion}"
              else
                      echo "No registry file found."
                      debugPause
              
                      dots "Retrieving Platform Version from PlatformVersion.rek file"
              
                      if [ -f "/ntfs/Windows/PlatformVersion.rek" ]
                      then
                              PlatformVersion=$(<"/ntfs/Windows/PlatformVersion.rek")
                              echo "${PlatformVersion}"
                              debugPause
                      else
                              echo "No platform version file found."
                              debugPause
                      fi
              fi
              

              fog.drivers

              #!/bin/bash
              
              dots "Preparing Drivers"
              
              mkdir /ntfs/Drivers &>/dev/null;
              echo "In Progress"
              
              dots "Adding drivers to driver path"
              cp -ar "/images/drivers/${machine}/${PlatformVersion}/" /ntfs/Drivers
              
              if [ "$?" = 0 ]; then
                      echo "Done"
              else
                      echo "Failed!"
              fi
              
              debugPause
              
              regfile="/ntfs/Windows/System32/config/SOFTWARE"
              echo "regfile ${regfile}"
              
              key="\Microsoft\Windows\CurrentVersion\DevicePath"
              echo "key ${key}"
              
              devpath="%SystemRoot%\inf;%SystemDrive%\Drivers"
              echo "devpath ${devpath}"
              
              reged -e “$regfile” &>/dev/null <<EOFREG
              ed $key
              $devpath
              q
              y
              EOFREG
              
              echo “Drivers done.”
              

              fog.unattend

              #!/bin/bash
              
              dots "Searching for Platform Version"
              
              # If $PlatformVersion is not null/empty
              if [ -n "$PlatformVersion" ]; then
                      echo "Found"
                      debugPause
              
                      dots "Removing old unattend file"
                      rm -f /ntfs/Windows/Panther/*nattend.xml
                      if [ "$?" = 0 ]; then
                              echo "Done"
                      else
                              echo "Failed to remove file!"
                              echo "Aborting fog.unattend"
                              debugPause
                              sleep 60
                              return
                      fi
                      debugPause
              
              
                      dots "Checking image mode"
                      if [ -n "$auditMode" ] && [ "$auditMode" -eq 1 ]; then
                              echo "AUDIT"
                              debugPause
              
                              dots "Copying audit mode unattend file"
                              cp "/images/unattends/UnattendAuditMode.xml" "/ntfs/Windows/Panther/Unattend.xml"
                              if [ "$?" = 0 ]; then
                                      echo "Done"
                              else
                                      echo "Failed!"
                              fi
                              debugPause
                      else
                              echo "OOBE"
                              debugPause
              
                              dots "Copying unattend file with driver path"
                              cp "/images/unattends/UnattendWithDriverPath.xml" "/ntfs/Windows/Panther/Unattend.xml"
                              if [ "$?" = 0 ]; then
                                      echo "Done"
                              else
                                      echo "Failed!"
                              fi
                              debugPause
                      fi
              else
                      echo "No valid Platform Version."
                      echo "Skipping unattend."
                      debugPause
              fi
              
              

              fog.bcu

              #!/bin/bash
              
              dots "Copying BIOS change script"
              
              if [ -f "/images/drivers/CMSL-BIOS_Change.ps1" ]
              then
                      cp "/images/drivers/CMSL-BIOS_Change.ps1" "/ntfs/Drivers"
                      echo "Done"
                      debugPause
              else
                      echo " Failed! Could not find bios change script."
                      debugPause
                      sleep 60
              fi
              
              echo "fog.bcu done."
              debugPause
              
              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              162

              Online

              12.0k

              Users

              17.3k

              Topics

              155.2k

              Posts
              Copyright © 2012-2024 FOG Project