You want to create mailboxes in Exchange Online and use Office 365. Before you can…
Move mail queue Exchange 2016 to another location
The mail queue database in Exchange temporarily holds location for messages. These messages are waiting to enter the next stage of processing or delivery to a destination. Move mail queue in Exchange 2016 to another location to prevent the C: drive getting out of disk space. It’s best practice to move transport database mail.que when configuring a new Exchange Server. In this article, you will learn how to move the mail queue in Exchange 2016 to another location. We are going to make use of a PowerShell script to move Exchange transport queue.
Table of contents
Create NTFS partition for the mail queue database
Before we start moving the mail queue database, we are going to:
- Add a new disk on the Exchange Server.
- Create and format a new NTFS partition (volume) with an allocation unit size of 64K.
- Name the volume Queue and give it the drive letter Q.
The required partition for the mail queue database is NTFS.
Get disk status
After adding a disk to the Exchange Server, we are going to configure it for the mail queue database. Run Exchange Management Shell as administrator. Get the information regarding the disks in the system using the Get-Disk cmdlet.
1 2 3 4 5 6 7 8 |
[PS] C:\>Get-Disk | Format-Table -AutoSize Number Friendly Name Serial Number HealthStatus OperationalStatus Total Size Partition Style ------ ------------- ------------- ------------ ----------------- ---------- --------------- 0 VMware Virtual disk 6000c2905397f746b506a29e5ae7fe22 Healthy Online 60 GB GPT 1 VMware Virtual disk 6000c29893be5b047dad48219ca6a74b Healthy Online 10 GB GPT 2 VMware Virtual disk 6000c29efde88f55a88f2cd7bc6d82a1 Healthy Online 10 GB GPT 3 VMware Virtual disk 6000c29580298e701e4c6cb79979ad54 Healthy Offline 10 GB RAW |
The disk that we like to configure is showing as Number 3 and it’s offline.
PowerShell one-liner creating NTFS volume
The partition style of disk number 3 is showing as RAW. We are going to set the disk online and initialize the partition as GPT (GUID partition table). Mount the partition as drive letter Q with the format volume NTFS and allocation unit size of 64K. We recommend configuring 64K allocation unit size/block size on the transport database volume in Exchange. Read more in the following article. The name of the new volume will be Queue.
1 2 3 4 5 |
[PS] C:\>Get-Disk 3 | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -UseMaximumSize -DriveLetter Q | Format-Volume -FileSystem NTFS -AllocationUnitSize 65536 -NewFileSystemLabel Queue DriveLetter FileSystemLabel FileSystem DriveType HealthStatus OperationalStatus SizeRemaining Size ----------- --------------- ---------- --------- ------------ ----------------- ------------- ---- Q Queue NTFS Fixed Healthy OK 9.93 GB 9.97 GB |
The NTFS volume is successfully configured. Verify the disk in Disk Management
Open File Explorer and go to This PC. Verify that the Queue disk is showing.
The volume is created with an NTFS partition and showing in This PC. In the next step, we are going to verify if everything is in place. After that, we will move the transport database to the Queue disk.
Before moving Exchange mail queue database
It’s good to prepare and make sure that we have everything in place before we start moving the mail queue database.
Microsoft created a PowerShell script Move-TransportDatabase.ps1. This script can be used to move the mail queue database to another location. The script is located in the Scripts folder. Find the script in the following path:
1 |
%ExchangeInstallPath%Scripts |
Confirm that the Move-TransportDatabase.ps1 is showing in the scripts directory.
Start File Explorer and go to the following path:
1 |
%ExchangeInstallPath%TransportRoles\data\ |
The Transport Roles folder, including the folders in data, is going to be moved to another location. In our example, the Q drive. Open the Queue folder if you like to check the mail.que database.
After verifying, we are ready to move the transport database in Exchange Server 2016.
Move Exchange mail queue database
Change the path to the default Exchange scripts folder. Run the command to move the Transport Roles folder including the mail queue database.
The script will do the following:
- Calculate the size of the files that are going to be moved.
- Check if there is space available on the disk.
- Creates new folders with permissions.
- Stops the Microsoft Exchange Transport service.
- Creates a back-up of the configuration file.
- Move the files.
- Starts the Microsoft Exchange Transport service.
There will be no mail data loss when using the PowerShell script.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
[PS] C:\>cd $ExScripts [PS] C:\Program Files\Microsoft\Exchange Server\V15\scripts>.\Move-TransportDatabase.ps1 -queueDatabasePath 'Q:\TransportRoles\data\Queue' -queueDatabaseLoggingPath 'Q:\TransportRoles\data\Queue' -iPFilterDatabasePath 'Q:\TransportRoles\data\IpFilter' -iPFilterDatabaseLoggingPath 'Q:\TransportRoles\data\IpFilter' -temporaryStoragePath 'Q:\TransportRoles\data\Temp' Queue Database Logging : Original path is C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Queue; New path is Q:\TransportRoles\data\Queue Temporary Storage : Original path is C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Temp; New path is Q:\TransportRoles\data\Temp IP Filter Database Logging : Original path is C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\IpFilter; New path is Q:\TransportRoles\data\IpFilter IP Filter Database : Original path is C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\IpFilter; New path is Q:\TransportRoles\data\IpFilter Queue Database : Original path is C:\Program Files\Microsoft\Exchange Server\V15\TransportRoles\data\Queue; New path is Q:\TransportRoles\data\Queue Required disk space: 2173698048 bytes. Target drive Q: has 10665787392 bytes free. Required disk space: 2147483648 bytes. Target drive Q: has 10665787392 bytes free. Required disk space: 2149580800 bytes. Target drive Q: has 10665787392 bytes free. Required disk space: 2155945984 bytes. Target drive Q: has 10665787392 bytes free. Required disk space: 2675908608 bytes. Target drive Q: has 10665787392 bytes free. Creating Q:\TransportRoles\data\Queue. Adding full control access to the directory for NetworkServiceSid. Adding full control access to the directory for LocalSystemSid. Adding full control access to the directory for BuiltinAdministratorsSid. Creating Q:\TransportRoles\data\Temp. Adding full control access to the directory for NetworkServiceSid. Adding full control access to the directory for LocalSystemSid. Adding full control access to the directory for BuiltinAdministratorsSid. Creating Q:\TransportRoles\data\IpFilter. Adding full control access to the directory for NetworkServiceSid. Adding full control access to the directory for LocalSystemSid. Adding full control access to the directory for BuiltinAdministratorsSid. Q:\TransportRoles\data\IpFilter already exists. Skipping directory creation. NetworkServiceSid already has full control to the directory. LocalSystemSid already has full control to the directory. BuiltinAdministratorsSid already has full control to the directory. Q:\TransportRoles\data\Queue already exists. Skipping directory creation. NetworkServiceSid already has full control to the directory. LocalSystemSid already has full control to the directory. BuiltinAdministratorsSid already has full control to the directory. Preparing to stop the MSExchangeTransport service... WARNING: Waiting for service 'Microsoft Exchange Transport (MSExchangeTransport)' to stop... MSExchangeTransport service is stopped successfully. Saving a copy of original configuration file in C:\Program Files\Microsoft\Exchange Server\V15\bin\EdgeTransport.exe.config.20200504191948.old. File trn.log has moved to the destination. File trn00000004.log has moved to the destination. File trntmp.log has moved to the destination. File Trnres00001.jrs has moved to the destination. File Trnres00002.jrs has moved to the destination. Skipping file Temp.edb because it doesn't exist. Queue Database Logging path is updated to Q:\TransportRoles\data\Queue Temporary Storage path is updated to Q:\TransportRoles\data\Temp File trn.log has moved to the destination. File trntmp.log has moved to the destination. File Trnres00001.jrs has moved to the destination. File Trnres00002.jrs has moved to the destination. Skipping file Temp.edb because it doesn't exist. IP Filter Database Logging path is updated to Q:\TransportRoles\data\IpFilter File IPFiltering.edb has moved to the destination. File trn.chk has moved to the destination. IP Filter Database path is updated to Q:\TransportRoles\data\IpFilter File mail.que has moved to the destination. File trn.chk has moved to the destination. Queue Database path is updated to Q:\TransportRoles\data\Queue Preparing to start the MSExchangeTransport service... WARNING: Waiting for service 'Microsoft Exchange Transport (MSExchangeTransport)' to start... MSExchangeTransport service is started successfully. Script execution completed successfully. |
Verify Exchange queue database files after moving
Start File Explorer. Verify the folders in the new location.
Open the Queue folder and verify that the files exist in the new location:
- Queue database files mail.que and trn.chk.
- Transaction log files trn.log, trntmp.log, trnres00001.jrs, trnres00002.jrs, and tmp.edb. Even though temp.edb isn’t a transaction log file, it’s kept in the same location as the transaction log files.
Good to know about EdgeTransport.exe.config
We can find the values that we have configured in the CONFIG file named EdgeTransport.exe.config. The XML application configuration file is associated with the Exchange Transport service. Find it in the following path:
1 |
%ExchangeInstallPath%Bin |
After running the PowerShell script, the EdgeTransport.exe.config is renamed. The date and .old are appended to the config name. You can open both the .config and .old file with Notepad.
Compare the following keys in both files:
- QueueDatabasePath
- QueueDatabaseLoggingPath
- IPFilterDatabasePath
- IPFilterDatabaseLoggingPath
- TemporaryStoragePath
Before moving the database queue database
After moving the database queue database
Now that you moved the mail queue database to another location, it will be easier to track. The monitoring team will get a notification that the Queue disk is getting full, knowing immediately that’s the mail queue database.
Did the article help you to move Exchange transport queue to another location?
Read more about mail.que file growing in Exchange Server to check the safety net values and adjust it. Another article is the mail.que file large in size Exchange Server if you like to start with a new mail.que database file.
Conclusion move mail queue Exchange 2016
In this article, you learned how to move mail queue in Exchange 2016 to another location. First, we created a separate disk volume for the queue database. Second, we moved the transport database with the PowerShell script Move-TransportDatabase.ps1. As of last, we verified the moved files in the new location. I recommend using the script by Microsoft to move the exchange transport database queue.
Did you enjoy this article? You may also like Exchange 2016 firewall ports for mail flow and clients. Don’t forget to follow us and share this article.
I found this tutorial very helpful and easy to understand. Great tutorial !