Linux disk and file system (2) ------- disk partition, format, check and mount.

Partitioning, formatting, checking and mounting of disks.

If we need to add a new hard disk to the system, what actions should we take?

1. Split the disk to create a usable partiton.
2. Format the partition to create a filesystem usable by the system.
3. If you want to be more careful, you can check the filesystem you just created
4. On the Linux system, you need to create a mount point (that is, a directory) and mount it.


     Since the number of disks and the environment on each host are different, you can first use the df command to find out the file names of the available disks and then use fdisk to view them.

fdisk -l can view all disk files


First, the steps to mount a hard disk on a virtual machine are explained. Just follow this step by step. (The virtual machine needs to be restarted, and the physical machine does not need to be restarted.)



(1) Separate and create partitions

fdisk /dev/sdb (followed by the partition to separate)



Start creating disk partitions


As shown above, we can also divide a partition.

Next we have to divide the extended partition. There can only be one extended partition. e (and account for all disks)





At this point, the creation of the disk partition is completed.


(2) Format the partition


(3) Mounting of the disk

Things to note before mounting:
 A single filesystem should not be mounted repeatedly on different mount points (directories).
A single directory should not mount multiple filesystems repeatedly
The directory to be used as a mount point should theoretically be an empty directory.




Follow the same steps to mount sd2, sd5, and sd6. (sd4 does not need to be mounted) That is to say, there are actually only four disks. sd4 is the extension

df, you can see that it has been successfully mounted.




(Additionally, unmount the disk: umont /dev/sdb1, this command is used to exit the sdb1 directory)


(4) Automatically mount /etc/fstab at boot

At this point, the disk has been successfully mounted. But if you restart your computer at this point, the disk will go offline. This leads to our next operation, let him start up.


At this point, you need to modify the fstab file.

vim /etc/fstab             

As follows


Column 1: Disk device filename or the device's Label   
The second column: mount point (mount point): must be a directory, the location where it is mounted
The third column: the file system of the disk partition slot: including ext4, reiserfs, nfs, vfat, etc.
The fourth column: file system parameters: generally use the default, and check it when you need specific configuration.
Column 5: Can it be used by the dump backup command
Column 6: Whether to check the sector with fsck


Add as follows:



Enter reboot to restart the verification.

fdisk  -l



At this point, the automatic mount is successful.







Guess you like

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