一、新增物理空间

二、linux中创建新分区

1、首先查看硬盘信息,用fdisk -l命令,如果有硬盘有剩余空间就可以对其进行分区。

  1. [root@master 桌面]# fdisk -l
  2. Disk /dev/sda: 64.4 GB, 64424509440 bytes
  3. 255 heads, 63 sectors/track, 7832 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x0004bbc1
  8. Device Boot      Start         End      Blocks   Id  System
  9. /dev/sda1   *           1          64      512000   83  Linux
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/sda2              64        2611    20458496   8e  Linux LVM
  12. Disk /dev/mapper/vg_hadoop-lv_root: 18.8 GB, 18798870528 bytes
  13. 255 heads, 63 sectors/track, 2285 cylinders
  14. Units = cylinders of 16065 * 512 = 8225280 bytes
  15. Sector size (logical/physical): 512 bytes / 512 bytes
  16. I/O size (minimum/optimal): 512 bytes / 512 bytes
  17. Disk identifier: 0x00000000
  18. Disk /dev/mapper/vg_hadoop-lv_swap: 2147 MB, 2147483648 bytes
  19. 255 heads, 63 sectors/track, 261 cylinders
  20. Units = cylinders of 16065 * 512 = 8225280 bytes
  21. Sector size (logical/physical): 512 bytes / 512 bytes
  22. I/O size (minimum/optimal): 512 bytes / 512 bytes
  23. Disk identifier: 0x00000000

2、下面对/dev/sda进行分区

fdisk /dev/sda

Command (m for help): m   //输入m查看帮助文档

Command (m for help): n   //输入n新建分区

  1. [root@master ~]# fdisk /dev/sda
  2. WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
  3. switch off the mode (command 'c') and change display units to
  4. sectors (command 'u').
  5. Command (m for help): m
  6. Command action
  7. a   toggle a bootable flag
  8. b   edit bsd disklabel
  9. c   toggle the dos compatibility flag
  10. d   delete a partition
  11. l   list known partition types
  12. m   print this menu
  13. n   add a new partition
  14. o   create a new empty DOS partition table
  15. p   print the partition table
  16. q   quit without saving changes
  17. s   create a new empty Sun disklabel
  18. t   change a partition's system id
  19. u   change display/entry units
  20. v   verify the partition table
  21. w   write table to disk and exit
  22. x   extra functionality (experts only)
  23. Command (m for help): n
  24. Command action
  25. e   extended
  26. p   primary partition (1-4)

3、建立扩展分区

有扩展分区和主分区,逻辑分区在扩展分区中建立。注意到括号中的1-4,最多只能建四个主分区(包括扩展分区)。这里创建扩展分区,

输入 : e  #建立扩展分区

Partition number (1-4)  :  3   #因为已经有sda1、sda2了

First cylinder (2611-7832, default 2611):Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832): #直接Enter键,默认即可

Command (m for help): p   #查看分区结果

  1. Command action
  2. e   extended
  3. p   primary partition (1-4)
  4. e
  5. Partition number (1-4): 3
  6. First cylinder (2611-7832, default 2611):
  7. Using default value 2611
  8. Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832):
  9. Using default value 7832
  10. Command (m for help): p
  11. Disk /dev/sda: 64.4 GB, 64424509440 bytes
  12. 255 heads, 63 sectors/track, 7832 cylinders
  13. Units = cylinders of 16065 * 512 = 8225280 bytes
  14. Sector size (logical/physical): 512 bytes / 512 bytes
  15. I/O size (minimum/optimal): 512 bytes / 512 bytes
  16. Disk identifier: 0x0004bbc1
  17. Device Boot      Start         End      Blocks   Id  System
  18. /dev/sda1   *           1          64      512000   83  Linux
  19. Partition 1 does not end on cylinder boundary.
  20. /dev/sda2              64        2611    20458496   8e  Linux LVM
  21. /dev/sda3            2611        7832    41939020    5  Extended

4、扩展分区建好就可以在扩展分区建立逻辑分区了

Command (m for help): n

输入 : l  建立逻辑分区

