大网数据广告活动
服务器运维问答

How to resize LVM in Redhat

· 52CE 我爱测

I have a VM with Redhat 6.8 that originally started with a 60GB disk 1. In VMware I increased the size to 100GB. I would like to increase the /tmp volume from 2GB to 5GB. I assume I need to resize the sda2 partition first and the…

问题原文

原帖链接 · Andy Arismendi · CC BY-SA 3.0

I have a VM with Redhat 6.8 that originally started with a 60GB disk 1. In VMware I increased the size to 100GB. I would like to increase the /tmp volume from 2GB to 5GB. I assume I need to resize the sda2 partition first and then increase the LV. I tried echo 1 > /sys/class/scsi_device/2\:0\:0\:0\/device/rescan and then resize2fs /dev/sda but it said it was busy. Not sure what commands I need or what the the order is... Here's my system info -

$ fdisk -l /dev/sda

Disk /dev/sda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x0000555c

   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        7833    62708736   8e  Linux LVM

$ lsblk
NAME                            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sr0                              11:0    1  3.6G  0 rom
sda                               8:0    0  100G  0 disk
├─sda1                            8:1    0  200M  0 part /boot
└─sda2                            8:2    0 59.8G  0 part
  ├─system-swap (dm-0)          253:0    0   10G  0 lvm  [SWAP]
  ├─system-root (dm-1)          253:1    0   10G  0 lvm  /
  ├─system-opt (dm-2)           253:2    0   10G  0 lvm  /opt
  ├─system-tmp (dm-3)           253:3    0    2G  0 lvm  /tmp
  ├─system-var_log (dm-4)       253:4    0    1G  0 lvm  /var/log
  ├─system-var (dm-5)           253:5    0   10G  0 lvm  /var
  ├─system-home (dm-6)          253:6    0   10G  0 lvm  /home
  └─system-var_log_audit (dm-7) 253:7    0    1G  0 lvm  /var/log/audit

$ lvdisplay /dev/system/tmp
  --- Logical volume ---
  LV Path                /dev/system/tmp
  LV Name                tmp
  VG Name                system
  LV UUID                QOy6T3-vVnK-fJ0o-hyfY-gPYf-IC61-YDLQn1
  LV Write Access        read/write
  LV Creation host, time hardlogs.localdomain, 2014-02-19 12:09:47 -0500
  LV Status              available
  # open                 1
  LV Size                2.00 GiB
  Current LE             512
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

已采纳解答

原帖链接 · shodanshok · CC BY-SA 3.0

After partition resize, you should reboot the system to be 100% sure that kernel recognizes the new size. After that:

  • you had to resize the LVM volume, issuing lvextend /dev/system/tmp -L 5G
  • you had to resize the filesystem, issuing resize2fs /dev/system/tmp

Please pay much attention to issuing the above command against the correct devices. For example, your previous resize2fs was plain and dangerously wrong, as you must not use sda as target, rather the LVM volume.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-06-06)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。