Linux Disk Management: Partitioning, Formatting

Reference: http://blog.csdn.net/nahancy/article/details/52201121

Usually when adding a disk or a new system, it is essential to format the disk, partition, and mount the partition. Friends who have played with Ali and other virtual hosts know that the data disk needs to be partitioned and mounted by itself. It is indeed a difficult problem for novices, so remember it for reference!

Use the df -lh command to check that the system only has the system disk.

Use fdisk -l to view the disk status. From the figure below, you can see that there is a disk that is not partitioned, and remember it as the identifier of the partition. Here we are /dev/xvdb:

To execute fdisk /dev/xvdb to partition the disk, you need to enter "n", "p", "1" in turn, enter twice, "wq":

[plain]  view plain  copy
  1. fdisk /dev/xvdb  


After the completion, execute fdisk -l to see the partitioned disk, and remember that the drive letter identifies us here as /dev/xvdb1. Now that all the partitions are divided, isn’t it amazing? The answer is no, it's not over yet.

Format the partition:

[plain]  view plain  copy
  1. mkfs.ext4 /dev/xvdb1  

After formatting, mount the partition:

1. Write the partition information to fstab

[plain]  view plain  copy
  1. echo '/dev/xvdb1 /mjydata ext4 defaults 0 0' >> /etc/fstab  
2. Mount the partition

[plain]  view plain  copy
  1. mount -a  


Then use the df -lh command to view, there is a new partition:


At this point, the entire Linux disk is partitioned and mounted Smile.


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325410046&siteId=291194637