Command (m for help): p   #查看分区结果

  1. Command action
  2. l   logical (5 or over)
  3. p   primary partition (1-4)
  4. l
  5. First cylinder (2611-7832, default 2611):
  6. Using default value 2611
  7. Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832):
  8. Using default value 7832
  9. Command (m for help): p
  10. Disk /dev/sda: 64.4 GB, 64424509440 bytes
  11. 255 heads, 63 sectors/track, 7832 cylinders
  12. Units = cylinders of 16065 * 512 = 8225280 bytes
  13. Sector size (logical/physical): 512 bytes / 512 bytes
  14. I/O size (minimum/optimal): 512 bytes / 512 bytes
  15. Disk identifier: 0x0004bbc1
  16. Device Boot      Start         End      Blocks   Id  System
  17. /dev/sda1   *           1          64      512000   83  Linux
  18. Partition 1 does not end on cylinder boundary.
  19. /dev/sda2              64        2611    20458496   8e  Linux LVM
  20. /dev/sda3            2611        7832    41939020    5  Extended
  21. /dev/sda5            2611        7832    41938988+  83  Linux

5、上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效,需要保存退出。

Command (m for help):w   #保存退出

输入 reboot 重启系统生效。

  1. Command (m for help): w
  2. The partition table has been altered!
  3. Calling ioctl() to re-read partition table.
  4. WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
  5. The kernel still uses the old table. The new table will be used at
  6. the next reboot or after you run partprobe(8) or kpartx(8)
  7. Syncing disks.

三、 Linux系统LVM增加新硬盘实现根文件系统扩容

1、创建物理卷

fdisk -l

  1. [root@master local]# fdisk -l
  2. Disk /dev/sda: 64.4 GB, 64424509440 bytes
  3. 255 heads, 63 sectors/track, 7832 cylinders
  4. Units = cylinders of 16065 * 512 = 8225280 bytes
  5. Sector size (logical/physical): 512 bytes / 512 bytes
  6. I/O size (minimum/optimal): 512 bytes / 512 bytes
  7. Disk identifier: 0x0004bbc1
  8. Device Boot      Start         End      Blocks   Id  System
  9. /dev/sda1   *           1          64      512000   83  Linux
  10. Partition 1 does not end on cylinder boundary.
  11. /dev/sda2              64        2611    20458496   8e  Linux LVM
  12. /dev/sda3            2611        7832    41939020    5  Extended
  13. /dev/sda5            2611        7832    41938988+  83  Linux
  14. Disk /dev/mapper/vg_hadoop-lv_root: 18.8 GB, 18798870528 bytes
  15. 255 heads, 63 sectors/track, 2285 cylinders
  16. Units = cylinders of 16065 * 512 = 8225280 bytes
  17. Sector size (logical/physical): 512 bytes / 512 bytes
  18. I/O size (minimum/optimal): 512 bytes / 512 bytes
  19. Disk identifier: 0x00000000
  20. Disk /dev/mapper/vg_hadoop-lv_swap: 2147 MB, 2147483648 bytes
  21. 255 heads, 63 sectors/track, 261 cylinders
  22. Units = cylinders of 16065 * 512 = 8225280 bytes
  23. Sector size (logical/physical): 512 bytes / 512 bytes
  24. I/O size (minimum/optimal): 512 bytes / 512 bytes
  25. Disk identifier: 0x00000000

pvcreate /dev/sda5

  1. [root@master local]# pvcreate /dev/sda5
  2. Physical volume "/dev/sda5" successfully created

2、查看创建好的物理卷

pvdisplay
/dev/sda5

  1. [root@master local]# pvdisplay /dev/sda5
  2. "/dev/sda5" is a new physical volume of "40.00 GiB"
  3. --- NEW Physical volume ---
  4. PV Name               /dev/sda5
  5. VG Name
  6. PV Size               40.00 GiB
  7. Allocatable           NO
  8. PE Size               0
  9. Total PE              0
  10. Free PE               0
  11. Allocated PE          0
  12. PV UUID               qX00lY-nkpd-4txl-HFwM-6NuT-wMqu-yEFehV

3、卷组扩容

vgdisplay

  1. [root@master local]# vgdisplay
  2. --- Volume group ---
  3. VG Name               vg_hadoop
  4. System ID
  5. Format                lvm2
  6. Metadata Areas        1
  7. Metadata Sequence No  3
  8. VG Access             read/write
  9. VG Status             resizable
  10. MAX LV                0
  11. Cur LV                2
  12. Open LV               2
  13. Max PV                0
  14. Cur PV                1
  15. Act PV                1
  16. VG Size               19.51 GiB
  17. PE Size               4.00 MiB
  18. Total PE              4994
  19. Alloc PE / Size       4994 / 19.51 GiB
  20. Free  PE / Size       0 / 0
  21. VG UUID               iQqDwB-Ft3T-aFfh-7nwK-alS3-LSMo-Uid9nz

vgextend vg_hadoop /dev/sda5

  1. [root@master local]# vgextend vg_hadoop /dev/sda5
  2. Volume group "vg_hadoop" successfully extended

