Linux服务器初始化系统盘后重新挂载数据盘方法

在本篇文章中我们给大家分享了LINUX初始化系统盘后重新挂载数据盘的解决方法,有需要的朋友们可以参考下。

Linux实例初始化系统盘后重新挂载数据盘

在Linux实例中,重新初始化系统盘不会改变数据盘里的内容,但是数据盘的挂载信息会丢失,所以,在Linux重启后,按以下步骤创建新的挂载点信息并挂载数据盘分区。

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

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

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。

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

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

mkdir /InitTest

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

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

mount /dev/vdb1 /InitTest

查看挂载结果:运行命令

df -h

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

卸载 /dev/vdb1:运行命令

umount /dev/vdb1

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

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

mount -a

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

以上就是本次介绍的全部内容,感谢大家对主机吧的支持。

声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。

给TA打赏
共{{data.count}}人
人已打赏
个人中心
购物车
优惠劵
搜索