首页 技术 正文
技术 2022年11月19日
0 收藏 396 点赞 2,284 浏览 2476 个字

Linux下磁盘挂载

公司新订购阿里云ECS,需要挂载当前的磁盘。暂时没有运维,自己动手挂载磁盘。

具体步骤如下:

1、查看是否已经分配

[root@iZ2ze1tefvghtbgkdur3xfZ /]# fdisk -l
[root@iZ2ze1tefvghtbgkdur3xfZ server]# 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: 0x0009e68a
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83884031 41940992 83 Linux
Disk /dev/vdb: 64.4 GB, 64424509440 bytes, 125829120 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

2、发现有磁盘,路径为/dev/vdb。然后使用fdisk命令进行建立分区

[root@iZ2ze1tefvghtbgkdur3xfZ /]#fdisk /dev/vdb

fdisk命令如下:

Linux阿里云挂载磁盘,并开机自动挂载

命令(输入 m 获取帮助):m
命令操作
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Linux阿里云挂载磁盘,并开机自动挂载

3、然后先新建分区(我这里因为要存储大数据库文件   所以逻辑全部是一个分区)

Linux阿里云挂载磁盘,并开机自动挂载

命令(输入 m 获取帮助):n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):
Using default response p
分区号 (1-4,默认 1):
起始 扇区 (2048-3221225471,默认为 2048):
将使用默认值 2048
Last 扇区, +扇区 or +size{K,M,G} (2048-3221225471,默认为 3221225471):
将使用默认值 3221225471
分区 1 已设置为 Linux 类型,大小设为 1.5 TiB

Linux阿里云挂载磁盘,并开机自动挂载

4、最后保存分区

命令(输入 m 获取帮助):w
The partition table has been altered!Calling ioctl() to re-read partition table.
正在同步磁盘。

5、使用fdisk -l命令查看,已经有分区了

Linux阿里云挂载磁盘,并开机自动挂载

磁盘 /dev/sdb:1649.3 GB, 1649267441664 字节,3221225472 个扇区
Units = 扇区 of 1 * 512 = 512 bytes
扇区大小(逻辑/物理):512 字节 / 512 字节
I/O 大小(最小/最佳):512 字节 / 512 字节
磁盘标签类型:dos
磁盘标识符:0xe0bc0098 设备 Boot Start End Blocks Id System
/dev/sdb1 2048 3221225471 1610611712 83 Linux

Linux阿里云挂载磁盘,并开机自动挂载

6、建好分区后要格式化分区,建立文件系统

Linux阿里云挂载磁盘,并开机自动挂载

 [root@localhost home]# mkfs.ext4 /dev/vdb
meta-data=/dev/sdb1 isize=256 agcount=4, agsize=100663232 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=402652928, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=196607, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

Linux阿里云挂载磁盘,并开机自动挂载

7、这样文件系统就建好了,然后选择一个挂载点挂上就可以了,我挂载在/server 下了

[root@localhost home]# mount /dev/vdb /server/

8、查看一下挂载是否成功了

[root@localhost home]# df -TH /server
文件系统 类型 容量 已用 可用 已用% 挂载点
/dev/sdb1 xfs 1.7T 34M 1.7T 1% /home/data

9、修改一下系统配置加入下列行到/etc/fstab,让系统启动后自动挂载,否则有可能会掉啊

UUID=5392f2ec-3101-4c14-a817-a53ab48070ae /server       ext4 defaults,barrier=0 1 1
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,994
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,507
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,350
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,135
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,768
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,845