4、查看扩容之后的卷组信息

vgdisplay

  1. [root@master local]# vgdisplay
  2. --- Volume group ---
  3. VG Name               vg_hadoop
  4. System ID
  5. Format                lvm2
  6. Metadata Areas        2
  7. Metadata Sequence No  4
  8. VG Access             read/write
  9. VG Status             resizable
  10. MAX LV                0
  11. Cur LV                2
  12. Open LV               2
  13. Max PV                0
  14. Cur PV                2
  15. Act PV                2
  16. VG Size               59.50 GiB
  17. PE Size               4.00 MiB
  18. Total PE              15232
  19. Alloc PE / Size       4994 / 19.51 GiB
  20. Free  PE / Size       10238 / 39.99 GiB
  21. VG UUID               iQqDwB-Ft3T-aFfh-7nwK-alS3-LSMo-Uid9nz

5、逻辑卷扩容

df -h

  1. [root@master local]# df -h
  2. Filesystem                     Size  Used Avail Use% Mounted on
  3. /dev/mapper/vg_hadoop-lv_root   18G   12G  5.1G  70% /
  4. tmpfs                          1.9G  224K  1.9G   1% /dev/shm
  5. /dev/sda1                      485M   40M  421M   9% /boot
  6. /dev/sr0                       3.6G  3.6G     0 100% /media/RHEL_6.5 x86_64 Disc 1

lvextend -L +38G /dev/mapper/vg_hadoop-lv_root

  1. [root@master local]# lvextend -L +38G /dev/mapper/vg_hadoop-lv_root
  2. Extending logical volume lv_root to 55.51 GiB
  3. Logical volume lv_root successfully resized

6、查看扩容之后的逻辑卷

lvdisplay /dev/vg_hadoop/lv_root

  1. [root@master local]# lvdisplay /dev/vg_hadoop/lv_root
  2. --- Logical volume ---
  3. LV Path                /dev/vg_hadoop/lv_root
  4. LV Name                lv_root
  5. VG Name                vg_hadoop
  6. LV UUID                wv0vJ6-c5Dd-Su9k-7dSV-P3KE-CF88-ElqYFA
  7. LV Write Access        read/write
  8. LV Creation host, time hadoop, 2017-07-05 18:56:16 +0800
  9. LV Status              available
  10. # open                 1
  11. LV Size                55.51 GiB
  12. Current LE             14210
  13. Segments               2
  14. Allocation             inherit
  15. Read ahead sectors     auto
  16. - currently set to     256
  17. Block device           253:0

7、文件系统扩容

resize2fs
/dev/vg_hadoop/lv_root

  1. [root@master local]# resize2fs /dev/vg_hadoop/lv_root
  2. resize2fs 1.41.12 (17-May-2010)
  3. Filesystem at /dev/vg_hadoop/lv_root is mounted on /; on-line resizing required
  4. old desc_blocks = 2, new_desc_blocks = 4
  5. Performing an on-line resize of /dev/vg_hadoop/lv_root to 14551040 (4k) blocks.
  6. The filesystem on /dev/vg_hadoop/lv_root is now 14551040 blocks long.

8、成功

df -h

  1. [root@master local]# df -h
  2. Filesystem                     Size  Used Avail Use% Mounted on
  3. /dev/mapper/vg_hadoop-lv_root   55G   12G   41G  22% /
  4. tmpfs                          1.9G  224K  1.9G   1% /dev/shm
  5. /dev/sda1                      485M   40M  421M   9% /boot
  6. /dev/sr0                       3.6G  3.6G     0 100% /media/RHEL_6.5 x86_64 Disc 1

参考资料:

https://zhidao.baidu.com/question/2138735858352570708.html

http://blog.chinaunix.net/uid-17176286-id-3129057.html

