给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 12:39
下一篇 2016-11-11 21:20

相关推荐

  • Linux文本处理三剑客之GNU awk的使用

    awk: Aho, Weinberger, Kernighan,报告生成器,格式化文本输出 有多种版本:New awk(nawk),GNU awk(gawk) gawk –模式扫描和处理语言 基本用法:     awk[options] ‘program’ var=value file…   &nb…

    Linux干货 2016-10-06
  • Linux命令执行

    Linux命令 Linux命令是对Linux系统进行管理的命令。对于Linux系统来说,无论是中央处理器、内存、磁盘驱动器、键盘、鼠标,还是用户等都是文件,Linux系统管理的命令是它正常运行的核心,与之前的DOS命令类似。linux命令在系统中有两种类型:内置Shell命令和外部命令。 命令格式 COMMAND [OPTIONS…] [ARGU…

    Linux干货 2017-07-15
  • 习题

    1、删除/etc/grub2.conf文件中所有以空白开头的行行首的空白字符 2、删除/etc/fstab文件中所有以#开头,后面至少跟一个空白字符的行的行首的#和空白字符 3、在/root/install.log每一行行首增加#号 4、在/etc/fstab文件中不以#开头的行的行首增加#号 5、处理/etc/fstab路径,使用sed命令取出其目录名和基…

    Linux干货 2016-08-10
  • ansible的入门使用手册

    ansible1

    2018-01-15
  • Linux磁盘及文件系统

    Linux磁盘及文件系统 一、硬盘 硬盘接口 PATA(Paralled Advanced Technology Attachment,并行的先进技术规范),也叫IDE(Integrated Drive Eelectronics,集成电路驱动设备),是作为一种简单而廉价的接口而开发的。速度中等,容量大而且非常便宜。 串行ATA接口SATA(Serial AT…

    Linux干货 2016-09-19
  • SElinux配置httpd

    一、启用SELinux策略并安装httpd服务,改变网站的默认主目录为/website,添加SELinux文件标签规则,使网站可访问     1、修改selinux策略并重启 [root@localhost ~]# vim /etc/selinux/config# This file controls the stat…

    Linux干货 2016-09-19