title | description | services | documentationcenter | author | manager | tags | ms.assetid | ms.service | ms.workload | ms.tgt_pltfrm | ms.devlang | ms.topic | ms.date | ms.author |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Persist files for Bash in Azure Cloud Shell | Microsoft Docs |
Walkthrough of how Bash in Azure Cloud Shell persists files. |
azure |
jluk |
timlt |
azure-resource-manager |
azure |
infrastructure-services |
vm-linux |
na |
article |
09/25/2017 |
juluk |
[!include features-introblock]
Bash in Cloud Shell persists files through both of the following methods:
- Creating a disk image of your
$Home
directory to persist all contents within the directory. The disk image is saved in your specified file share asacc_<User>.img
atfileshare.storage.windows.net/fileshare/.cloudconsole/acc_<User>.img
, and it automatically syncs changes. - Mounting your specified file share as
clouddrive
in your$Home
directory for direct file-share interaction./Home/<User>/clouddrive
is mapped tofileshare.storage.windows.net/fileshare
.
Note
All files in your $Home
directory, such as SSH keys, are persisted in your user disk image, which is stored in your mounted file share. Apply best practices when you persist information in your $Home
directory and mounted file share.
With Bash in Cloud Shell, you can run a command called clouddrive
, which enables you to manually update the file share that is mounted to Cloud Shell.
You can update the file share that's associated with Cloud Shell by using the clouddrive mount
command.
If you mount an existing file share, the storage accounts must be:
- Locally redundant storage or geo-redundant storage to support file shares.
- Located in your assigned region. When you are onboarding, the region you are assigned to is listed in the resource group name
cloud-shell-storage-<region>
.
Note
If you're mounting a new file share, a new user image is created for your $Home
directory. Your previous $Home
image is kept in your previous file share.
Run the clouddrive mount
command with the following parameters:
clouddrive mount -s mySubscription -g myRG -n storageAccountName -f fileShareName
To view more details, run clouddrive mount -h
, as shown here:
You can unmount a file share that's mounted to Cloud Shell at any time. Since Cloud Shell requires a mounted file share to be used, you will be prompted to create and mount another file share on the next session.
- Run
clouddrive unmount
. - Acknowledge and confirm prompts.
Your file share will continue to exist unless you delete it manually. Cloud Shell will no longer search for this file share on subsequent sessions. To view more details, run clouddrive unmount -h
, as shown here:
Warning
Although running this command will not delete any resources, manually deleting a resource group, storage account, or file share that's mapped to Cloud Shell will erase your $Home
directory disk image and any files in your file share. This action cannot be undone.
To discover which file share is mounted as clouddrive
, run the df
command.
The file path to clouddrive will show your storage account name and file share in the URL. For example, //storageaccountname.file.core.windows.net/filesharename
justin@Azure:~$ df
Filesystem 1K-blocks Used Available Use% Mounted on
overlay 29711408 5577940 24117084 19% /
tmpfs 986716 0 986716 0% /dev
tmpfs 986716 0 986716 0% /sys/fs/cgroup
/dev/sda1 29711408 5577940 24117084 19% /etc/hosts
shm 65536 0 65536 0% /dev/shm
//mystoragename.file.core.windows.net/fileshareName 5368709120 64 5368709056 1% /home/justin/clouddrive
justin@Azure:~$
[!include features-introblock]
Bash in Cloud Shell Quickstart
Learn about Microsoft Azure Files storage
Learn about storage tags