给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

相关推荐

  • 马哥教育网络班21期+第八周课程练习

    1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 网桥:也叫做桥接器,工作在OSI七层中第二层数据链路层,主要是用来连接两个局域网的一种存储或者转发设备,它能将一个大的LAN分隔      为多个网段,也可以将多个LAN互联为一个逻辑LAN,网桥是在数据层上实现的局域网互联;即使…

    Linux干货 2016-09-08
  • 软件安装与管理–rpm、yum

    一、rpm包管理器     1、介绍rpm        在linux系统中,服务是要通过程序来提供的,通过调用API接口编写好之后的源码包文件对于普通用户来说,安装起来较为繁琐。于是人们将源码在编译安装的环境下制作了更加高级的rpm包,它的最大特点是避免了对原软件包的编译安装,以更加简便…

    Linux干货 2016-08-22
  • 配置NTP服务器

    配置NTP时间服务器 一.安装ntp软件 1.检查是否安装了ntp相关包。 rpm -qa | grep ntp 2.安装ntp软件。 yum -y install ntp 二.参数讲解 ignore  :关闭所有的 NTP 联机服务 nomodify:客户端不能更改服务端的时间参数,但是客户端可以通过服务端进行网络校时。 notrust :客户端…

    Linux干货 2016-10-30
  • history命令详解

       有效地使用命令历史机制将会使效率获得极大提升。history:   保存你输入的命令历史。 可以用它来重复执行命令。   history [-c] [-d offset] [n]   history -anrw [filename]   history …

    2017-03-26
  • 马哥教育网络班21期-第八周课程练习

    第八周作业 1、请描述网桥、集线器、二层交换机、三层交换机、路由器的功能、使用场景与区别。 集线器:集线器工作在OSI七层模型的物理层;功能是将传输信号再生或放大,收到数据后将数据转发至除接收接口外的所有接口(广播)),但是由于集线器所有端口属于共享带宽,属于同一个冲突域和属于同一个广播域,容易产生信号冲突导致帧碎片,现今大部分集线器已经被交换机所替代; 网…

    Linux干货 2016-09-01
  • 描述器

    Edit 描述器 |[Descriptors] 描述器的表现 用到3个魔术方法:__get__()、__set__()、__delete__() 方法用法: object.__get__(self,instance,owner) object.__set__(self,instance,value) object.__delete__(self,instan…

    Linux干货 2017-11-29