Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to unmount drive in Google Colab and remount to another drive?

I mounted to Google drive account A. Now I want to switch to account B but I cannot do that, because there is no way for me to enter a new authentication key when executing drive.mount().

What I have tried and failed:

  1. restart browser, restart computer
  2. use force_remount=True in drive.mount(), it will only automatically remount account A. Not asking me for new mounting target.
  3. change account A password
  4. change run-time type from GPU to None and back to GPU
  5. open everything in incognito mode
  6. sign out all google accounts

How can I:

  • forget previous authentication key so it will ask me for a new one?
  • dismount drive and forget previous authentication key?
like image 880
Raymond Kwok Avatar asked Feb 23 '19 00:02

Raymond Kwok


People also ask

How do I unmount Google Drive?

On both Windows 10 and Windows 11, open Settings (using the Win + I shortcut if you like) and browse to Apps > Apps & features. Use the search box or scroll down to find Google Drive. Click it, followed by Uninstall, then walk through the steps to remove Google Drive from your computer.

How do I remove Google Drive from Google Colab?

How do I delete a directory in Colab? Enter the collaboration. Click My Account > Manage Folders. to collapse it. In the Manage Folder pane, click the name of the parent folder (one level up) of the folder you want to delete.

How do I change the directory of a drive in Colab?

If you want to change directory from google colab into google drive, connect to google drive first. Change to the google drive directory. Yes, because this answer is slightly outdated. Now the same path should be: '/content/drive/MyDrive/'.


2 Answers

I have found the 'Restart runtime...' not to work, and changing permission too much of a hassle.
Luckily, the drive module is equipped with just the function you need:

from google.colab import drive drive.flush_and_unmount() 
like image 169
M.G.Poirot Avatar answered Sep 20 '22 21:09

M.G.Poirot


You can reset your Colab backend by selecting the 'Reset all runtimes...' item from the Runtime menu.

Be aware, however, that this will discard your current backend.

like image 44
Bob Smith Avatar answered Sep 21 '22 21:09

Bob Smith