To prevent files in the temporary storage space from being lost when your instance is released, attach and mount an File Storage NAS instance in Cloud Shell. This provides persistent storage for your common scripts and files.
Prerequisites
Cloud Shell depends on File Storage NAS (NAS) for persistent file storage. For more information about File Storage NAS, see What is Apsara File Storage NAS?.
To mount a storage space, create a pay-as-you-go, performance-type File Storage NAS instance. This may incur minor fees. For more information, see Billing overview.
Use a Resource Access Management (RAM) identity, such as a RAM user or RAM role, to access Cloud Shell. To create a NAS instance, grant the RAM identity the required File Storage NAS permissions. For more information, see Use RAM for access control.
Procedure
Attach and mount an File Storage NAS file system instance in Cloud Shell. This instance serves as the $HOME directory for your Cloud Shell instance. The directory provides persistent storage for your common scripts and files, which prevents them from being destroyed when the instance is released.
Mount a storage space
In the toolbar, click the Storage icon > Mount storage space.

In the dialog box that appears, click Create and Attach. The system creates a NAS instance and attaches it to Cloud Shell. Attaching a NAS instance for the first time may take several minutes.

After the NAS instance is created and attached, Cloud Shell automatically recreates the virtual machine. This process requires no manual intervention and takes no more than 30 seconds.
After the virtual machine is created, you can use the instance as usual. In the toolbar, click the Storage icon > Mount storage space to view the File System ID of the attached instance.

Click the File System ID to view the basic parameters of the instance.

Detach a storage space
In the toolbar, click the Storage icon > Detach storage space.

In the dialog box that appears, click Detach. Cloud Shell detaches the NAS instance.
NoteIf you no longer need the NAS service, manually release the file system instance. After the instance is released, the files stored in it are not retained. For more information, see Release a file system instance.
If you do not release the NAS instance, the instance is reattached when you mount a storage space again. A new NAS instance is not created.

After the NAS instance is detached, Cloud Shell automatically recreates the virtual machine. This process requires no manual intervention and takes no more than 30 seconds.
After the virtual machine is created, it uses the temporary storage space as the
$HOMEdirectory again. Your custom settings and third-party software installed on the instance are not retained. Files stored in the$HOMEdirectory are lost after the Cloud Shell instance is released.