RedHat6.5系统LVM增加新硬盘实现根文件系统扩容
一、新增物理空间
二、linux中创建新分区
1、首先查看硬盘信息,用fdisk -l命令,如果有硬盘有剩余空间就可以对其进行分区。
- [root@master 桌面]# fdisk -l
- Disk /dev/sda: 64.4 GB, 64424509440 bytes
- 255 heads, 63 sectors/track, 7832 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: 0x0004bbc1
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 64 512000 83 Linux
- Partition 1 does not end on cylinder boundary.
- /dev/sda2 64 2611 20458496 8e Linux LVM
- Disk /dev/mapper/vg_hadoop-lv_root: 18.8 GB, 18798870528 bytes
- 255 heads, 63 sectors/track, 2285 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
- Disk /dev/mapper/vg_hadoop-lv_swap: 2147 MB, 2147483648 bytes
- 255 heads, 63 sectors/track, 261 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、下面对/dev/sda进行分区
fdisk /dev/sda
Command (m for help): m //输入m查看帮助文档
Command (m for help): n //输入n新建分区
- [root@master ~]# fdisk /dev/sda
- WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
- switch off the mode (command 'c') 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)
- Command (m for help): n
- Command action
- e extended
- 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 #查看分区结果
- Command action
- e extended
- p primary partition (1-4)
- e
- Partition number (1-4): 3
- First cylinder (2611-7832, default 2611):
- Using default value 2611
- Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832):
- Using default value 7832
- Command (m for help): p
- Disk /dev/sda: 64.4 GB, 64424509440 bytes
- 255 heads, 63 sectors/track, 7832 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: 0x0004bbc1
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 64 512000 83 Linux
- Partition 1 does not end on cylinder boundary.
- /dev/sda2 64 2611 20458496 8e Linux LVM
- /dev/sda3 2611 7832 41939020 5 Extended
4、扩展分区建好就可以在扩展分区建立逻辑分区了
Command (m for help): n
输入 : l 建立逻辑分区
Command (m for help): p #查看分区结果
- Command action
- l logical (5 or over)
- p primary partition (1-4)
- l
- First cylinder (2611-7832, default 2611):
- Using default value 2611
- Last cylinder, +cylinders or +size{K,M,G} (2611-7832, default 7832):
- Using default value 7832
- Command (m for help): p
- Disk /dev/sda: 64.4 GB, 64424509440 bytes
- 255 heads, 63 sectors/track, 7832 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: 0x0004bbc1
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 64 512000 83 Linux
- Partition 1 does not end on cylinder boundary.
- /dev/sda2 64 2611 20458496 8e Linux LVM
- /dev/sda3 2611 7832 41939020 5 Extended
- /dev/sda5 2611 7832 41938988+ 83 Linux
5、上面显示已经建好一个主分区,一个逻辑分区,但是这些现在还没有生效,需要保存退出。
Command (m for help):w #保存退出
输入 reboot 重启系统生效。
- Command (m for help): w
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
- The kernel still uses the old table. The new table will be used at
- the next reboot or after you run partprobe(8) or kpartx(8)
- Syncing disks.
三、 Linux系统LVM增加新硬盘实现根文件系统扩容
1、创建物理卷
fdisk -l
- [root@master local]# fdisk -l
- Disk /dev/sda: 64.4 GB, 64424509440 bytes
- 255 heads, 63 sectors/track, 7832 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: 0x0004bbc1
- Device Boot Start End Blocks Id System
- /dev/sda1 * 1 64 512000 83 Linux
- Partition 1 does not end on cylinder boundary.
- /dev/sda2 64 2611 20458496 8e Linux LVM
- /dev/sda3 2611 7832 41939020 5 Extended
- /dev/sda5 2611 7832 41938988+ 83 Linux
- Disk /dev/mapper/vg_hadoop-lv_root: 18.8 GB, 18798870528 bytes
- 255 heads, 63 sectors/track, 2285 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
- Disk /dev/mapper/vg_hadoop-lv_swap: 2147 MB, 2147483648 bytes
- 255 heads, 63 sectors/track, 261 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
pvcreate /dev/sda5
- [root@master local]# pvcreate /dev/sda5
- Physical volume "/dev/sda5" successfully created
2、查看创建好的物理卷
pvdisplay
/dev/sda5
- [root@master local]# pvdisplay /dev/sda5
- "/dev/sda5" is a new physical volume of "40.00 GiB"
- --- NEW Physical volume ---
- PV Name /dev/sda5
- VG Name
- PV Size 40.00 GiB
- Allocatable NO
- PE Size 0
- Total PE 0
- Free PE 0
- Allocated PE 0
- PV UUID qX00lY-nkpd-4txl-HFwM-6NuT-wMqu-yEFehV
3、卷组扩容
vgdisplay
- [root@master local]# vgdisplay
- --- Volume group ---
- VG Name vg_hadoop
- System ID
- Format lvm2
- Metadata Areas 1
- Metadata Sequence No 3
- VG Access read/write
- VG Status resizable
- MAX LV 0
- Cur LV 2
- Open LV 2
- Max PV 0
- Cur PV 1
- Act PV 1
- VG Size 19.51 GiB
- PE Size 4.00 MiB
- Total PE 4994
- Alloc PE / Size 4994 / 19.51 GiB
- Free PE / Size 0 / 0
- VG UUID iQqDwB-Ft3T-aFfh-7nwK-alS3-LSMo-Uid9nz
vgextend vg_hadoop /dev/sda5
- [root@master local]# vgextend vg_hadoop /dev/sda5
- Volume group "vg_hadoop" successfully extended
4、查看扩容之后的卷组信息
vgdisplay
- [root@master local]# vgdisplay
- --- Volume group ---
- VG Name vg_hadoop
- System ID
- Format lvm2
- Metadata Areas 2
- Metadata Sequence No 4
- VG Access read/write
- VG Status resizable
- MAX LV 0
- Cur LV 2
- Open LV 2
- Max PV 0
- Cur PV 2
- Act PV 2
- VG Size 59.50 GiB
- PE Size 4.00 MiB
- Total PE 15232
- Alloc PE / Size 4994 / 19.51 GiB
- Free PE / Size 10238 / 39.99 GiB
- VG UUID iQqDwB-Ft3T-aFfh-7nwK-alS3-LSMo-Uid9nz
5、逻辑卷扩容
df -h
- [root@master local]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_hadoop-lv_root 18G 12G 5.1G 70% /
- tmpfs 1.9G 224K 1.9G 1% /dev/shm
- /dev/sda1 485M 40M 421M 9% /boot
- /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
- [root@master local]# lvextend -L +38G /dev/mapper/vg_hadoop-lv_root
- Extending logical volume lv_root to 55.51 GiB
- Logical volume lv_root successfully resized
6、查看扩容之后的逻辑卷
lvdisplay /dev/vg_hadoop/lv_root
- [root@master local]# lvdisplay /dev/vg_hadoop/lv_root
- --- Logical volume ---
- LV Path /dev/vg_hadoop/lv_root
- LV Name lv_root
- VG Name vg_hadoop
- LV UUID wv0vJ6-c5Dd-Su9k-7dSV-P3KE-CF88-ElqYFA
- LV Write Access read/write
- LV Creation host, time hadoop, 2017-07-05 18:56:16 +0800
- LV Status available
- # open 1
- LV Size 55.51 GiB
- Current LE 14210
- Segments 2
- Allocation inherit
- Read ahead sectors auto
- - currently set to 256
- Block device 253:0
7、文件系统扩容
resize2fs
/dev/vg_hadoop/lv_root
- [root@master local]# resize2fs /dev/vg_hadoop/lv_root
- resize2fs 1.41.12 (17-May-2010)
- Filesystem at /dev/vg_hadoop/lv_root is mounted on /; on-line resizing required
- old desc_blocks = 2, new_desc_blocks = 4
- Performing an on-line resize of /dev/vg_hadoop/lv_root to 14551040 (4k) blocks.
- The filesystem on /dev/vg_hadoop/lv_root is now 14551040 blocks long.
8、成功
df -h
- [root@master local]# df -h
- Filesystem Size Used Avail Use% Mounted on
- /dev/mapper/vg_hadoop-lv_root 55G 12G 41G 22% /
- tmpfs 1.9G 224K 1.9G 1% /dev/shm
- /dev/sda1 485M 40M 421M 9% /boot
- /dev/sr0 3.6G 3.6G 0 100% /media/RHEL_6.5 x86_64 Disc 1
参考资料:
RedHat6.5系统LVM增加新硬盘实现根文件系统扩容的更多相关文章
- xenserver 增加新硬盘
xenserver 增加新硬盘 1.XS创建本地存储 首先 分区好的的硬盘接到服务器上 查看所有硬盘了的id ls -l /dev/disk/by-id/ 记下硬盘的全称.接下来开始挂载 xe sr ...
- win2012 挂载硬盘即增加新硬盘方法
这篇文章主要介绍了win2012 挂载硬盘即增加新硬盘方法,需要的朋友可以参考下 点击左下角的服务器管理图标 点击右上角的“工具”,再选择“计算机管理” 再点击“磁盘管理” 在磁盘1的按钮处单击右键, ...
- linux系统下添加新硬盘的方法详解
对于linux新手来说,在linux上添加新硬盘,是很有挑战性的一项工作. 在Linux服务器上把硬盘接好,启动linux,以root登陆. fdisk -l ## 这里是查看目前系统上有几块硬盘 D ...
- ubuntu 增加新硬盘
在校内建了一个ftp,本来是想放一点东西的,没想到越放越多,然后硬盘就不够了. 服务器是虚拟出来的ubuntu-server 12.04.想要将新硬盘挂载到/home/ftp目录. 操作步骤: 1.可 ...
- xenserver增加新硬盘
1. 查看所有硬盘了的id # ls -l /dev/disk/by-id/ 2. 挂载 # xe sr-create type=lvm content-type=user device-config ...
- vmware增加新硬盘无需重启生效
echo "scsi add-single-device 2 0 2 0" > /proc/scsi/scsi # echo "scsi add-single-de ...
- linux服务器添加一块新硬盘不用重新启动机器的操作
Linux系统添加一块新硬盘不用关闭系统即可加载硬盘信息的操作 因之前换过硬盘重装系统,硬盘上的数据没有拷贝出来,开发人员问我要备份,炸了.我只好联系机房让他把之前换掉的硬盘插回服务器.但是插好之后f ...
- 给Linux系统新增加一块硬盘
今天公司测试Linux服务器硬盘不够用了,主要是mysql数据文件太大了,买了个500G的硬盘回来,这里记录下新加硬盘的方法PS 测试服务器的主板太差劲了,没有多余的电源接口,只能把光驱的电源拿出来, ...
- CentOS 挂载(U盘NTFS格式,新硬盘,增加交换分区,扩展根分区等)
1.挂载fat或者fat32分区的U盘 如果是用VM安装的linux,在vm里挂载U盘有两个前提: 第一,主机里的service要启动: 第二,U盘是连接到虚拟机,而不是主机,需要确认这点: 2.使用 ...
随机推荐
- ubantu 设置默认python3.叽叽叽的环境变量
wkp 发表于 2017-8-22 17:49:08 | 只看该作者 sudo vi ~/.bashrc 在里面加一句 alias python='python3' 或者再简单一点 alias p=' ...
- Maven Speed Up
收录架构 proxy代理仓库 不支持仓库搜索功能 收录版本 所有版本 更新时间 每24小时更新一次 使用说明 一.在maven软件中使用 以Maven 3.5.2为例: 打开maven配置文件 ./a ...
- Java学习笔记29(IO字符流,转换流)
字符流:只能操作文本文件,与字节流的区别是,字节流是按照字节来读取文件,而字符流是按照字符来读取,因此字符流的局限性为文本文件 字符输出流:Write类,使用时通过子类 每一次写入都要刷新 pac ...
- 使用Intellij Idea创建简单Maven项目(转)
我是学Java Web的,基本靠自学,在网上收集了各种视频资料,逐一的看,代码逐一的敲.学习了这么久之前一直未成想过要把自己的学习路程记录下来,在网上也看到过很多人把自己的学习历程以及遇到的问题写在了 ...
- 【webdriver自动化】使用数据驱动的方式实现登录多个163账号
练习1:使用数据驱动的方式,登录多个邮箱账号 login_info.txt: youxiang_99@163.com,XXXX youxiang_100@163.com,XXXX main.py: f ...
- 给Ubuntu软件升级命令
以非root用户更新系统 sudo: sudo是linux系统管理指令,是允许系统管理员让普通用户执行一些或者全部的root命令的一个工具,如halt,reboot,su等等.这样不仅减少了root用 ...
- Wget用法、参数解释的比较好的一个文章
wget是一个从网络上自动下载文件的自由工具.它支持HTTP,HTTPS和FTP协议,可以使用HTTP代理. 所谓的自动下载是指,wget可以在用户退出系统的之后在后台执行.这意味这你可以登录系统,启 ...
- Java匿名内部类的继承者、终结者————lambda表达式
一.什么是lambda表达式? lambda表达式就是一个代码块,可以传入变量和放入相应的代码. 二.基本格式 (参数 ) - >{ 代码 ...
- Justified Jungle
Problem J: Justified Jungle Time limit: 6 s Memory l imit: 512 MiB As you probably know, a tree is a ...
- C4-ResNet-TF-小象cv-code
https://blog.csdn.net/chaipp0607/article/details/75577305 https://blog.csdn.net/leastsq/article/deta ...