To mount Google Drive in Google Colab, import drive from google.colab, run drive.mount('/content/drive'), and complete Google’s interactive authorization process. Your personal Drive files will then be accessible under /content/drive/MyDrive/.
The short version
- Mount with Python: Run the import and mounting code in a notebook cell, then complete authorization.
- Use the file browser: Click Mount Drive in the left-side file browser and run the mounting cell if Colab inserts one.
- Find your files: The standard mount puts personal files under
/content/drive/MyDrive/. - Reconnect when needed: Add
force_remount=Trueto retry an existing connection.
| Method or option | When to use it | What to expect |
|---|---|---|
| Python code cell | Mount in a hosted notebook | Run the code and authorize access |
| File browser | Start from the notebook interface | The button may insert mounting code |
| Automatic remounting | Return to an eligible notebook | Colab may reconnect Drive automatically |
| Custom mount directory | Choose a different folder path | Supply a valid mount directory |
| Read-only mounting | Read files without writing through the mount | Add readonly=True |
| Forced remount | Retry an existing connection | Add force_remount=True |
| Flush and unmount | Finish using the connection | Flush pending writes and disconnect |
| Gemini code generation | Request code with an eligible account | Review and run the generated code |
| Colab VS Code extension | Mount from VS Code | Execute the appended mounting snippet |
| Extension installation page | Get Google’s VS Code extension | Install from the official listing |
| Colab CLI | Mount from Linux or macOS | Run the mounting command for a hosted session |
| CLI installation repository | Get Google’s CLI | Choose a supported installation command |
| Administrator service control | Enable Colab for a managed account | An administrator enables service access |
| Administrator Drive policy | Address a domain-policy block | An administrator reviews the Drive integration setting |
Run the mounting code in your notebook
In a Colab notebook connected to a supported hosted runtime, enter the following Python in a code cell. Keep both lines together so the import runs before the mounting call.
from google.colab import drive
drive.mount('/content/drive')
Run the cell, then complete the interactive Google authorization process.
After mounting completes, access your personal files under /content/drive/MyDrive/. Use that location when your notebook needs a path to a personal Drive file with this mount directory.
Mount from the file browser
Open the left-side file browser and click Mount Drive. If Colab inserts a mounting code cell, run that cell next. Complete the interactive Google authorization process to finish connecting Drive to the hosted runtime.
Choose a different mount directory
You can replace /content/drive with another valid mount directory. Run the following code to use /content/gdrive, then complete authorization.
from google.colab import drive
drive.mount('/content/gdrive')Choose a path without spaces, and do not use a symbolic link as the mountpoint. An existing directory must be empty. If Colab rejects your directory for one of these reasons, choose a directory that meets those requirements and run the mounting call again.
Connect Drive with read only access
Use the read-only option when you want to read files without allowing writes through the mount. Run the following cell with readonly=True, then complete authorization.
from google.colab import drive
drive.mount('/content/drive', readonly=True)If Drive is already mounted, unmount it first using the disconnection steps below, or add force_remount=True. To apply read-only access through a forced remount, run this version and complete authorization if requested.
from google.colab import drive
drive.mount('/content/drive', readonly=True, force_remount=True)Reconnect or finish using the mount
To retry an existing Drive connection, run the mounting call with force_remount=True. Complete authorization again if Colab requests it.
from google.colab import drive
drive.mount('/content/drive', force_remount=True)When you finish using the connection, run the following code to flush pending writes and unmount Drive. Wait for the operation to complete.
from google.colab import drive
drive.flush_and_unmount()To reconnect afterward, run the standard mounting call again. Complete the interactive authorization process if requested.
drive.mount('/content/drive')Fix managed account access blocks
If your organization-managed account needs Colab enabled, ask an administrator with the Service Settings privilege to enable it. In Google Admin console, the administrator opens Apps > Additional Google services > Colab > Service status, selects On for everyone, then clicks Save. The administrator can instead target an organizational unit or access group. Once service access is enabled, you still need to mount Drive inside Colab.
If mounting reports a domain-policy block, ask an administrator with Drive & Docs privileges to review Apps > Google Workspace > Drive and Docs > Google Drive for desktop > Enable Drive for desktop. To enable the service, the administrator checks Allow Google Drive for desktop in your organization and clicks Save. This policy controls a prerequisite for mounting; forcing a remount does not bypass organization policy.
Ask Gemini for mounting code
In AI-enabled Colab, eligible accounts aged 18 or older in supported locales can use Gemini to generate mounting code. Click the Gemini spark icon in the notebook footer and explicitly request code to mount Google Drive. Review the generated drive.mount code, run it, and complete authorization. This option still requires a supported runtime.
Mount Drive from VS Code
Install the official Google Colab extension in VS Code. Open a notebook and sign in when prompted, then click Select Kernel > Colab > Auto Connect to connect to a Colab server.
With a Colab server assigned, press Ctrl + Shift + P, or Command + Shift + P on Mac. Select Colab: Mount Google Drive to Server... from the command palette. The command appends a mounting code snippet to the active notebook. Execute that snippet and complete Google authorization to finish mounting Drive.
Use the Colab CLI on Linux or macOS
The official Colab CLI provides a command-line route on Linux and macOS. Windows is unsupported by this CLI, and mounting requires an accessible Colab-hosted session. Install the CLI with this command.
pip install google-colab-cliIf you use uv, you can install the CLI with the following command instead. Choose one installation command.
uv tool install google-colab-cliWith CLI authentication configured, create a session using the first command below, then mount Drive using the second. Complete the interactive authentication requested by the CLI.
colab new -s analysis
colab drivemount -s analysisThe default mountpoint is /content/drive. To choose a different location, supply a PATH argument to the mounting command.
Frequently Asked Questions
Will Google Drive mount automatically next time?
Colab may remount Drive when you reconnect after initially mounting and authorizing it, provided the notebook passes its security checks. Notebooks edited by another user do not automatically mount. Google’s Colab FAQ does not describe a user-facing toggle to force eligibility.
Do you need a paid Colab plan to mount Google Drive?
You can use the standard Python mounting method on both free and paid consumer Colab plans. In either case, you need a supported hosted runtime.
Can you use these mounting steps with a local runtime?
The built-in mounting method applies to supported consumer Colab hosted runtimes. Its scope excludes local runtimes, Colab Enterprise, and Marketplace VMs.
Why do older examples ask you to paste an authorization code?
Older browser-notebook instructions used an out-of-band OAuth flow that Google has blocked for production clients. Use the current interactive mounting flow instead.
Can a forced remount fix missing account permissions?
A forced remount retries the mounting operation but does not bypass account permissions. You still need to complete the required authorization.