Linux虚拟机扩展文件系统
我的安装TimesTen和12c的虚拟机文件系统满了,需要扩展文件系统。
然后下面的过程大致是:
1. 扩展物理磁盘
2. 创建磁盘分区
2. 重启
3. 使用磁盘分区创建PV
4. 使用新PV扩展VG
5. 使用新PV扩展文件系统所在的LV
6. 扩展文件系统
以下是文件系统满的信息,可以看到文件系统所在的VG为VolGroup,LV为lv_root
[root@tt12c ~]# df -k
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/VolGroup-lv_root22063664 21106848 0 100% /
tmpfs 2020948 76 2020872 1% /dev/shm
/dev/sda1 487652 65340 392616 15% /boot
.host:/ 341867516 322829796 19037720 95% /mnt/hgfs
关机,由于是虚拟机,因此通过VMware Workstation中磁盘的实用工具中的扩展,将24G的硬盘扩展到30G,然后启动。
发现物理磁盘已变为30G
[root@tt12c ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes <- 已经是30G了
255 heads, 63 sectors/track, 3916 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: 0x00061f5dDevice 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 3133 4194302+ 83 LinuxDisk /dev/mapper/VolGroup-lv_root: 23.1 GB, 23089643520 bytes
255 heads, 63 sectors/track, 2807 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: 0x00000000Disk /dev/mapper/VolGroup-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
然后建立新的磁盘分区
[root@tt12c ~]# fdisk /dev/sdaWARNING: DOS-compatible mode is deprecated. It's strongly recommended toswitch off the mode (command 'c') and change display units tosectors (command 'u').Command (m for help): n
Command actione extendedp primary partition (1-4)
p
Selected partition 4
First cylinder (3134-3916, default 3134):
Using default value 3134
Last cylinder, +cylinders or +size{K,M,G} (3134-3916, default 3916):
Using default value 3916Command (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: Device or resource busy.
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.
新的磁盘分区/dev/sda4建立好了
[root@tt12c ~]# fdisk -lDisk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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: 0x00061f5dDevice 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 3133 4194302+ 83 Linux
/dev/sda4 3134 3916 6289447+ 83 LinuxDisk /dev/mapper/VolGroup-lv_root: 23.1 GB, 23089643520 bytes
255 heads, 63 sectors/track, 2807 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: 0x00000000Disk /dev/mapper/VolGroup-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
这时VG还没有多余的PE
[root@tt12c ~]# vgdisplay--- Volume group ---VG Name VolGroupSystem ID Format lvm2Metadata Areas 2Metadata Sequence No 5VG Access read/writeVG Status resizableMAX LV 0Cur LV 2Open LV 2Max PV 0Cur PV 2Act PV 2VG Size 23.50 GiBPE Size 4.00 MiBTotal PE 6017Alloc PE / Size 6017 / 23.50 GiBFree PE / Size 0 / 0 VG UUID sjpb7M-lq3U-h15f-Rzoi-351J-icTS-6mQARK
重启机器, 使用shutdown -r now
。如果不用重启就好了,不过现在还不知道如何做。
使用/dev/sda4创建PV
[root@tt12c ~]# pvcreate /dev/sda4Physical volume "/dev/sda4" successfully created
扩展VG后,发现有了多余的PE,后续lvextend可以用到此数字。然后扩展LV,在线扩展文件系统,成功!
[root@tt12c ~]# vgextend /dev/VolGroup /dev/sda4Volume group "VolGroup" successfully extended[root@tt12c ~]# vgdisplay--- Volume group ---VG Name VolGroupSystem ID Format lvm2Metadata Areas 3Metadata Sequence No 6VG Access read/writeVG Status resizableMAX LV 0Cur LV 2Open LV 2Max PV 0Cur PV 3Act PV 3VG Size 29.50 GiBPE Size 4.00 MiBTotal PE 7552Alloc PE / Size 6017 / 23.50 GiBFree PE / Size 1535 / 6.00 GiBVG UUID sjpb7M-lq3U-h15f-Rzoi-351J-icTS-6mQARK[root@tt12c ~]# lvdisplay--- Logical volume ---LV Path /dev/VolGroup/lv_rootLV Name lv_rootVG Name VolGroupLV UUID PY5XNv-pu3C-l8DH-bLbn-obly-uYZH-PaoMZWLV Write Access read/writeLV Creation host, time localhost.localdomain, 2015-06-19 22:28:46 +0800LV Status available# open 1LV Size 21.50 GiBCurrent LE 5505Segments 2Allocation inheritRead ahead sectors auto- currently set to 256Block device 252:0--- Logical volume ---LV Path /dev/VolGroup/lv_swapLV Name lv_swapVG Name VolGroupLV UUID 4BmUJs-9AGc-PGd9-dFTM-OD7m-KeUv-CTsRv0LV Write Access read/writeLV Creation host, time localhost.localdomain, 2015-06-19 22:28:48 +0800LV Status available# open 2LV Size 2.00 GiBCurrent LE 512Segments 1Allocation inheritRead ahead sectors auto- currently set to 256Block device 252:1[root@tt12c ~]# [root@tt12c ~]# lvextend /dev/VolGroup/lv_root /dev/sda4Size of logical volume VolGroup/lv_root changed from 21.50 GiB (5505 extents) to 27.50 GiB (7040 extents).Logical volume lv_root successfully resized[root@tt12c ~]# resize2fs /dev/VolGroup/lv_root
resize2fs 1.43-WIP (20-Jun-2013)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/VolGroup/lv_root is now 7208960 blocks long.[root@tt12c ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root27G 21G 5.6G 79% /
tmpfs 2.0G 80K 2.0G 1% /dev/shm
/dev/sda1 477M 64M 384M 15% /boot
.host:/ 327G 308G 19G 95% /mnt/hgfs
这里有一点注意,由于是将新建的分区的所有空间都用以扩展文件系统,因此使用了lvextend /dev/VolGroup/lv_root /dev/sda4.
如果只是给一部分空间用于文件系统,则使用lvextend -l+1535 /dev/VolGroup/lv_root (1535=7040-5505)
参考:
* Logical Volume Manager: How can I extend a Volume Group?
* VMware KB: Extending a logical volume in a virtual machine running Red Hat or Cent OS
Linux虚拟机扩展文件系统相关推荐
- linux虚拟机扩展磁盘
记一次linux虚拟机扩展磁盘 cmd diskpart DISKPART> help Microsoft DiskPart 版本 10.0.17134.1ACTIVE - 将选中的分区标记为活 ...
- linux在线扩展文件系统空间ext2online
linux在线扩展文件系统空间 ext2resize是一款可以增大/减小ext2/ext3文件系统的工具,安装后有2个命令ext2resize和ext2online,ext2resize命令 必须要在 ...
- linux 虚拟机扩展硬盘后扩展到分区
导读 我们管理的服务器可能会随着业务量的不断增长造成磁盘空间不足的情况,比如:共享文件服务器硬盘空间不足,在这个时候我们就需要增加磁盘空间,来满足线上的业务:又或者我们在使用linux的过程中, 有时 ...
- linux如何扩展根分区,linux扩展根分区详细步骤
Linux虚拟机扩展根分区! 虚拟机根分区空间不够用,在虚拟机管理界面进行单个磁盘扩展(图形化界面操作略),比如原来是30G,扩展至40G,(扩展需要关机之后操作) 其中的10G空间需要重新分区,以下 ...
- hyper扩展linux硬盘,Hyper-V 虚拟机扩展磁盘
在使用虚拟机的时候,会经常遇到虚拟硬盘空间不足的情况.本文对Hyper-V的虚拟机硬盘扩容方法进行整理记录,为大家提供参考.本文的内容基于Win10 Pro系统上的Hyper-V虚拟机进行实例演示.H ...
- linux原有的文件系统扩展,原来linux不用LVM也能扩展文件系统
以前总以为UNIX/LINUX使用了lvm才能扩展或缩小卷和文件系统,今天才发现我错了:即使没有lvm,linux也能扩展卷和及其相应的文件系统而不会丢失原有数据. 以下是测试步骤,记录备查. 1.系 ...
- vscode通过ssh扩展连接Linux虚拟机
vscode通过ssh扩展连接Linux虚拟机 连接Linux虚拟机 设置自动连接 记录一下使用vscode通过ssh扩展Linux虚拟机,避免重复造轮子. 首先在Linux系统中安装openssh- ...
- 独家 | 手把手教你用Python 3创建用于机器学习开发的Linux虚拟机(附安装教程代码)
原文标题:How to Create a Linux Virtual Machine For Machine Learning Development With Python 3 作者:Jason B ...
- Linux设备中文件系统位置,【linux之设备,分区,文件系统】
一.设备 IDE磁盘的设备文件采用/dev/hdx来命名,分区则采用/dev/hdxy来命名,其中x表示磁盘(a是第一块磁盘,b是第二块磁盘,以此类推), y代表分区的号码(由1开始,1.2.3以此类 ...
最新文章
- 大连Linux内核开发,如何查看linux内核版本
- Qt动画框架Animation Framework
- Appium环境搭建python篇(mac系统)
- Tomcat源码分析(九)--Session管理
- java数据库编程——事务
- zipline-benchmarks.py文件改写
- redis 判断存在性_springboot + redis + 注解 + 拦截器 实现接口幂等性校验
- 计算机网络---IP数据报组成计及IP模块工作流程
- Pascal VOC 数据集国内下载
- 50.magento 订单状态
- 计算机网络安全方面论文题目,计算机网络安全方面论文题目 计算机网络安全毕业论文题目怎么定...
- wacom win10 未连接任何设备 驱动的问题 解决影拓3手绘板等老设备驱动无法在win10使用的问题
- 大数据分析师技能图谱详解
- A. Harry Klopf是谁?
- mysql的填充因子_数据库SQL Server – 索引 – 填充因子
- 【U8+】U8+自动备份不成功BackupDB日志中显示“数据源.未找到”
- Vue学习随笔+商城项目【上】
- SATA学习笔记 13 ---SATA NCQ
- [转]Windows Shell 编程 第十章
- 彻底删除MySQL57服务
热门文章
- 无法打开源文件stdafx.h
- 华为OD机试真题 C++ 实现【获取最大软件版本号】【2022.11 Q4 新题】
- 用python语言实现人工智能猴子摘香蕉的问题_【提问】求大神看看代码哪里错了 C语言猴子摘香蕉...
- react脚手架honeycomb部署
- MATLAB学习笔记(2):MATLAB结构和工具箱以及菜单栏,工具栏
- VASP(1)_参数测试_截断能(ENCUT)测试
- 华为3C刷机ROOT 一键ROOT必备工具
- 在2020年,向SpaceX学习如何建造太空飞船!
- 【python】分析静态网页内容与获取
- 麦克纳姆轮(麦轮)原理