添加磁盘扩容操作:

1、添加物理磁盘到服务器重启服务器,#fdisk -l查看识别磁盘(以/dev/sdb为例)

[ ~]# fdisk -l

Disk /dev/sda: 42.9 GB, 42949672960 bytes

255 heads, 63 sectors/track, 5221 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x0006a7c5

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          26      204800   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2              26         287     2097152   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sda3             287        5222    39640064   83  Linux

disk /dev/sdb: 21.5 gb, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

2、添加分区

[ ~]# fdisk /dev/sdb

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It‘s strongly recommended to

         switch off the mode (command ‘c‘) 1116.www.qixoo.qixoo.com and change display units to

         sectors (command ‘u‘).

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition     (删除分区)

   l   list known partition types

   m   print this menu

   n   add a new partition    (新建分区)

   o   create a new empty DOS partition table

   p   print the partition table       (显示分区信息)

   q   quit without saving changes     (不保存退出)

   s   create a new empty Sun disklabel

   t   change a partition‘s system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit   (保存退出)

   x   extra functionality (experts only)

   

#用"n"新建分区选择"p"主分区,在这里可以新建三个主分区剩下的可以建成扩展分区 选择“e”扩展分区

Command (m for help): n

Command action

   e   extended                 (扩展分区)

   p   primary partition (1-4)  (主分区)

1

