Initialize a Disk
To use the attached disk, you need to initialize the disk first, including formatting, partitioning, and creating file systems.
Prerequisites
You have attached the disk to your elastic compute instance.
Background Information
Disks support the Master Boot Record (MBR) partition format.
MBR: recognize partitions up to 2 TiB in size and allows up to four partitions to be created on each disk.
Precautions
Disk partitioning and formatting are high-risk operations. Proceed with caution when you partition and format disks. This topic applies only to new disks.
Only disks can be partitioned. Please do not partition a Boot disk, otherwise risks such as system failures and data loss may occur.
Procedures
Run the following command to view the information of the disk attached.
fdisk -lPartition the disk. Assume
/dev/vdbis the disk name for illustration.Run the following command to partition the disk.
fdisk -u /dev/vdbEnter P to view the partition information of the disk.
Enter N to create a partition.
Enter P to set the partition as a primary partition.
Enter the partition number and press the Enter key.
Enter the number of the first available sector and press the Enter key.
Enter the number of the last sector and press the Enter key.
Enter P to view the partition information of the disk.
Enter W to start partitioning. Then, exit after the disk is partitioned.
Run the following command to view the new partition.
fdisk -lu /dev/vdbCreate a file system for the partition
Run the following command to create an
ext4file system.mkfs -t ext4 /dev/vdb1Run the following command to create an
xfsfile system.mkfs -t xfs /dev/vdb1
Configure the
/etc/fstabfile and mount the partition Write the information of the new partition to/etc/fstabto enable this partition to be automatically mounted on instance startup.Run the following command to back up
etc/fstab.cp /etc/fstab /etc/fstab.bakWrite the information of the new partition to
/etc/fstab.echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /mnt ext4 defaults 0 0 >> /etc/fstabDescription of the parameters in this command:
/dev/vdb1: the data disk partition that has a file system created. Replace it with your actual partition name./mnt: the directory to which the partition is mounted. Replace it with the actual directory of your partition.ext4: the file system type of the partition. Replace it with the type of the created file system.
Run the following command to check the information of the new partition in
/etc/fstab.cat /etc/fstabRun the following command to mount the file system configured in the
/etc/fstabfile.mount -aRun the following command to check the mount result.
df -h
Open the Disk Management window and find the disk that is not partitioned or formatted.
On the Windows Server desktop, click the Server Manager icon in the lower-left corner.
In the Server Manager window, choose Tools > Computer Management in the upper-right corner.
In the left-side navigation pane, choose Computer Management (Local) > Storage > Disk Management.
Find a disk that is not partitioned or formatted, which is in the Offline state.
Right-click the blank area around the disk and select Online. When the disk goes online, it enters the Not Initialized state.
Right-click the blank area around the disk and select Initialize Disk.
In the Initialize Disk dialog box, select the disk, select a partition format, and then click OK.
Right-click the Unallocated section and select New Simple Volume.
In the New Simple Volume Wizard dialog box, perform the following operations.
Click Next.
In the Specify Volume Size step, set Simple volume size in MB and click Next.
In the Assign Drive Letter or Path step, select Assign the following drive letter, select a drive letter, and then click Next.
In the Format Partition step, select Format this volume with the following settings, configure formatting settings, and then click Next.
Check the settings and click Finish.
Last updated