« 上一篇下一篇 »

Linux系统新装或初始化后,应该如何快速重新挂载数据盘

  在Linux服务器的实际案例操作中,如果服务器需要初始化系统,您不需要改变数据盘数据,但是服务器初始化后需要对数据盘进行重新挂载,数据盘的挂载信息会丢失,所以,在Linux重启后,按以下步骤创建新的挂载点信息并挂载数据盘分区。

说明:本文档中,假设初始化系统盘之前,实例上挂载的数据盘分区名称为/dev/vdb1,挂载点名称为/InitTest。

一、查看数据盘挂载信息:运行命令 mount。返回结果中没有/dev/vdb1的信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs (rw,nosuid,size=497476k,nr_inodes=124369,mode=755)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_prio,net_cls)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpuacct,cpu)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset)
configfs on /sys/kernel/config type configfs (rw,relatime)
/dev/vda1 on / type ext4 (rw,relatime,data=ordered)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=29,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=9791)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=101620k,mode=700)

二、查看数据盘分区信息:运行命令 fdisk -l。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Disk /dev/vda: 42.9 GB, 42949672960 bytes, 83886080 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
Disk label type: dos
Disk identifier: 0x0008d73a
Device Boot   Start     End   Blocks  Id System
/dev/vda1  *    2048  83884031  41940992  83 Linux
Disk /dev/vdb: 25.8 GB, 25769803776 bytes, 50331648 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
Disk label type: dos
Disk identifier: 0xfe6d77c1
Device Boot   Start     End   Blocks  Id System
/dev/vdb1      2048  50331647  25164800  83 Linux

三、重新创建数据盘分区的挂载点:运行命令

1
mkdir /InitTest

说明:这里的挂载点名称必须与系统盘初始化之前/dev/vdb1的挂载点名称保持一致。您可以通过 cat /etc/fstab 命令查看原来的挂载点名称。

重新挂载数据盘分区:运行命令

1
mount /dev/vdb1 /InitTest

四、查看挂载结果:运行命令

1
df -h

检测/dev/vdb1是否能自动挂载:

卸载 /dev/vdb1:运行命令

1
umount /dev/vdb1

查看挂载信息:运行命令 mount。假如卸载成功,返回结果中不会有/dev/vdb1的信息。

自动挂载/dev/vdb1:运行命令

1
mount -a

查看挂载信息:运行命令 mount。假如自动挂载成功,返回结果中会有/dev/vdb1的信息。

 

小结:

  一般在window服务器的系统下面我们直接接上sata接口或者sas接口 都是可以直接读取磁盘里面的数据。Linux系统则不然,即使你接上去,硬盘里面数据不是能直接读取得到的,需要我们挂载 才可以识别得到