Invalid partition number for type `1‘

Command action

   e   extended

   p   primary partition (1-4)

p                                 (p为新建主分区)

Partition number (1-4): 1         (主分区号)

First cylinder (1-2610, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +2G   (给主分区分配2G空间)

Command (m for help): p            (打印出配置的分区信息)

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xbf76d5e8

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux        (已经分配好的分区)

 

一般是先建三个主分区再有需求在建剩下空间的扩展分区

新建三个主分区和两个扩展分区并且保存退出

Command (m for help): p

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xbf76d5e8

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

/dev/sdb2             263         524     2104515   83  Linux

/dev/sdb3             525         786     2104515   83  Linux

/dev/sdb4             787        2610    14651280    5  Extended

/dev/sdb5             787         918     1060258+  83  Linux

/dev/sdb6             919        1050     1060258+  83  Linux

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

3、使分区生效

[ ~]# partprobe    (强制让内核重新找一次分区表)

4、查看新建分区

[ ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xbf76d5e8

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1         262     2104483+  83  Linux

/dev/sdb2             263         524     2104515   83  Linux

/dev/sdb3             525         786     2104515   83  Linux

/dev/sdb4             787        2610    14651280    5  Extended

/dev/sdb5             787         918     1060258+  83  Linux

/dev/sdb6             919        1050     1060258+  83  Linux

5、格式化分区

[ ~]# mkfs.ext3 /dev/sdb1

mke2fs 1.41.12 (17-May-2010)

文件系统标签=

操作系统:Linux

块大小=4096 (log=2)

分块大小=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

131648 inodes, 526120 blocks

26306 blocks (5.00%) reserved for the super user

第一个数据块=0

Maximum filesystem blocks=541065216

17 block groups

32768 blocks per group, 32768 fragments per group

7744 inodes per group

Superblock backups stored on blocks:

    32768, 98304, 163840, 229376, 294912

正在写入inode表: 完成                            

Creating journal (16384 blocks): 完成

Writing superblocks and filesystem accounting information: 完成

This filesystem will be automatically checked every 22 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[ ~]# mkfs.ext3 /dev/sdb2

[ ~]# mkfs.ext3 /dev/sdb3

[ ~]# mkfs.ext3 /dev/sdb5

[ ~]# mkfs.ext3 /dev/sdb6   (剩下的分区都格式化)

6、新建挂载目录并且挂载到系统上

[ ~]# mkdir -p /sdb/sdb1

[ ~]# mkdir -p /sdb/sdb2

[ ~]# mkdir -p /sdb/sdb3

[ ~]# mkdir -p /sdb/sdb5

[ ~]# mkdir -p /sdb/sdb6

[ ~]# ls /sdb

sdb1  sdb2  sdb3  sdb5  sdb6

[ ~]# mount /dev/sdb1 /sdb/sdb1

[ ~]# mount /dev/sdb2 /sdb/sdb2

[ ~]# mount /dev/sdb3 /sdb/sdb3

[ ~]# mount /dev/sdb5 /sdb/sdb5

[ ~]# mount /dev/sdb6 /sdb/sdb6

7、修改配置文件设置开机自动挂载

[ ~]# vi /etc/fstab

# /etc/fstab

# Created by anaconda on Fri Oct 14 22:27:19 2016

#

# Accessible filesystems, by reference, are maintained under ‘/dev/disk‘

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

UUID=bd82cad1-2b0a-4984-9846-06e690b1fdad /                       ext3    defaults        1 1

UUID=6d8f8e24-7849-4ad9-af35-7e8fb71eb7ec /boot                   ext3    defaults        1 2

UUID=dc268ee4-ba91-471f-9acf-94d0a2658083 swap                    swap    defaults        0 0

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

/dev/sdb1               /sdb/sdb1               ext3    defaults        0 0   (新添加挂载选项)

/dev/sdb2               /sdb/sdb2               ext3    defaults        0 0   (defaults都是00)

/dev/sdb3               /sdb/sdb3               ext3    defaults        0 0

/dev/sdb5               /sdb/sdb5               ext3    defaults        0 0

/dev/sdb6               /sdb/sdb6               ext3    defaults        0 0

8、重启服务器生效,并查看分区结果

[ ~]# reboot

[ ~]# df -hT

Filesystem     Type   Size  Used Avail Use% Mounted on

/dev/sda3      ext3    38G  7.7G   28G  22% /

tmpfs          tmpfs  495M     0  495M   0% /dev/shm

/dev/sda1      ext3   194M   30M  155M  17% /boot

/dev/sdb1      ext3   2.0G   68M  1.9G   4% /sdb/sdb1

/dev/sdb2      ext3   2.0G   68M  1.9G   4% /sdb/sdb2

/dev/sdb3      ext3   2.0G   68M  1.9G   4% /sdb/sdb3

/dev/sdb5      ext3  1020M   34M  935M   4% /sdb/sdb5

/dev/sdb6      ext3  1020M   34M  935M   4% /sdb/sdb6

扩容成功。

备注:1、这是在虚拟机上自己实验操作的,所以一块盘的空间20G在真正的工作环境中扩充的盘都是几百G甚至好几个T的;

2、Linux上还有一个伸缩性更好的为服务器扩容的方法即LVM,更灵活操作也很简单。

Linux添加新盘扩容空间的更多相关文章

  1. linux添加新LUN,无需重启

    linux添加新LUN,无需重启 在给存储增加新的Lun时,在linux下一般是: A.重启操作系统B.重启HBA卡驱动 1. kudzu添加完新硬盘后,运行命令kudzu重新扫描新的硬件设备,类似a ...

  2. Linux添加新硬盘自动挂载硬盘

    Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204 ...

  3. 给Linux添加新用户,新建用户,新建帐号

    给Linux添加新用户,新建用户,新建帐号 添加用户组 sudo groupadd groupname 添加用户 sudo useradd username -m -s /sbin/nologin - ...

  4. linux添加新硬盘不需要重启识盘,及查看uuid

     添加新物理硬盘 用ssh工具连接到服务器,执行:fdisk -l 查看磁盘,并没有新加的硬盘 fdisk -l查看硬盘及分区状态     查看主机总线号,命令:ls /sys/class/scsi_ ...

  5. linux 添加新硬盘的方法

    在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help) ...

  6. Virtualbox中Linux添加新磁盘并创建分区

    原文:https://www.linuxidc.com/Linux/2017-01/139616.htm ----------------------------------------------- ...

  7. Linux 添加新用户账号并赋予root权限

    除了root用户之外,通常需要为每个管理创建各自的用户账号,方便每个管理员登录使用, 步骤如下: 1.  添加新用户账号 useradd  mary.lee 2.  为新用户账号设置密码 passwd ...

  8. linux添加新硬盘

    1.添加新磁盘 2.fdisk -l查看磁盘被识别的名称 3.如果输入fdisk -l命令没有找到新的磁盘,按下面步骤操作 1)进入到cd /sys/class/scsi_host/ 2)echo & ...

  9. LINUX添加新的用户账号并赋予root权限

    一:添加新的用户账号使用 useradd 命令 语法:     useradd  选项  用户名 示例:      # 添加用户,设定登录目录:useradd -d  /home/admin -m a ...

随机推荐

  1. 使用rest方式修改服务端xml文件

    想法: 最近想用REST的方式去修改一个远端的xml文件,于是自己写了个Handler 设计: 用现成的XPath,和GET,POST,PUT,DELETE这4个http方法作为动作,达到直接读写xm ...

  2. [转]Windows 8.1删除这台电脑中视频/文档/下载等六个文件夹的方法

    Windows 8.1 已将“计算机”正式更名为“这台电脑”,当我们双击打开“这台电脑”后,也会很明显得发现另外一些变化:Windows 8.1  默认将视频.图片.文档.下载.音乐.桌面等常用文件夹 ...

  3. jQuery问题集锦

    [1]阻止提交表单 方法1: $(function () { $("input[type=submit]").click(function (event) { //如果不满足表单提 ...

  4. eclipse failed to load the jni jvm.dll

    问题:打开Eclipse弹出,eclipse failed to load the jni jvm.dll,一般都是本机的JDK与Eclipse位数不等{32-64,64-32} 解决:看本机Java ...

  5. RabbitMQ官方中文入门教程(PHP版) 第一部分:Hello World

    RabbitMQ是一个消息代理.它的核心原理非常简单:接收和发送消息.你可以把它想像成一个邮局:你把信件放入邮箱,邮递员就会把信件投递到你的收件人处.在这个比喻中,RabbitMQ是一个邮箱.邮局.邮 ...

  6. android 随记 ContentValues

    ContentValues 和HashTable类似都是一种存储的机制 但是两者最大的区别就在于,contenvalues只能存储基本类型的数据,像string,int之类的,不能存储对象这种东西,而 ...

  7. oracle去重等基础问题

    --去重查询方法一:根据id select * from sxe where id in(select min(id) from sxe group by username) order by id ...

  8. [转]如何判断js中的数据类型

    原文地址:http://blog.sina.com.cn/s/blog_51048da70101grz6.html 如何判断js中的数据类型:typeof.instanceof. constructo ...

  9. 【URAL 1018】Binary Apple Tree

    http://vjudge.net/problem/17662 loli蜜汁(面向高一)树形dp水题 #include<cstdio> #include<cstring> #i ...

  10. 基于tomcat-jQ-springMVC-bootstrap的公司产品管理WEB应用

    管理员登录后台以后才能操作 ,权限管理只有一个管理员, 系统的主要作用是查看所有的 “公司列表”, 并查看该公司的”产品“, 用户可以对该公司的产品进行添加或者删除, 添加或者删除公司等 , 添加产品 ...