阿里云Ubuntu挂载数据盘

阿里云Ubuntu挂载数据盘,第1张

这两天将阿里云上的服务器改为Ubuntu系统,原有的数据盘需要重新挂载。过程如下。

首先可以使用fdisk -l 查看磁盘状态,看到数据盘是/dev/vdb.

然后使用fdisk /dev/vdb来管理数据盘,由于对linux不熟悉,频繁使用m命令查看帮助。根据经验,首先使用d命令删除现在的分区,然后使用F命令查看未分区部分,接下来使用n命令创建新的分区,使用缺省参数创建,最后使用w保存。

然后进行格式化,命令是mkfs.ext3 /dev/vdb1

格式化完成后,映射到一个目录:

echo '/dev/vdb1 /mydata ext3 defaults 0 0' >>/etc/fstab

然后使用mount -a 加载,可以使用df -h 查看是否加载成功。

[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       新挂载的分区


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

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

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

发表评论

登录后才能评论

评论列表(0条)

    保存