ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

华为云服务器磁盘挂载实战记录

2021-07-02 18:54:31  阅读:272  来源: 互联网

标签:default bytes dev 华为 2048 磁盘 挂载 512 size


背景:买了一台华为云服务器,挂载磁盘,之前都是先找资料,好记性不如烂笔头,先记录下。废话不多说,直接上干货

1、执行以下命令,查看新增数据盘。一般是/dev/vdb

执行命令查看磁盘信息:fdisk -l

[root@ecs-test-0001 ~]# 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: 0x000bcb4e

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83886079    41942016   83  Linux

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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

表示当前的云服务器有两块磁盘,“/dev/vda”是系统盘,“/dev/vdb”是新增数据盘。

2、执行以下命令,进入fdisk分区工具,开始对新增数据盘执行分区操作。

fdisk /dev/vdb

回显类似如下信息:
[root@ecs-test-0001 ~]# 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 table
Building a new DOS disklabel with disk identifier 0x38717fc1.

Command (m for help): 

 

3、输入“n”,按“Enter”,开始新建分区。

回显类似如下信息:
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended

4、以创建一个主要分区为例,输入“p”,按“Enter”,开始创建一个主分区。

Select (default p): p
Partition number (1-4, default 1): 

5、以分区编号选择“1”为例,输入主分区编号“1”,按“Enter”。

Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048):

 

6、以选择默认起始磁柱值2048为例,按“Enter”。

First sector (2048-209715199, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
 

 

7、以选择默认按“Enter”。

Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199):
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set

Command (m for help):
 

 

8、输入“p”,按“Enter”,查看新建分区的详细信息。

Command (m for help): p

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 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: 0x38717fc1

   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   209715199   104856576   83  Linux

Command (m for help):
 

 

9、输入“w”,按“Enter”,将分区结果写入分区表中。

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

Calling ioctl() to re-read partition table.
Syncing disks.
10、执行以下命令,将新的分区表变更同步至操作系统。

partprobe

11、格式化磁盘

[root@ecs-test-0001 ~]# mkfs -t 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
6553600 inodes, 26214144 blocks
1310707 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 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
  10、执行完后,就可以愉快的挂载了。执行以下命令,新建挂载目录。

 

mkdir 挂载目录

以新建挂载目录“/mnt/sdc”为例:

mkdir /mnt/sdc

mount 磁盘分区 挂载目录

以挂载新建分区“/dev/vdb1”至“/mnt/sdc”为例:

mount /dev/vdb1 /mnt/sdc

[root@ecs-test-0001 ~]# df -TH
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/vda1      ext4       43G  1.9G   39G   5% /
devtmpfs       devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs          tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs          tmpfs     2.0G  9.1M  2.0G   1% /run
tmpfs          tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
tmpfs          tmpfs     398M     0  398M   0% /run/user/0
/dev/vdb1      ext4      106G   63M  101G   1% /mnt/sdc
11、以上就完成了

 

标签:default,bytes,dev,华为,2048,磁盘,挂载,512,size
来源: https://blog.51cto.com/u_12737513/2972201

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有