参数:
1. 系统盘 40G
2. 数据盘 200G

场景,新买的阿里云服务器,默认只会把数据盘挂载上,并没有分区,所以使用 df -h 只能看到系统盘,如下:

查看当前哪些磁盘可用

df -h
注意: 在没有分区和格式化数据盘之前,使用 df-h 命令是无法看到数据盘的

[root@shared-server ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G  1.6G   36G   5% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G  316K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           783M     0  783M   0% /run/user/0
[root@shared-server ~]#

查看数据盘

fdisk -l

[root@shared-server ~]# 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: 0x0008d73a
# 系统盘分区
   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83884031    41940992   83  Linux

# 数据盘信息
Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 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@shared-server ~]#

数据盘分区

fdisk 磁盘名称

[root@shared-server ~]# fdisk /dev/vdb
# 根据提示, 依次输入 n, p, 1, 两次回车, wq, 分区就开始了。

在次查看数据盘

[root@shared-server ~]# 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: 0x0008d73a
# 系统盘分区
   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048    83884031    41940992   83  Linux

# 数据盘信息
Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 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: 0xf4302046
# 数据盘分区
   Device Boot      Start         End      Blocks   Id  System
/dev/vdb1            2048   419430399   209714176   83  Linux

对新分区进行格式化

mkfs.ext3 磁盘分区名称

[root@shared-server ~]# mkfs.ext3 /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
13107200 inodes, 52428544 blocks
2621427 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
1600 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@shared-server ~]#

执行下列命令写入新分区信息

echo '数据盘分区名称 /mnt ext3 defaults 0 0'>> /etc/fstab

[root@shared-server ~]# echo '/dev/vdb1 /mnt ext3 defaults 0 0'>> /etc/fstab
[root@shared-server ~]#

挂载分区

mount 磁盘分区名称 /mnt

[root@shared-server ~]# mount /dev/vdb1 /mnt

在次查看当前哪些磁盘可用

[root@shared-server ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        40G  1.6G   36G   5% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G     0  3.9G   0% /dev/shm
tmpfs           3.9G  320K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           783M     0  783M   0% /run/user/0
/dev/vdb1       197G   60M  187G   1% /mnt
[root@shared-server ~]#
分类: CentOS

发表评论

电子邮件地址不会被公开。 必填项已用*标注