@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