Get-AppxPackage: The database disk image is malformed

You may be unable to install or update Store apps. Also, when you run the Get-AppxPackage command, the following error may appear:

Get-AppxPackage : The database disk image is malformed
The database disk image is malformed
At line:1 char:1
+ Get-AppxPackage
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AppxPackage], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.Windows.Appx.PackageManager.Commands.GetAppxPackageCommand

get-appxpackage database disk image malformed

In some cases, the database may be full or oversized. Add-ProvisionedAppPackage command may throw the following error:

Add-ProvisionedAppPackage : Insertion failed because database is full
At line:1 char:1
+ Add-ProvisionedAppPackage -online -PackagePath "C:\Apps\DesktopAppIns ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AppxProvisionedPackage], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.AddAppxProvisionedPackageCommand

Cause

The “The database disk image is malformed” or the “database is full” error occurs if the State Repository database is corrupt. This database stores information about every Store app installed on the computer. The database file names are below:

  • StateRepository-Deployment.srd
  • StateRepository-Deployment.srd-shm
  • StateRepository-Deployment.srd-wal
  • StateRepository-Machine.srd
  • StateRepository-Machine.srd-shm
  • StateRepository-Machine.srd-wal

Unfortunately, a repair installation using an in-place upgrade using the ISO may not resolve the issue.

However, resetting the StateRepository databases manually should fix the issue.

Resolution

To fix the error “The database disk image is malformed”, rebuild the State Repository database.

Important: The procedure will erase your Store apps. The Start menu and Settings might become inaccessible. However, a repair installation (after rebuilding the app repository) should fix all the issues.

Step 1: Rebuilding the State Repository database

  1. Download AdvancedRun from Nirsoft.net.
  2. Using AdvancedRun, open a TrustedInstaller Command Prompt. See the screenshot below.
    advancedrun - trustedinstaller

  3. After the Command Prompt window opens, close the AdvancedRun utility.
  4. In the TrustedInstaller Command Prompt, run the following commands:
    md C:\SRBackup
    cd /d C:\ProgramData\Microsoft\Windows\AppRepository
    sc config staterepository start= disabled
    net stop StateRepository

    Note: If you’re prompted to stop the Appx Deployment Service (AppxSVC) service, press Y to proceed. And, if the above command does not stop the State Repository service, you’ll get the error “The StateRepository service could not be stopped”. In that case, rerun the above command again.

    Then, run these commands:
    move StateRepository-*   C:\SRBackup
    sc config staterepository start= demand

    staterepository rebuild commands

The above procedure moves the existing State Repository database files to a folder for backup purposes.

Restart Windows. Or, click the Start button or an item in your notification area. This starts the State Repository service automatically and rebuilds the databases. A fresh set of StateRespository-* databases will be created. The newly built database will not contain information about your previously installed Store apps.


Step 2: Repair install Windows 10/11 using the ISO

Instructions to repair install Windows 10

1) Download Windows 10 Media Creation Tool (MCT) from this link:
https://go.microsoft.com/fwlink/?LinkId=2265055

2) Run MCT and accept the license agreement.



3) Click “Upgrade this PC now”. This starts the repair installation.

Your apps, settings, and files will be kept by default during a repair install/in-place upgrade.

Instructions to repair install Windows 11

1) Download Windows 11 Media Creation Tool (MCT) from this link:
https://go.microsoft.com/fwlink/?linkid=2156295

2) Run MCT and download the ISO it recommends for your system. Do not uncheck “Use the recommended options for this PC”.
https://www.winhelponline.com/blog/how-to-download-windows-11-iso/ (screenshots)

3) Right-click on the downloaded ISO and choose “Mount.” This assigns the ISO a drive letter.

4) Run setup.exe from the ISO drive. This starts the in-place upgrade/repair installation.

(Your files, settings and applications will be preserved if you use the ISO recommended for your system by the Media Creation Tool.)

This resolves the errors “The database disk image is malformed” and “Insertion failed because database is full” by rebuilding the StateRepository databases and allows you to install the Store apps.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

2 thoughts on “Get-AppxPackage: The database disk image is malformed”

  1. Been having this problem for some time now, and the most recent Windows Update for Win 10 has now caused my entire Windows “system” apparatus to be non-functional (no start menu, can’t access anything that would be considered a “base windows” function, like the search bar or even the clock!). I tried your steps listed here, but the final step was blocked because the files were still being used by another process.

    C:\WINDOWS\system32>cd /d C:\ProgramData\Microsoft\Windows\AppRepository

    C:\ProgramData\Microsoft\Windows\AppRepository>net stop StateRepository
    The following services are dependent on the State Repository Service service.
    Stopping the State Repository Service service will also stop these services.

    AppX Deployment Service (AppXSVC)

    Do you want to continue this operation? (Y/N) [N]: y
    The AppX Deployment Service (AppXSVC) service is stopping…
    The AppX Deployment Service (AppXSVC) service was stopped successfully.

    The State Repository Service service is stopping.
    The State Repository Service service was stopped successfully.

    C:\ProgramData\Microsoft\Windows\AppRepository>md C:\SRBackup

    C:\ProgramData\Microsoft\Windows\AppRepository>move StateRepository-* C:\SRBackup
    C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd
    The process cannot access the file because it is being used by another process.
    C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd-shm
    The process cannot access the file because it is being used by another process.
    C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Deployment.srd-wal
    The process cannot access the file because it is being used by another process.
    C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd
    The process cannot access the file because it is being used by another process.
    C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd-shm
    The process cannot access the file because it is being used by another process.
    C:\ProgramData\Microsoft\Windows\AppRepository\StateRepository-Machine.srd-wal
    The process cannot access the file because it is being used by another process.
    0 file(s) moved.

    Can you offer any insight on what other steps I can take?

    Reply

Leave a Comment