跟老姚学前端,课程体系更完善,10%基础 + 90%实战演练,快人一步学编程

扫一扫浏览

Linux磁盘查看与挂载,阿里云服务器如何挂盘

未结贴
0 5394
混底薪站长未认证 2019-03-19 10:01:16
收藏

在阿里云新买了一台新的服务器,但默认新添加的数据盘是没有挂载的

tpframe_阿里云添加新盘

新买的阿里云服务器如果进行挂盘呢?在线工单问了客户,说要按照https://help.aliyun.com/document_detail/25426.html?spm=a2c4g.11186623.2.21.33de7d56WddCtM#concept-jl1-qzd-wdb这里进行挂盘操作,点开看到这样链接后,我就从上往下看了下,当看到“单独 购买的数据盘 必须先 挂载数据盘 才能格式化。随实例一起购买的数据盘,无需挂载。”,关键的是“随实例一起购买的数据盘,无需挂载”,我就很气了,这明明就是一起购买的,所以别认为他们说的你就信了,所以还是老老实实的按照命令进行操作

首页看你是否有待要挂的盘,通过命令fdisk -l查看

新磁盘

这里有这么一个盘须要进行挂载,开始挂载操作:

注意:
如果数据盘设备名为 dev/xvd?(? 是 a−z 的任意一个字母),表示您使用的是非 I/O 优化实例。
执行命令后,如果不存在 /dev/vdb,表示您的实例没有数据盘。确认数据盘是否已挂载。

依次执行以下命令以创建一个单分区数据盘

运行 fdisk -u /dev/vdb:分区数据盘。
输入 p:查看数据盘的分区情况。本示例中,数据盘没有分区。
输入 n:创建一个新分区。
输入 p:选择分区类型为主分区。
输入分区编号并按回车键。本示例中,仅创建一个分区,输入 1。
输入第一个可用的扇区编号:按回车键采用默认值 2048。
输入最后一个扇区编号:本示例仅创建一个分区,按回车键采用默认值。
输入 p:查看该数据盘的规划分区情况。
输入 w:开始分区,并在分区后退出。
[root@iZbp1it9lc0o7e2ywaaiumZ soft]# fdisk -u /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x9201b376.

Command (m for help): p

Disk /dev/vdb: 171.8 GB, 171798691840 bytes, 335544320 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: 0x9201b376

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-335544319, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-335544319, default 335544319): 
Using default value 335544319
Partition 1 of type Linux and of size 160 GiB is set

Command (m for help): p

Disk /dev/vdb: 171.8 GB, 171798691840 bytes, 335544320 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: 0x9201b376

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   335544319   167771136   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

运行命令 fdisk -lu /dev/vdb 查看新分区

如果出现以下信息,表示新分区 /dev/vdb1创建成功。

[root@iZbp1it9lc0o7e2ywaaiumZ soft]# fdisk -lu /dev/vdb

Disk /dev/vdb: 171.8 GB, 171798691840 bytes, 335544320 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: 0x9201b376

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   335544319   167771136   83  Linux

在这里还没有结束,继续

运行命令 mkfs.ext4 /dev/vdb1在新分区上创建一个文件系统。

本示例中,创建一个 ext4 文件系统。您也可以根据自己的需要,选择创建其他文件系统,例如,如果您需要在 Linux、Windows 和 Mac 系统之间共享文件,可以使用 mkfs.vfat 创建 VFAT 文件系统。

[root@iZbp1it9lc0o7e2ywaaiumZ soft]# mkfs.ext4 /dev/vdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
10485760 inodes, 41942784 blocks
2097139 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2189426688
1280 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
	4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done 

(建议)运行命令 cp /etc/fstab /etc/fstab.bak 备份 etc/fstab

运行命令 echo /dev/vdb1 /mnt ext4 defaults 0 0 >> /etc/fstab 向 /etc/fstab 写入新分区信息。

说明 Ubuntu 12.04 不支持 barrier,因此Ubuntu 12.04系统需要运行命令 echo '/dev/vdb1 /mnt ext4 barrier=0 0 0' >> /etc/fstab。

如要把数据盘单独挂载到某个文件夹,例如单独用来存放网页,则将命令中 /mnt 替换成所需的挂载点路径。

运行命令 cat /etc/fstab 查看 /etc/fstab 中的新分区信息。

[root@iZbp1it9lc0o7e2ywaaiumZ soft]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Nov 29 03:34:10 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=b98386f1-e6a8-44e3-9ce1-a50e59d9a170 /                       ext4    defaults        1 1
/dev/vdb1 /mnt ext4 defaults 0 0

运行命令 mount /dev/vdb1 /mnt 挂载文件系统。

运行命令 df -h 查看目前磁盘空间和使用情况

出现新建文件系统的信息,表示挂载成功,您不需要重启实例即可以使用新的文件系统

[root@iZbp1it9lc0o7e2ywaaiumZ soft]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G  1.8G   36G   5% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G  460K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           783M     0  783M   0% /run/user/0
/dev/vdb1       158G   61M  150G   1% /mnt

到此,整个挂盘操作就完成了,今天遇到的这个问题记录一下,希望对你有帮助。

最近热帖 HOT TOPIC
【全套视频】thinkphp5视频教程 85798
父元素flex之后,子元素高度自适应问题 10855
一张纸的厚度是0.01毫米,则该纸对折30次后是多厚(据说超过珠穆朗玛峰的高度)php实现 9849
thinkphp5隐藏默认模块的一些问题 9319
api接口文档插件easydoc的基本用法,快速搞定接口文档 9268
omnicore rpc api中文手册【usdt】 9088
PHP如何判断字符串是否为json格式 9004
教你如果处理高并发数据不同步的问题php篇 8942
关于thinkphp5.0.x getshell漏洞的说明 8668
使用宝塔linux面板创建FTP无法连接的解决办法(阿里云或腾讯云) 8440
月度热议HOT COMMENTS
【全套视频】thinkphp5视频教程 70
tpframe 后续版本你希望有的功能是什么(分享贴) 12
权限那里怎么一登录别的账号就报错啊 9
关于tpframe的一点话题 6
cms插件在分类排序的时候JSON错误 6
基于tpframe v3.x 的微信公众号插件已批量上线 5
tpframe插件tcms插件v2.2已发布上线,欢迎下载使用 5
tpframe6.0马上就要跟大家见面了,一次全新的升级 5
透析thinkphp5升级版开发框架tpframe 3
新增的管理员没有权限操作CMS模块。 3
爆料早知道: