Techibee.com

[Resolved] ISO Mount error(Sorry, there was a problem mounting the file) on Windows 8 & Windows 2012

Couldn’t mount file. Sorry, there was a problem mounting the file

You might get this error message while trying to mount an ISO file on Windows 8 or Windows Server 2012. This article helps you in understanding the root cause and find a solution for this problem.

I ran into this problem first time when I was working on automating building VHD files from ISO file directly (see the related article here). Recently noticed this again while upgrading my lab to Windows Server 2012. Since this is hindering my work often, I decided to understand this issue more and found some interesting details.

The issue behind failing to mount ISO files is, it has got a sparse flag set. You can read more about this particular file attribute at this MSDN page(http://msdn.microsoft.com/en-us/library/windows/desktop/aa365564%28v=vs.85%29.aspx). In a nutshell, this sparse flag is facility supported in NTFS file system that enables efficient use of disk space by not writing zeros in a data stream. Instead it maintains an internal list containing the location zeros in file.

So the solution is to remove that sparse flag to mount the ISO. At this moment, I am not clear why the mounting will not work if this flag is set. May be because CDFS file system cannot understand this flag and hence the errors.

There are two ways you can remove the sparse flag:

  1. Just by simple copy & paste: You can copy & paste the ISO file into same folder or different folder. The sparse flag will be removed when a copy of this file is made. You can use the copied file to mount as CD/DVD drive
  2. Remove the sparse flag programmatically: You can use below approach to remove the sparse flag on one of multiple files.

To know if a file has sparse flag, try the below command. The output will show list of flags that the file has.

[System.IO.File]::GetAttributes("d:\Softwares\R2.ISO")

Alternatively you can use fsutil as well to check if the file has sparse flag.

fsutil sparse queryflag R2.ISO

To remove the sparse flag, use the below code:

function Remove-SparseFlag {            
[cmdletbinding()]            
param(            
[string]$FileName            
)            
    if(!(Test-Path $FileName)) {             
        Write-Host "$FileName No such filename present"            
        return            
    }            
            
    $Attribs = [System.IO.File]::GetAttributes($FileName)            
    if($Attribs.HasFlag([System.IO.FileAttributes]::SparseFile)) {            
        Invoke-Expression -Command "fsutil sparse setflag '$FileName' 0"            
        if($LASTEXITCODE -ne 0) {            
            Write-host "Failed to remove sparse flag on $FileName"            
        } else {            
            Write-Host "Successfully removed the sparse flag on $FileName"            
        }            
    } else {            
        Write-Host "$FileName has no sparse flag set"            
    }            
            
            
}

Output:

I tried to remove the sparse flag dotnet way, but it is not working for some reason. I will explore that more when I get a chance.

Exit mobile version