给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

相关推荐

  • 网络班第27期第一周作业

    1、         描述计算机的组成及其功能 CPU:主要由控制器和运算器组成,其他还有寄存器和缓存等。 控制器:其功能是对程序规定的控制信息进行解释,根据其要求进行控制,调度程序、数据、地址,协调计算机各部分工作及内存与外设的访问等。 运算器:功能是对数据进行各种算术运算和逻…

    2017-07-29
  • 马哥教育网络班21期-第4周课程练习

    1、复制/etc/skel目录为/home/tuser1,要求/home/tuser1及其内部文件的属组和其它用户均没有任何访问权限。     cp -R /etc/skel /home/tuser1     chmod g-rwx,o-r…

    Linux干货 2016-08-03
  • linux上的组管理

    上一次我们谈了CentOS上的用户管理,现在我们再来谈下CentOS上的用户组管理。 groupadd创建一个新的组 用法如下: groupadd [选项] groupname 常用选项: -f 强制添加一个组(这个组可能已经存在系统中) -g 指定组的id; -r 创建系统工作组(系统工作组的组ID小于500) -K 覆盖配置文件/ect/log…

    Linux干货 2017-04-09
  • 文本三剑客—sed 基础

    文本三剑客—sed 基础        sed编辑器被称作流编辑器(stream editor),和普通的交互式文本编辑器恰好相反。在交互式文本编辑器中(比如vim),你可以用键盘命令来交互式的插入、删除或者替换数据中的文本。流编辑器则会自爱编辑器处理数据之前基于预习提供的一组…

    Linux干货 2017-05-15
  • CentOS系统启动

    Linux组成 Linux: kernel+rootfs kernel:  进程管理、内存管理、网络管理、驱动程序、文件系统、安全功能 rootfs: 程序和glibc 库:函数集合, function,  调用接口(头文件负责描述) 过程调用:procedure ,无返回值 函数调用:function 程序:二进制执行文件 内核设计流派…

    2017-05-15
  • HipHop PHP实战(详解web运行模式)

    Note: These code examples assume the HipHop compiler is fully built. 1 . Setting Up Your Environment (构建环境) To get started, you need to configure two environment variables. cd…

    Linux干货 2015-04-10