给linux系统添加新的磁盘

虚拟化环境中,我们经常会遇到需要增加磁盘容量的情况,通常有两种方式,第一种是添加一块新的硬盘,另一种是扩容原有磁盘,以下是添加新磁盘至linux系统的操作规范。注:具体磁盘信息可能有所不同。

##查看新增加磁盘/dev/sdb的信息

[root@CentOS7 ~]# fdisk -l /dev/sdb

 

Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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/sdb上创建分区

[root@CentOS7 ~]# fdisk /dev/sdb

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 0x8c60b336.

 

Command (m for help): n   ##新建分区

Partition type:

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

   e   extended

Select (default p): p ##主分区

Partition number (1-4, default 1):             ##保持默认

First sector (2048-10485759, default 2048):      ##保持默认

Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759): +100M        ##磁盘分区大小为100MB

Partition 1 of type Linux and of size 100 MiB is set

 

Command (m for help): w  ##写入分区信息

The partition table has been altered!

 

Using default value 2048

Calling ioctl() to re-read partition table.

Syncing disks.

[root@CentOS7 ~]# fdisk -l /dev/sdb     ##再次查看/dev/sdb的信息,此时应该有新增的一个分区/dev/sdb1

 

Disk /dev/sdb: 5368 MB, 5368709120 bytes, 10485760 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: 0x8c60b336

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048      206847      102400   83  Linux

[root@CentOS7 ~]# blkid /dev/sdb1      ##查看分区信息,因为此时并没有格式化,所以此处无任何显示

[root@CentOS7 ~]# mkfs -t ext4 /dev/sdb1     ##格式化分区/dev/sdb1,格式为ext4

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

25688 inodes, 102400 blocks

5120 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=33685504

13 block groups

8192 blocks per group, 8192 fragments per group

1976 inodes per group

Superblock backups stored on blocks:

            8193, 24577, 40961, 57345, 73729

 

Allocating group tables: done                           

Writing inode tables: done                           

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done

 

[root@CentOS7 ~]# blkid /dev/sdb1      ##再次查看分区信息,此时已经有磁盘ID和分区类型

/dev/sdb1: UUID="a7a1bc0d-eddd-46e8-8b06-27b41b287424" TYPE="ext4"

[root@CentOS7 ~]# mkdir /Data             ##创建新的数据挂载点

[root@CentOS7 ~]# mount /dev/sdb1 /Data/  ##挂载新分区/dev/sdb1至新的挂载点

[root@CentOS7 ~]# mount          ##查看现在系统的挂载信息

sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime,seclabel)

……

/dev/sdb1 on /Data type ext4 (rw,relatime,seclabel,data=ordered)            ##已经成功挂载

原创文章,作者:Net24-仙鹤,如若转载,请注明出处:http://www.178linux.com/58901

(0)
Net24-仙鹤Net24-仙鹤
上一篇 2016-11-11
下一篇 2016-11-11

相关推荐

  • 20161014作业

    2016/10/14作业: ##操作类: 1. 设置自己的终端提示符,要求字符终端登录时: a> 需要带颜色 b> 需要显示当前执行到了第几条命令 c> 显示当前登录终端,主机名和当前时间 2、使用shutdown命令于5分钟后重启自己的PC机 3. 学习man,学会使用a> ls递归列出/usr目录下所有文件, b> 列出目录…

    Linux干货 2016-10-20
  • 文本处理工具

    文本处理工具 一、文本处理命令less,cat,more,sort 1.less  less :一页一页地查看文件或STDIN 输出  查看时有用的命令包括:   /文本  搜索 文本   n/N 个 跳到下一个 or  上一个匹配   less 命令是man…

    系统运维 2016-08-08
  • drbd+corosync+pacemaker

    存储分类: DAS:直接附加存储;例如ide,sata,scsi,sas等 NAS:网络附加存储;即文件级别共享存储;例如nfs等 SAN:存储区域网络;即块级别共享存储;例如ip-san,fc-san   共享存储选型比较: SAN性能优良,价格昂贵; NAS性能基于文件系统级别,性能低下; 因此,另一个DRBD诞生,全称为分布式复制块设备,Di…

    Linux干货 2017-11-13
  • 非对称密钥加密解密

    两台计算机一台用公钥加密
    另一台解密

    2018-01-08
  • 第九周作业

    awk基础 简介        AWK是一种优良的文本处理工具。它是 Linux 中也是任何环境中现有的功能最强大的数据处理引擎之一,相比sed常常作用于一整行的处理,awk比较倾向于将一行分成数个“字段”来处理。所以,awk相当适合处理小型的数据处理。 基础用法 awk[选项] ‘program’…

    2017-07-16
  • 马哥教育网络班22期中秋节课程练习1

    #!/bin/sh   set -e CheckRoot() { #check if currect use is root user     CUR_USER=`whoami`     if&nbs…

    Linux干货 2016-10-09