教程针对已经挂载过的磁盘,若没有挂载过请百度格式化后挂载磁盘
服务器到期后续费,磁盘没有写入/etc/fstab挂载磁盘消失
使用fdisk -l
查看挂载的磁盘
root@iZj6cg7d2xorzj0189br77Z:/# fdisk -l
Disk /dev/vda: 500 GiB, 536870912000 bytes, 1048576000 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
Disklabel type: dos
Disk identifier: 0x5b0a964e
Device Boot Start End Sectors Size Id Type
/dev/vda1 * 2048 1048575966 1048573919 500G 83 Linux
Disk /dev/vdb: 1.5 TiB, 1610612736000 bytes, 3145728000 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
Disklabel type: dos
Disk identifier: 0x2d593caf
Device Boot Start End Sectors Size Id Type
/dev/vdb1 2048 3145727999 3145725952 1.5T 83 Linux
可以看到1.5T的盘,使用df -h
查看被挂载
root@iZj6cg7d2xorzj0189br77Z:/# df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.9G 0 7.9G 0% /dev
tmpfs 1.6G 3.2M 1.6G 1% /run
/dev/vda1 493G 246G 227G 53% /
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
tmpfs 1.6G 0 1.6G 0% /run/user/0
可以看到未被挂载,使用命令mount /dev/vdb1 /mnt2
挂载到服务器
root@iZj6cg7d2xorzj0189br77Z:/# df -h
Filesystem Size Used Avail Use% Mounted on
udev 7.9G 0 7.9G 0% /dev
tmpfs 1.6G 3.2M 1.6G 1% /run
/dev/vda1 493G 246G 227G 53% /
tmpfs 7.9G 0 7.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
tmpfs 1.6G 0 1.6G 0% /run/user/0
/dev/vdb1 1.5T 368G 1.1T 27% /mnt2
磁盘已被挂载,使用命令vi /etc/fstab
加入以下内容
/dev/vdb1 /mnt2 ext4 defaults 0 0
即可保证重启后不需要重新挂载
2019/07/24更新
如果新购买的服务器直接加了一块硬盘
需要先在根目录mkdir /mnt2
mkfs.ext4 /dev/sdb
然后再回到上边mount命令