RedHat6.5系统LVM增加新硬盘实现根文件系统扩容的更多相关文章

  1. xenserver 增加新硬盘

    xenserver 增加新硬盘 1.XS创建本地存储 首先 分区好的的硬盘接到服务器上 查看所有硬盘了的id ls -l /dev/disk/by-id/ 记下硬盘的全称.接下来开始挂载  xe sr ...

  2. win2012 挂载硬盘即增加新硬盘方法

    这篇文章主要介绍了win2012 挂载硬盘即增加新硬盘方法,需要的朋友可以参考下 点击左下角的服务器管理图标 点击右上角的“工具”,再选择“计算机管理” 再点击“磁盘管理” 在磁盘1的按钮处单击右键, ...

  3. linux系统下添加新硬盘的方法详解

    对于linux新手来说,在linux上添加新硬盘,是很有挑战性的一项工作. 在Linux服务器上把硬盘接好,启动linux,以root登陆. fdisk -l ## 这里是查看目前系统上有几块硬盘 D ...

  4. ubuntu 增加新硬盘

    在校内建了一个ftp,本来是想放一点东西的,没想到越放越多,然后硬盘就不够了. 服务器是虚拟出来的ubuntu-server 12.04.想要将新硬盘挂载到/home/ftp目录. 操作步骤: 1.可 ...

  5. xenserver增加新硬盘

    1. 查看所有硬盘了的id # ls -l /dev/disk/by-id/ 2. 挂载 # xe sr-create type=lvm content-type=user device-config ...

  6. vmware增加新硬盘无需重启生效

    echo "scsi add-single-device 2 0 2 0" > /proc/scsi/scsi # echo "scsi add-single-de ...

  7. linux服务器添加一块新硬盘不用重新启动机器的操作

    Linux系统添加一块新硬盘不用关闭系统即可加载硬盘信息的操作 因之前换过硬盘重装系统,硬盘上的数据没有拷贝出来,开发人员问我要备份,炸了.我只好联系机房让他把之前换掉的硬盘插回服务器.但是插好之后f ...

  8. 给Linux系统新增加一块硬盘

    今天公司测试Linux服务器硬盘不够用了,主要是mysql数据文件太大了,买了个500G的硬盘回来,这里记录下新加硬盘的方法PS 测试服务器的主板太差劲了,没有多余的电源接口,只能把光驱的电源拿出来, ...

  9. CentOS 挂载(U盘NTFS格式,新硬盘,增加交换分区,扩展根分区等)

    1.挂载fat或者fat32分区的U盘 如果是用VM安装的linux,在vm里挂载U盘有两个前提: 第一,主机里的service要启动: 第二,U盘是连接到虚拟机,而不是主机,需要确认这点: 2.使用 ...

随机推荐

  1. Day8作业及默写

    1,有如下文件,a1.txt,里面的内容为: 老男孩是最好的培训机构, 全心全意为学生服务, 只为学生未来,不为牟利. 我说的都是真的.哈哈 分别完成以下的功能: 将原文件全部读出来并打印. with ...

  2. dd 命令的使用

    linux 下dd命令直接清除分区表(不用再fdisk一个一个的删除啦) 分区表是硬盘的分区信息,要删除一个硬盘的所有分区表很麻烦的,需要fdisk一个一个的删除,其实dd命令可直接清除分区信息,当然 ...

  3. excel idea sql 操作

    1.excel  concatenate()函数中连接单元格中值拼接sql时,内容超长,把insert into.... values()前面的单独提出来,只在concatenate()中拼接valu ...

  4. Python 操作系统介绍 进程的创建

    背景知识 顾名思义,进程即正在执行的一个过程.进程是对正在运行程序的一个抽象. 进程的概念起源于操作系统,是操作系统最核心的概念,也是操作系统提供的最古老也是最重要的抽象概念之一.操作系统的其他所有内 ...

  5. angular 学习日志

    1.创建项目 npm install -g @angular/cli ng new my-app cd my-app ng serve --open // 或者 npm start 2.生成新模块 n ...

  6. 在使用MyCat和MySqL时的错误总结

    在mysql中,无法连接虚拟机中的mysql. 原因:防火墙没有关闭 解决方案:service iptables stop 在mycat中,无法打开数据库的表, 原因:mycat在配置文件中设置的是自 ...

  7. 单点登录系统---SSO

    1.------------------SSO介绍--------------------------------- 有什么卵用?搞什么飞机的? 大家看看这个图,一个系统是没有问题.如果是分布式的系统 ...

  8. 2.25 js处理多窗口

    2.25 js处理多窗口 前言在打开页面上链接的时候,经常会弹出另外一个窗口(多窗口情况前面这篇有讲解:Selenium2+python自动化13-多窗口.句柄(handle)),这样在多个窗口之间来 ...

  9. math、numpy、pandas NaN 判断

    >> np.nan == np.nan False >> np.nan is np.nan True >> math.nan is np.nan False > ...

  10. Java中的IO流大体介绍

    由于Java中的IO流是在是知识点繁多,所以我大约花了1周的时间将其整理起来.但是整理起来后并不是将完事了,我还是要分字节流和字符流来讲述.然后字节流和字符流中还有是否带有缓冲流. 讲述完IO流后我将 ...