A bucket is a container that is used to store objects in Object Storage Service (OSS). You must create a bucket before you upload any objects to OSS. This topic describes how to create a bucket by using the mb command.

Note This topic provides sample command lines that are based on the 64-bit Linux system. For other systems, replace ./ossutil64 in the commands with the corresponding binary name. For more information, see ossutil.

Create a bucket based on the options that are specified in the command

Command syntax

./ossutil64 mb oss://bucketname 
[--acl <value>]
[--storage-class <value>]
[--redundancy-type <value>]

The following table describes the parameters that are used in the preceding statements.

ParameterDescription
bucketnameThe name of the bucket that you want to create. A bucket name must be globally unique within OSS. The name of a bucket cannot be changed after the bucket is created.
--aclThe access control list (ACL) of the bucket. Default value: private. Valid values:
  • private: Only the bucket owner can perform read and write operations on the objects in the bucket. Other users cannot access the objects in the bucket.
  • public-read: Only the bucket owner can perform write operations on the objects in the bucket. Other users, including anonymous users, can perform only read operations on the objects in the bucket. This may result in unauthorized access to objects and high fees. If a user uploads prohibited data or information to the objects, your legitimate interests and rights may be infringed. We recommend that you do not set this parameter to public-read unless necessary.
  • public-read-write: All users, including anonymous users, can perform read and write operations on the objects in the bucket. This may result in unauthorized access to the data in your bucket and high fees. Proceed with caution when you set this parameter to public-read-write.
--storage-classThe storage class of the bucket. Default value: Standard. Valid values:
  • Standard: This storage class is suitable for data that is frequently accessed.
  • IA: This storage class is suitable for data that is infrequently accessed, such as once or twice a month. Infrequent Access (IA) objects have a minimum storage period of 30 days and a minimum billable size of 64 KB. You can access IA objects in real time. You are charged data retrieval fees when you access IA objects.
  • Archive: This storage class is suitable for data that needs to be stored for a long period of time. Archive objects have a minimum storage period of 60 days and a minimum billable size of 64 KB. You must restore an Archive object before you can access it. The amount of time that is required to restore an Archive object is approximately one minute. You are charged data retrieval fees when you restore Archive objects.
  • ColdArchive: This storage class is suitable for data that needs to be stored over an ultra-long period of time. Cold Archive objects have a minimum storage period of 180 days and a minimum billable size of 64 KB. You must restore a Cold Archive object before you can access it. The amount of time that is required to restore a Cold Archive object varies based on the object size and the restoration mode. You are charged data retrieval fees when you restore Cold Archive objects.

For more information about storage classes, see Overview.

--redundancy-typeThe redundancy type of the bucket. Default value: LRS. Valid values:
  • LRS: If you set the redundancy type of a bucket to locally redundant storage (LRS), OSS stores the copies of each object across different devices within the same zone. This way, OSS ensures data reliability and availability even if two storage devices are damaged at the same time.
  • ZRS: ZRS uses the multi-zone mechanism to distribute user data across multiple zones in the same region. If one zone becomes unavailable, you can continue to access the data that is stored in other zones.
Note Zone-redundant storage (ZRS) is supported in the following regions: China (Shenzhen), China (Beijing), China (Hangzhou), China (Shanghai), China (Hong Kong), Singapore, and Indonesia (Jakarta). You are charged additional fees for ZRS. This feature cannot be disabled after it is enabled. Exercise caution when you enable this feature.

Examples

  • You can run the following command to create a bucket named examplebucket:
    ./ossutil64 mb oss://examplebucket

    If you do not specify the region in which you want to create the bucket, the bucket is created in the region specified by the endpoint in the ossutil configuration file. For example, if the endpoint specified in the configuration file is https://oss-cn-hangzhou.aliyuncs.com, the bucket is created in the China (Hangzhou) region.

  • You can run the following command to create a bucket named examplebucket and set the ACL of the bucket to private, storage class to IA, and redundancy type to ZRS:
    ./ossutil64 mb oss://examplebucket --acl private --storage-class IA --redundancy-type ZRS
  • If the following output is displayed, the examplebucket bucket is created:
    0.335189(s) elapsed

Create a bucket based on the XML structure that is specified in the command

Command syntax

./ossutil64 mb oss://bucketname local_xml_file

The following table describes the parameters that are used in the preceding statements.

ParameterDescription
bucketnameThe name of the bucket that you want to create.
local_xml_fileThe local file path that contains bucket configurations, such as localfile.xml.

Examples

  1. You can run the following command to specify the bucket configurations based on the XML structure in the local file path localfile.xml:
    <?xml version="1.0" encoding="UTF-8"?>
    <CreateBucketConfiguration>    
        <StorageClass>IA</StorageClass>
        <DataRedundancyType>LRS</DataRedundancyType>
    </CreateBucketConfiguration>
  2. You can run the following command to obtain the bucket configurations from the local file path by using ossutil and add the configurations to the bucket that you want to create:
    ./ossutil64 mb oss://examplebucket localfile.xml

Common options

If you use ossutil to switch to a bucket that is located in another region, add the -e option to the command to specify the endpoint of the region in which the specified bucket is located. If you use ossutil to switch to a bucket that belongs to another Alibaba Cloud account, you can add the -i option to the command to specify the AccessKey ID of the specified account, and add the -k option to the command to specify the AccessKey secret of the specified account.

For example, you can run the following command to create a bucket named examplebucket that is located in the China (Shanghai) region and that belongs to another Alibaba Cloud account.
./ossutil64 mb oss://examplebucket -e oss-cn-shanghai.aliyuncs.com -i LTAI4Fw2NbDUCV8zYUzA****  -k 67DLVBkH7EamOjy2W5RVAHUY9H****

For more information about other common options that you can specify in the sync command, see Common options.