###########################################################################
###########################################################################
Run the following command to install the e2fsprogs and parted :
yum install -y parted
yum install -y e2fsprogs
Perform the following operations to partition and format a data disk larger than 2 TiB in size and mount the file system.
Check whether a data disk exists.
Run the following command:
fdisk -l
A command output similar to the following one is returned. The command output includes information about the data disk. If no data disk information is returned, the instance does not have data disks attached.
Disk /dev/vdb: 3221.2 GB, 3221225472000 bytes, 6291456000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Use the Parted tool to partition the data disk.
Run the following command to start partitioning:
parted /dev/sdb
Run the following command to convert the partition format from MBR to GPT:
mklabel gpt
Run the following command to create a primary partition and specify the start and end sectors for the partition:
mkpart primary 1 100%
where the 100% is total size of the disk allocated, you can choose as required.
Run the following command to start partitioning:
parted /dev/sdb
Run the following command to convert the partition format from MBR to GPT:
mklabel gpt
Run the following command to create a primary partition and specify the start and end sectors for the partition:
mkpart primary 1 100%
where the 100% is total size of the disk allocated, you can choose as required.
Run the following command to check whether the partition is aligned:
align-check optimal 1
A command output similar to the following one is returned:
1 aligned
Note: -
align-check optimal 1
A command output similar to the following one is returned:
1 aligned
Note: -
If 1 not aligned is returned, the partition is not aligned.
We recommend that you run the following commands
and use the (<optimal_io_size> + <alignment_offset>)/<physical_block_size> formula to obtain the start sector number to align the partition for optimal performance.
For example, if the start sector number is 1024, you can then run the mkpart primary 1024s 100% command to create another primary partition.
cat /sys/block/vdb/queue/optimal_io_size
cat /sys/block/vdb/queue/minimum_io_size
cat /sys/block/vdb/alignment_offset
cat /sys/block/vdb/queue/physical_block_size
Run the following command to view the partition table:
print
Run the following command to exit the Parted tool:
quit
The following figure shows the result of partitioning by using the Parted tool.Partitioning by using Parted
Run the following command to enable the system to re-read the partition table:
partprobe
Run one of the following commands to create a file system for the /dev/vdb1 partition.
Run one of the following commands to create a file system based on your needs:
Create an ext4 file system.
mkfs -t ext4 /dev/vdb1
Run the following command to create a mount point named /test:
mkdir /test
Run the following command to mount the /dev/vdb1 partition to /test:
mount /dev/vdb1 /test
Run the following command to view the current disk space and usage:
df -h
If the command output shows the information of the new file system, the mount operation is successful. You can use the new file system.df output
cat /sys/block/vdb/queue/minimum_io_size
cat /sys/block/vdb/alignment_offset
cat /sys/block/vdb/queue/physical_block_size
Run the following command to view the partition table:
Run the following command to exit the Parted tool:
quit
The following figure shows the result of partitioning by using the Parted tool.Partitioning by using Parted
Run the following command to enable the system to re-read the partition table:
partprobe
Run one of the following commands to create a file system for the /dev/vdb1 partition.
Run one of the following commands to create a file system based on your needs:
Create an ext4 file system.
mkfs -t ext4 /dev/vdb1
Run the following command to create a mount point named /test:
mkdir /test
Run the following command to mount the /dev/vdb1 partition to /test:
mount /dev/vdb1 /test
Run the following command to view the current disk space and usage:
df -h
If the command output shows the information of the new file system, the mount operation is successful. You can use the new file system.df output
(Recommended) Write the information of the new partition to /etc/fstab to enable this partition to be automatically mounted on system startup.
Run the cp /etc/fstab /etc/fstab.bak command to back up etc/fstab:
Run the following command to write information of the new partition to /etc/fstab:
echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /test ext4 defaults 0 0 >> /etc/fstab
Note
You must run the command as the root user. If you are a common user,
you can run the su - command to switch to the root user, and then run this command.
Alternatively, you can run the sudo vi /etc/fstab command to edit /etc/fstab.
We recommend that you use a universally unique identifier (UUID) to reference the new partition in /etc/fstab.
You can run the blkid command to obtain the UUID of the new partition.
Run the following command to check the information of /etc/fstab:
cat /etc/fstab
###########################################################################
Run the cp /etc/fstab /etc/fstab.bak command to back up etc/fstab:
Run the following command to write information of the new partition to /etc/fstab:
echo `blkid /dev/vdb1 | awk '{print $2}' | sed 's/\"//g'` /test ext4 defaults 0 0 >> /etc/fstab
Note
You must run the command as the root user. If you are a common user,
you can run the su - command to switch to the root user, and then run this command.
Alternatively, you can run the sudo vi /etc/fstab command to edit /etc/fstab.
We recommend that you use a universally unique identifier (UUID) to reference the new partition in /etc/fstab.
You can run the blkid command to obtain the UUID of the new partition.
Run the following command to check the information of /etc/fstab:
cat /etc/fstab
###########################################################################
###########################################################################