磁盘扩容问题

Posted bluesky-

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了磁盘扩容问题相关的知识,希望对你有一定的参考价值。

centos6.5扩容(不使用partprobe命令重读分区)

[root@host-10-0-0-15 ~]# fdisk /dev/vda

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): c
DOS Compatibility flag is not set

Command (m for help): u
Changing display/entry units to sectors

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First sector (16777216-83886079, default 16777216): 
Using default value 16777216
Last sector, +sectors or +size{K,M,G} (16777216-83886079, default 83886079): +5G

Command (m for help): p

Disk /dev/vda: 42.9 GB, 42949672960 bytes
16 heads, 63 sectors/track, 83220 cylinders, total 83886080 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0001a1bb

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048     1026047      512000   83  Linux
/dev/vda2         1026048    16777215     7875584   8e  Linux LVM
/dev/vda3        16777216    27262975     5242880   83  Linux

Command (m for help): wq
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.
[root@host-10-0-0-15 ~]# partx -a /dev/vda			#centos6.5安装partprobe命令失败,可以使用此命令代替
BLKPG: Device or resource busy
error adding partition 1
BLKPG: Device or resource busy
error adding partition 2
[root@host-10-0-0-15 ~]# lsblk 
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda                         252:0    0   40G  0 disk 
├─vda1                      252:1    0  500M  0 part /boot
├─vda2                      252:2    0  7.5G  0 part 
│ ├─VolGroup-lv_root (dm-0) 253:0    0  6.7G  0 lvm  /
│ └─VolGroup-lv_swap (dm-1) 253:1    0  816M  0 lvm  [SWAP]
└─vda3                      252:3    0    5G  0 part 
[root@host-10-0-0-15 ~]# vgs
  VG       #PV #LV #SN Attr   VSize VFree
  VolGroup   1   2   0 wz--n- 7.51g    0 
[root@host-10-0-0-15 ~]# lvs
  LV      VG       Attr       LSize   Pool Origin Data%  Move Log Cpy%Sync Convert
  lv_root VolGroup -wi-ao----   6.71g                                             
  lv_swap VolGroup -wi-ao---- 816.00m                                             
[root@host-10-0-0-15 ~]# pvcreate /dev/vda3 
  Physical volume "/dev/vda3" successfully created
[root@host-10-0-0-15 ~]# vgextend VolGroup /dev/vda3 
  Volume group "VolGroup" successfully extended
[root@host-10-0-0-15 ~]# vgs
  VG       #PV #LV #SN Attr   VSize  VFree
  VolGroup   2   2   0 wz--n- 12.50g 5.00g
[root@host-10-0-0-15 ~]# lvextend -L +3G /dev/VolGroup/lv_root 
  Extending logical volume lv_root to 9.71 GiB
  Logical volume lv_root successfully resized
[root@host-10-0-0-15 ~]# df -Th
Filesystem                   Type   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root ext4   6.7G  826M  5.5G  13% /
tmpfs                        tmpfs  1.9G     0  1.9G   0% /dev/shm
/dev/vda1                    ext4   485M   32M  428M   7% /boot
[root@host-10-0-0-15 ~]# resize2fs /dev/VolGroup/lv_root 
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/VolGroup/lv_root to 2545664 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 2545664 blocks long.

[root@host-10-0-0-15 ~]# df -Th
Filesystem                   Type   Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root ext4   9.6G  826M  8.3G   9% /
tmpfs                        tmpfs  1.9G     0  1.9G   0% /dev/shm
/dev/vda1                    ext4   485M   32M  428M   7% /boot

以上是关于磁盘扩容问题的主要内容,如果未能解决你的问题,请参考以下文章

Linux 无损扩容磁盘

关于linux中的磁盘扩容和LVM的疑问

VMware磁盘扩容问题

linux扩容/磁盘不能在同一块盘上吗

Centos7 给根目录磁盘扩容

kvm虚拟机磁盘扩容