How to reset Google Cloud Shell user persistent disk?

送分小仙女□ 提交于 2019-12-12 19:06:16

问题


Ok, folks. Pushing the limits (of my understanding), I've broken my Google Cloud Shell on Google Cloud Platform. I can no longer open a shell session.

When I click the shell icon >_ on the tool bar, the shell opens on the lower half of the screen for a moment, stating it is provisioning the instance (if it has been over an hour), established a connection, and then poof, it closes.

I was able to time a screen capture just right to see the following:

Welcome to Cloud Shell! For help, visit https://cloud.google.com/cloud-shell/help.
-bash: /usr/bin/zsh: No such file or directory

I am pretty sure this relates to a naive attempt to install zsh ON A DIFFERENT PROJECT. My theory is that the 5Gb of persistent disk storage provided by Cloud Shell is per user, not per user per project. Therefore, my home directory is borked and will no longer load because the OS modifications are not persisted, only user home directories, and my .bashrc now references non-existent files.

So my question is this: How do I start over, or wipe out the existing persistent disk and settings to obtain a working Shell again?


回答1:


You can reset the cloud shell like this

Restore your Cloud Shell home directory to a clean state:

Check for personal files in the home directory:

ls -a $HOME

Remove all files from your home directory:

sudo rm -rf $HOME

In the Cloud Shell menu, click the gear icon, then click Restart Cloud Shell. Click Restart Cloud Shell in the confirmation dialog.

From the docs https://cloud.google.com/shell/docs/limitations#resetting_cloud_shell_to_default_state




回答2:


Resolved, with help from Google.

Note: This approach of obtaining help is likely not the best way long term.

I used the Shell's 'Send Feedback' feature to communicate the issue to Google.

An engineer on the Google Cloud Shell team was awesome, and replied with the following:

Unfortunately, this is a known issue that if you add starting zsh to your .bashrc file. If there is nothing important to you on the disk, I can just delete your home disk which will in turn provision you a new disk that does not have this issue. However, if there is something important on there, I could manually mount your disk and do the cleanup. The downside of that is while the disk is mounted I could see what's on the disk. Let me know what you would like done. Apologies for the inconvenience.

Fortunately, I didn't have anything important, nor sensitive, and replied with the delete option. Back in business.

Hope this helps someone else.




回答3:


I actually was wondering about the same thing myself the other day. As you figured out, the Cloud Shell persistent disk is per user and as far as I know, there's no way to reset your persistent disk.




回答4:


Just do sudo su - which will make you the root user.

Then just remove/uninstall anything you added/installed. Ex: rm /home/your_user/.bashrc

If you are unable to login because you messed up your .bashrc or something, it will prompt you to signin as root and then you can remove things with the command above.



来源:https://stackoverflow.com/questions/36067968/how-to-reset-google-cloud-shell-user-persistent-disk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!