阿里云ECS数据盘初始化

Linux系统挂载数据盘

1.查看当前硬盘

[root@EPROS ~]# fdisk -l
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 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
Disklabel type: dos
Disk identifier: 0xca2533dd

Device     Boot Start       End   Sectors Size Id Type
/dev/vda1  *     2048 104857566 104855519  50G 83 Linux


Disk /dev/vdb: 800 GiB, 858993459200 bytes, 1677721600 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/sda为系统盘,/dev/sdb为数据盘,并未分区

2.创建磁盘分区

[root@EPROS ~]# fdisk /dev/vdb 

Welcome to fdisk (util-linux 2.32.1).
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.
Created a new DOS disklabel with disk identifier 0x98f69975.

Command (m for help): n   ##创建新的分区,n表示new
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p   #选择主分区
Partition number (1-4, default 1):  #此处回车
First sector (2048-1677721599, default 2048): #回车
Last sector, +sectors or +size{K,M,G,T,P} (2048-1677721599, default 1677721599): #回车

Created a new partition 1 of type 'Linux' and of size 800 GiB.

Command (m for help): wq #保存退出(write & quit)
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

此时再查看一下磁盘

[root@EPROS ~]# fdisk -l
Disk /dev/vda: 50 GiB, 53687091200 bytes, 104857600 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
Disklabel type: dos
Disk identifier: 0xca2533dd

Device     Boot Start       End   Sectors Size Id Type
/dev/vda1  *     2048 104857566 104855519  50G 83 Linux


Disk /dev/vdb: 800 GiB, 858993459200 bytes, 1677721600 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
Disklabel type: dos
Disk identifier: 0x98f69975

Device     Boot Start        End    Sectors  Size Id Type
/dev/vdb1        2048 1677721599 1677719552  800G 83 Linux   #已经有新的分区了

3.格式化分区

[root@EPROS ~]# mkfs.ext4 /dev/vdb1 
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 209714944 4k blocks and 52428800 inodes
Filesystem UUID: 330b4a1b-c52c-4250-91ba-75de2ee3082a
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
        102400000

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

4.挂载分区

[root@EPROS ~]# mkdir /data   #新增目录
[root@EPROS ~]# echo /dev/vdb1 /data ext4 defaults 0 0 >> /etc/fstab  #磁盘和目录绑定
[root@EPROS ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Fri May 27 05:31:44 2022
#
# 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.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
UUID=1d5588f6-74c0-447d-b95a-43e6c26aac16 /                       ext4    defaults        1 1
/dev/vdb1 /data ext4 defaults 0 0
[root@EPROS ~]# mount -a    #挂载磁盘分区和目录
[root@EPROS ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
devtmpfs         16G     0   16G   0% /dev
tmpfs            16G   84K   16G   1% /dev/shm
tmpfs            16G  492K   16G   1% /run
tmpfs            16G     0   16G   0% /sys/fs/cgroup
/dev/vda1        50G  3.4G   44G   8% /
tmpfs           3.1G     0  3.1G   0% /run/user/0
/dev/vdb1       787G   73M  747G   1% /data              #新的磁盘生效了
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值