Three steps to mount a Linux hard disk
1. View all hard disks and confirm that you want to mount the hard disk:
Lists the overall disk space usage of the file system, which can be used to see how much space has been used and how much space is left on the disk.
df -h
List block device information: display your disk and disk partition information in a tree format
lsblk
If it is a new hard disk, it needs to be formatted. If it is not formatted, it cannot be mounted! Never format a hard drive that already contains data, otherwise all your data will be cleared.
sudo mkfs.ext4 /dev/sdb
2. Determine the location to mount:
3. One-time mounting (it still needs to be mounted after the machine restarts):
sudo mount /dev/sdb /home/wangtong/8t_hdd_wt
The reason for adding sudo is that the user may not have root permissions.
Implement automatic mounting
sudo vi /etc/fstab
Press Enter first , then i , then Enter again to enter insert mode.
Among them we can see that there are 6 columns:
-
Column 1 is the device to be mounted
-
Column 2 is the mount point (that is, the mount directory)
-
Column 3 is the file system or file system type of the device to be mounted.
-
Column 4 is the mount options, usually defaults can be used
-
Column 5 sets whether to use dump backup. Set 0 for no backup, set 1 and 2 for backup, but the backup of 2 is less important than 1.
-
Column 6 sets whether to use fsck to check the mounted disk when booting. Set 0 to not check, set 1 and 2 to check, but set 2 disk to check later than set 1 disk.
First press Esc to exit editing mode, then enter : wq! to force exit and save.
Mount all hard drives
sudo mount -a