centos磁盘挂载

通常情况下,云平台开出来的服务器只有默认的系统盘,而数据盘需要运维人员自己挂载在数据目录,此篇记录centos磁盘挂载的过程,以便今后遇到类似情况便于查看。

系统版本:centos7.9
1、查看磁盘情况:

[root@xus ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           7.9G   17M  7.8G   1% /run
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/vda1        20G  2.4G   18G  12% /
/dev/vdb1        69G   24K   66G   1% /dataext
tmpfs           1.6G     0  1.6G   0% /run/user/0

2、查看磁盘挂载

[root@xus ~]# fdisk -l
# /dev/vda已经做了分区 
Disk /dev/vda: 21.5 GB, 21474836480 bytes, 41943040 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: 0x0000c4ba

Device Boot      Start         End        Blocks     Id   System
/dev/vda1   *    2048        41929649     20963801   83   Linux

# /dev/vdb已经做了分区,如果还有未分区的空间,就没有下面的 /dev/vdb1 分区
Disk /dev/vdb: 75.2 GB, 75161927680 bytes, 146800640 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: 0xf8c48eec

Device Boot      Start         End        Blocks    Id   System
/dev/vdb1         2048       146800639    73399296   83   Linux

3、分区(操作完分区步骤后,就会看到步骤2的结果)

[root@xus ~]# fdisk /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 tableBuilding a new DOs disklabel with disk identifier 0x774b38c4
Command (m for help): #输入n回车,添加新分区,如果需要更多,请输入m回车看帮助

Partition type:
	p primary (0 primary,  extended, 4 free)
	e extended
select (default p): # 输入p回车,P的意思是主分区

Partition number (1-4): # 输入数字1回车,分区数量

First sector (2048-20971519,default 2048): #认回车
Using default value 2048

Last sector,+sectors or +sizefk,M,G) (2048-419430399,default 419430399): # 默认回车
Using default value 419430399
Partition 1 of type Linux and of size 200GiB is set

Command (m for help): # 输入w保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

4、格式化分区

[root@xus ~]# mkfs.ext4 /dev/vdb1

5、建立挂载目录

[root@xus ~]# mkdir /dataext

6、挂载分区

[root@xus ~]# mount /dev/vdb1 /dataext

7、设置开机自动挂载

[root@xus ~]# echo /dev/vdb1 /dataext  ext4 defaults 0 0 >> /etc/fstab

8.确认是否挂载成功

[root@xus ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           7.9G   17M  7.8G   1% /run
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/vda1        20G  2.4G   18G  12% /
/dev/vdb1        69G   24K   66G   1% /dataext    #这是挂载完的磁盘
tmpfs           1.6G     0  1.6G   0% /run/user/0

9、重启系统

[root@xus ~]# reboot

你可能感兴趣的:(centos,大数据,linux)