阿里云ECS挂载硬盘

阿里云ECS挂载硬盘,第1张

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

  Device Boot      Start        End      Blocks  Id  System

/dev/vda1  *        2048    83886046    41941999+  83  Linux

Disk /dev/vdb: 100.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

[root@test~]# 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 0xc247eca8.

Command (m for help): n    输入n

Partition type:

  p  primary (0 primary, 0 extended, 4 free)

  e  extended

Select (default p): p  输入p

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

First sector (2048-209715199, default 2048):      回车

Using default value 2048

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): wq  输入wq退出

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

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

  Device Boot      Start        End      Blocks  Id  System

/dev/vda1  *        2048    83886046    41941999+  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

Disk label type: dos

Disk identifier: 0xc247eca8

  Device Boot      Start        End      Blocks  Id  System

/dev/vdb1            2048  209715199  104856576  83  Linux      已创建/dev/vdb1分区

[root@test~]# 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

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

[root@test~]# mkdir /mnt    创建挂载目录

mkdir: cannot create directory ‘/mnt’: File exists

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

[root@Hilbert ~]# cat /etc/fstab       写入新分区信息

#

# /etc/fstab

# Created by anaconda on Wed May 25 02:12:53 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

#

UUID=d71b01a9-bf24-4afb-b7d9-3a0961522139 /                      ext4    defaults        1 1

/dev/vdb1 /mnt ext4 defaults 0 0

[root@test~]# mount /dev/vdb1 /mnt      把分区挂载在/mnt目录下

[root@test~]# df -h

Filesystem      Size  Used Avail Use% Mounted on

devtmpfs        3.9G    0  3.9G  0% /dev

tmpfs          3.9G    0  3.9G  0% /dev/shm

tmpfs          3.9G  608K  3.9G  1% /run

tmpfs          3.9G    0  3.9G  0% /sys/fs/cgroup

/dev/vda1        40G  2.1G  36G  6% /

tmpfs          783M    0  783M  0% /run/user/0

/dev/vdb1        98G  61M  91G  1% /mnt       新挂载的分区

如题,阿里云的服务器升级系统版本后,挂载的磁盘需要自动手动挂载。

服务器上有两块磁盘,第一块是系统盘,第二块是数据盘。系统升级以后,数据盘需要登录进系统手动挂载。

df 查看磁盘分区:

挂载方法:

df 查看磁盘分区,可以看到/dev/xvdb1已经挂载到/mnt磁盘了

--

平时做好磁盘快照很关键,当遇到系统出问题或者系统升级这些场景,能够一键还原,保证数据不丢失。

云服务为开发者提供了很大的便利性。我这次升级前后不过几十分钟,点了几下按钮就完成了系统的平滑升级。赞!


欢迎分享,转载请注明来源:夏雨云

原文地址:https://www.xiayuyun.com/zonghe/337118.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-05
下一篇2023-05-05

发表评论

登录后才能评论

评论列表(0条)

    保存