OneDrive File Issues

How to Map a Local Folder or Drive to OneDrive Using a Junction

Steve KSteve K Nov 2, 2026 869 views

Question details

The user wants to synchronize local folders or an entire external/secondary drive with OneDrive without physically moving the original files into the default OneDrive folder.

How to Map a Local Folder or Drive to OneDrive Using a Junction
Product
OneDrive
Device & OS
not provided
Scenario
A user has large files or folders on a separate local drive and wishes to mirror them to OneDrive for cloud synchronization while keeping the original file paths intact.
Observed behavior
Instead of moving files directly to the OneDrive directory, a directory junction must be created via Command Prompt to link the original source to the OneDrive folder.
Before you start

Ensure you have administrator privileges on your computer, as running the mklink command requires an elevated Command Prompt to successfully create directory junctions.

Solution 1Recommended

Create a Directory Junction Using Command Prompt

Use the mklink command to create a hard link (junction) that makes OneDrive recognize your original folder as if it were stored locally within the OneDrive directory.

A directory junction acts as a mirror for your folders. It tricks Windows and OneDrive into thinking the files exist inside the OneDrive folder, prompting them to sync to the cloud, even though the actual files remain safely on your secondary drive.

While you can technically link an entire root drive, it is highly recommended to link specific folders instead to avoid syncing hidden system volume files that can cause OneDrive errors.

1
Open Command Prompt as Administrator

Click the Start menu, type 'cmd' in the search bar, right-click on 'Command Prompt', and select 'Run as administrator'.

2
Identify Your Folder Paths

Note down the exact path of your OneDrive folder where you want the link to appear (e.g., C:\Users\Username\OneDrive\Videos) and the exact path of your source folder (e.g., E:\Videos).

3
Execute the mklink Command

In the Command Prompt window, type the syntax: mklink /j "C:\Users\Username\OneDrive\FolderName" "D:\SourceFolder". Replace the placeholder paths with your actual folder locations.

4
Verify the Junction

Press Enter. You should see a message stating 'Junction created for...'. Open your OneDrive folder in File Explorer to confirm the mirrored folder appears with a shortcut icon.

Create a Directory Junction Using Command Prompt
Link Specific Folders Instead of Entire Drives: Linking an entire drive (like D:\) directly into OneDrive is not recommended. It is better to create a master folder on your D: drive, place your files inside it, and create a junction for that specific folder.
Free Microsoft Office alternative

Enhance Your Productivity with WPS Office

While managing your local files and OneDrive sync settings, try WPS Office as your primary productivity suite. It is a powerful, lightweight, and free alternative to Microsoft Office that easily handles all your document needs.

  1. 1. Download and Install: Visit the official WPS website to download the free installer and complete the quick installation process.
  2. 2. Connect Your Cloud: Sign in and seamlessly link your preferred cloud storage accounts to access your documents anywhere.
  3. 3. Edit with Ease: Open your existing Word, Excel, and PowerPoint files in WPS Office without any format loss or distortion.
Seamless compatibility with Microsoft Office formats (DOCX, XLSX, PPTX)Built-in cloud storage integration for effortless document saving and syncingLightweight installation that preserves your system resourcesFamiliar and intuitive interface for a zero-learning-curve migration
microsoft office alternative - wps office

Frequently Asked Questions

What happens if I delete a file inside the mirrored OneDrive folder?

Because the junction points directly to your original folder, deleting, modifying, or adding files in the mirrored OneDrive folder will apply those exact changes to the original source folder.

Can I use this method to sync an external hard drive to OneDrive?

Yes, you can create a junction for folders on an external drive. However, the external drive must remain continuously connected to your computer. If the drive is disconnected, the junction will break and OneDrive may display sync errors.

Why am I getting an 'Access Denied' error when typing the mklink command?

This error occurs when you do not have sufficient administrative privileges. Ensure you opened the Command Prompt by right-clicking it and selecting 'Run as administrator'.

What is the difference between /j and /d in the mklink command?

The /j parameter creates a directory junction (a hard link), while the /d parameter creates a symbolic link (a soft link). OneDrive processes directory junctions much more reliably when syncing local files to the cloud.