Skip to content

Move Exchange database to another drive

After renaming the Exchange database, we like to move the Exchange database to another drive. Good to know is that we can only move the Exchange database path to another drive with PowerShell. It’s not possible to do it in the Exchange Admin Center. In this article, you will learn how to move the Exchange database to another drive.

Before moving Exchange mailbox database to another drive

Before moving the database to another drive, we recommend configuring the volumes as ReFS in Exchange. After that, move the database and logs to the created ReFS volumes.

  • Standalone Exchange Server
    If the Exchange Server is a standalone server. Configure two separate disks. One disk is for the database, and the other disk is for the database logs.
  • Exchange Server DAG
    If the Exchange Server is going to be a member of a DAG, configuring two disks is not required. We can have the database and logs on the same disk or separately.

Note: For recoverability, move the database (.edb) file and logs from the same database to different volumes backed by different physical disks.

Read more: Exchange database best practices »

Get Exchange mailbox database path

Run Exchange Management Shell as administrator. Let’s get the Exchange mailbox database path and run the Get-MailboxDatabase cmdlet.

[PS] C:\>Get-MailboxDatabase | Format-List Name, EdbFilePath, LogFolderPath


Name          : DB01
EdbFilePath   : C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1237333779\Mailbox Database 1237333779.edb
LogFolderPath : C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\Mailbox Database 1237333779

We already did rename the mailbox database name to DB01. That’s because we recommend having an easy-to-read mailbox database naming convention.

However, the .edb file (database) and log folder still have the unique generated name. Therefore, we will configure the name when we move both the database and log folder to another drive.

Move Exchange mailbox database to another drive

We will place the database file and logs from the same mailbox database to different volumes. The volumes are configured on both different physical disks. The (E:) drive is the database disk, and the (F:) drive is the logs disk.

Move Exchange database to another drive before move

Run the Move-DatabasePath cmdlet and fill in the values for each parameter:

  • EdbFilePath: Specifies a new file path for the database. All current database files are moved to this location.
  • LogFolderPath: Specifies the folder where log files are stored.

After running the command, confirm both times with Y and press Enter.

Important: The database will dismount, and the files will move to the new location. After the files finish moving, the database is mounted. Everything will happen automatically. The time of the operation depends on how much data there is to move. The users configured in the mailbox database will have no access to their email. It’s recommended to do this after business hours.

[PS] C:\>Move-DatabasePath "DB01" -EdbFilePath "E:\DB01\DB01.edb" -LogFolderPath "F:\DB01"

Confirm
Are you sure you want to perform this action?
Moving database path "DB01".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): Y

Confirm
To perform the move operation, database "DB01" must be temporarily dismounted, which will make it inaccessible to all users. Do you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [?] Help (default is "Y"): Y

Let’s check if the folders are created, and if the files have moved to each disk.

Results after moving Exchange database to another drive

The database file is renamed and shown in the new disk volume, including the content index folder. The content index files are located in the same path as the database EDB file, in a sub-folder named with a GUID.

Move Exchange database to another drive after move database volume

The database logs are moved to the new disk volume.

Move Exchange database to another drive after move logs volume

To clean up the old database folder, browse the old database path. Then, right-click the folder and click delete.

Delete old database folder

If you get a warning that the folder or file is in use, restart the following services in PowerShell. After that, you can delete the folder.

[PS] C:\>Get-Service -Name "HostControllerService","MSExchangeFastSearch" | Restart-Service
WARNING: Waiting for service 'Microsoft Exchange Search Host Controller (HostControllerService)' to stop...
WARNING: Waiting for service 'Microsoft Exchange Search Host Controller (HostControllerService)' to stop...
WARNING: Waiting for service 'Microsoft Exchange Search (MSExchangeFastSearch)' to stop...

Verify the results with PowerShell.

[PS] C:\>Get-MailboxDatabase | Format-List Name, EdbFilePath, LogFolderPath


Name          : DB01
EdbFilePath   : E:\DB01\DB01.edb
LogFolderPath : F:\DB01

That’s it!

Read more: Delete mailbox database in Exchange Server

Conclusion

You learned how to move the Exchange database to another drive. It’s only possible to move the Exchange database and log folder of the mailbox database to another drive with PowerShell. Move Exchange database path to another drive outside business hours. Otherwise, the users with a mailbox in that mailbox database cannot connect to their email.

Did you enjoy this article? You may also like to read Create mailbox database in Exchange Server. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 13 Comments

  1. I was able to solve, but ran into a scary error after move finished:
    “The task completed successfully, but the database [nameofDB] cannot be restored.”
    The moved database wouldn’t mount! I googled the error and came across someone who said they deleted all log files and then it mounted. that worked for me! fyi, I moved log files to same folder as database file. I know it’s not best practice, not sure if this caused the error.

    1. edit; I just moved another (smaller DB) and it moved and remounted at new location perfectly. it’s possible a VM snapshot occurred during my first move, I’m thinking that might cause an issue.. vsswriter stuff.

  2. Found a user who tried to add a new drive and did a robocopy of their E:\ exchange install folder to the new drive then changed the partitions so the new drive was E:. Now nothing starts. Powershell won’t connect to exchange and EAC won’t start (registry key Global denied). Tried running CU22 which completed but did not fix the issue. Any hope here?

  3. Dear Ali, does Move-DatabasePath really move the database or copy it?
    I need to MOVE it from one folder to another on the same disk, but I dont have enough space to hold two copies. So a move is no problem, a copy would not work.

    Thank you for your insight 🙂

    1. Hi Joachin,

      It will copy the database from the source location to the target location. After the copy finishes, it will delete the database from the source location.

      In your case, it will not work because you will not have enough space free to hold two copies when it’s copying.

  4. Great article Ali,

    Do you know if this process will move the database as is, or will it eliminate white space during the move? Reason I ask is I have a db with significant white space and am looking for an alternate way to shrink other than doing the offline defrag.

  5. What happens to the mailboxes being moved , if you run out of time and need to stop migration?
    I’m assuming they won’t finish and use should still be able to access?

  6. Dear Ali,
    thanks for this, however I seem to go round in circles: I have to move a mailbox db (archive) from the default C:\Program Files\Microsoft\Exchange Server\V15\Mailbox\ location to the D: drive, I have a DAG with two nodes,
    but it tells me I can’t move as it is a replicated db “Move-DatabasePath is not allowed for replicated databases”
    I have tried to dismount the db, suspend it, but it keeps telling me the same each time… any ideas would be most welcome,
    Thanks in advance,
    Kind regards
    Oli

    1. Hi Oli,

      This article was written for a single Exchange Server and not a DAG configuration.

      In your case:

      1. Remove all mailbox database copies for the database being moved.
      2. Move the mailbox database path to the new location.
      3. Create the necessary folder structure on each Mailbox server that previously contained a passive copy of the moved mailbox database.
      4. Move the passive copy of the mailbox database and its log stream to the new location.
      5. Add all of the database copies that were removed.
      6. On each server that contains a copy of the mailbox database being moved, run the cmdlet Restart-Service MSExchangeFastSearch.

      You can read more over here: Move Exchange DAG database to another drive.

Leave a Reply

Your email address will not be published. Required fields are marked *