Automatic disk mount at startup
/etc/fstab Explanation
sudo vim /etc/fstab
# <file system> <mount point> <type> <options> <dump> <pass>
# <设备文件名称> <挂载目录> <文件系统类型> <文件系统参数> <是否备份> <开机时自检>
-
Device file name
The device name of the file system, device name (such as /dev/sda1), LABEL or UUID, UUID is recommended, (sudo blkid can view) -
Mount directory
Mount to the corresponding folder -
File system types
The following are most common file system types (ext3, tmpfs, devpts, sysfs, proc, swap, vfat) -
File system parameters
are generally set to defaults. -
Dump file system (backup or not)
1 - back up
0 - don't back up -
File system check,
the number in this field indicates whether the file system needs to be checked by fsck.
0 - indicates that the file system does not need to be checked,
1 - indicates that the file system needs to be checked first (for the root file system)
2 - indicates that the file system is checked after the root file system is checked
for example
Automatically mount at boot
sudo vim /etc/fstab
#加入下面内容
/dev/sdb /disk2 ext4 defaults 0 1
or
UUID=d765d835-4989-4bff-8ae8-116c654d4bba /disk2 ext4 defaults 0 2
The device name of the file system, device name (such as /dev/sda1), LABEL or UUID, UUID is recommended, (sudo blkid can be viewed)
- View hard drive list
sudo fdisk -lu
- View UUID
sudo blkid
Manual mount
- Add partitions to the new hard drive
sudo fdisk /dev/sdb
n:添加新分区
p:使用主分区
l:主分区编号为1,这样创建的分区为sdb1
- format new partition
sudo mkfs -t ext4 /dev/sdb #使用ext4格式化sdb分区
- Create a folder and mount the new partition to it
sudo mkdir /disk2
sudo mount /dev/sdb /disk2 #将sdb1挂载到/disk2文件夹上
- unmount partition
sudo umount /disk2
Currently, our machines:
sudo mount /dev/sdb /data