Technology Encyclopedia Home >How to check the disk of a Linux instance on a cloud server and format its partitions?

How to check the disk of a Linux instance on a cloud server and format its partitions?

To check the disk of a Linux instance on a cloud server, you can use the following commands:

  1. List all disks:
    Use lsblk or fdisk -l to view available disks and partitions.
    Example:

    lsblk
    

    or

    sudo fdisk -l
    
  2. Check disk usage:
    Use df -h to see mounted filesystems and their usage.
    Example:

    df -h
    
  3. Check disk health (if SMART is supported):
    Use smartctl (install via sudo apt install smartmontools or sudo yum install smartmontools).
    Example:

    sudo smartctl -a /dev/sda
    

To format a partition:

  1. Unmount the partition (if mounted):
    Example:

    sudo umount /dev/sdX1
    
  2. Format the partition (e.g., with ext4):
    Example:

    sudo mkfs.ext4 /dev/sdX1
    
  3. Mount the formatted partition:
    Example:

    sudo mount /dev/sdX1 /mnt/mydisk
    

If you're using Tencent Cloud, you can manage disks via the Tencent Cloud Console under Cloud Block Storage (CBS). For automated disk operations, Tencent Cloud provides Cloud-Init and Tencent Cloud API for scripting. Additionally, Tencent Cloud Monitor can help track disk performance.