Purpose
This KB explains how to configure CMP S3 bucket storage on a Linux VM using:
- s3cmd for command-line S3 operations
- s3fs for mounting the S3 bucket as a filesystem
Using this setup, you can upload, download, mount, and manage files in a CMP S3 bucket from a Linux server.
Prerequisites
Before starting, make sure you have the following:
- A Linux VM, for example Ubuntu
- CMP S3 Access Key
- CMP S3 Secret Key
- Target bucket name: linux-backup-test
- Basic knowledge of Linux command-line operations
- Internet connectivity from the Linux VM to the CMP S3 endpoint
Understanding CMP S3 Access Control
CMP S3 supports two access modes:
Bucket visibility
- Public bucket
- Private bucket
Access using keys
The Access Key and Secret Key generated from CMP S3 provide access to CMP S3 resources.
Note: Keys created in CMP S3 work only within CMP S3.
How to Create Access Key and Secret Key in CMP
To access CMP S3 buckets securely, you need to generate an Access Key and Secret Key.
Steps:
- Log in to the CMP Dashboard.
- Navigate to Object Storage.
- Click on the Access tab.
- You will see fields like:
Region
User ID
Accounts
Status
- Click on the required access section.
- Click on Create First Key or Create Key if one already exists.
- Copy the generated:
Access Key
Secret Key
Important: Save the Secret Key securely, as it is shown only once.
Installing s3cmd on Linux VM
Run the following commands:
sudo apt update
sudo apt install s3cmd -y
Verify the installation:
Configuring s3cmd for CMP S3
Run the configuration wizard:
Enter the following details when prompted:
Prompt : Value
Access Key : <Your-Access-Key>
Secret Key : <Your-Secret-Key>
Default Region : in-west2
S3 Endpoint : s3.in-west2.purestore.io
DNS-style bucket+hostname:port template : %(bucket)s.s3.in-west2.purestore.io
Encryption password : Optional or leave blank
Path to GPG program : /usr/bin/gpg
Use HTTPS protocol : True
HTTP Proxy server name : Leave blank unless required
HTTP Proxy server port : 0
Note: Do not add https:// in the S3 Endpoint field during s3cmd –configure.
Validate s3cmd Configuration
Run the following command to check bucket access:
Expected output should show the available bucket, for example:
Common Operations Using s3cmd
s3cmd ls s3://linux-backup-test
Before uploading, create a test file on the server:
echo “This is a test file for CMP S3 upload” > today1234.txt
Verify the file:
ls -lh today1234.txt
cat today1234.txt
Upload the test file to the CMP S3 bucket:
s3cmd put today1234.txt s3://linux-backup-test
Verify the uploaded file:
s3cmd ls s3://linux-backup-test
Download the file from the bucket:
s3cmd get s3://linux-backup-test/today1234.txt
To download the file to a specific directory:
mkdir -p /mnt/cmp-s3
s3cmd get s3://linux-backup-test/today1234.txt /mnt/cmp-s3/today1234.txt
Verify the downloaded file:
ls -lh /mnt/cmp-s3/today1234.txt
cat /mnt/cmp-s3/today1234.txt
Mount CMP S3 as a Filesystem Using s3fs
s3fs allows you to mount the CMP S3 bucket as a local directory on the Linux server.
sudo apt update
sudo apt install s3fs -y
Create the password file using the Access Key and Secret Key:
echo ACCESS_KEY:SECRET_KEY > ~/.passwd-s3fs
Example:
echo ABCD123456789:xyzsecretkey123456789 > ~/.passwd-s3fs
Set secure permission:
Important: Replace ACCESS_KEY and SECRET_KEY with the actual CMP S3 credentials.
Create the directory where the bucket will be mounted:
Verify the directory:
Mount the bucket linux-backup-test on /mnt/cmp-s3:
s3fs linux-backup-test /mnt/cmp-s3 -o url=https://s3.in-west2.purestore.io -o use_path_request_style
Check whether the bucket is mounted successfully:
Expected output:
s3fs on /mnt/cmp-s3 type fuse.s3fs
You can also check using:
List files from the mounted bucket:
File Operations Using Mounted S3 Directory
Once the bucket is mounted, you can manage files like a normal Linux directory.
Create a local test file:
echo “This is a test upload using s3fs mount” > /root/localfile.txt
Verify it:
ls -lh /root/localfile.txt
cat /root/localfile.txt
- Upload File to Bucket Using cp Command
Copy the local file to the mounted S3 bucket:
cp /root/localfile.txt /mnt/cmp-s3/
Verify:
You can also verify using s3cmd:
s3cmd ls s3://linux-backup-test
- Create a New File Directly in Mounted Bucket
Create a file directly inside the mounted S3 bucket:
echo “Hello CMP S3” > /mnt/cmp-s3/hello.txt
Verify:
ls -lh /mnt/cmp-s3/hello.txt
cat /mnt/cmp-s3/hello.txt
- Download/Copy File from Mounted Bucket to Local Server
Create a local download directory:
Copy the file from mounted bucket to local directory:
cp /mnt/cmp-s3/hello.txt ~/Downloads/
Verify:
ls -lh ~/Downloads/hello.txt
cat ~/Downloads/hello.txt
- Delete a File from Bucket
Delete the file from the mounted S3 bucket:
Verify:
Or verify using:
s3cmd ls s3://linux-backup-test
Unmount the Bucket
When the work is completed, unmount the bucket:
fusermount -u /mnt/cmp-s3
If fusermount is not available, use:
Verify that it is unmounted:
If no output is shown, the bucket has been unmounted successfully.
Important Notes
- Make sure the mount directory exists before running the s3fs mount command.
- Keep the .passwd-s3fs file secure with 600 permission.
- Do not share the Secret Key with anyone.
- Use HTTPS endpoint for secure connectivity.
- For persistent mount after reboot, an entry can be added in /etc/fstab with proper credential handling.
- If s3cmd ls gives a connection refused error, check that use_https = True is configured in ~/.s3cfg.
Troubleshooting
Issue: Connection Refused
Error:
ERROR: Could not connect to server: [Errno 111] Connection refused
Check the ~/.s3cfg file:
Make sure this value is set:
Also confirm the endpoint:
host_base = s3.in-west2.purestore.io
host_bucket = %(bucket)s.s3.in-west2.purestore.io
Issue: File Not Found During Copy
Error:
cp: cannot stat ‘/path/to/localfile.txt’: No such file or directory
Reason:
/path/to/localfile.txt is only a sample path. You need to create an actual file first.
Create a test file:
echo “This is a test file” > /root/localfile.txt
Then copy it:
cp /root/localfile.txt /mnt/cmp-s3/
Issue: Mount Directory Does Not Exist
Create the mount directory:
Then run the mount command again.
Conclusion
CMP S3 bucket storage can be accessed from Linux using both s3cmd and s3fs.
- s3cmd is useful for CLI-based upload/download operations.
- s3fs is useful when you want to mount the S3 bucket as a local filesystem.
In this setup, the bucket linux-backup-test was configured and mounted successfully on: