First, the physical machine adds a new hard drive method (the purpose is to add the added disk directly above the existing, no more partition Mount)
1, first to determine the existing system on the plate
[Email protected] ~]# DF-LH
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root
50G 50G 0 100%/
Tmpfs 3.9G 0 3.9G 0%/dev/shm
/DEV/SDB1 485M 37M 424M 8%/boot
/dev/mapper/volgroup-lv_home
75G 7.9G 63G 12%/Home
From this information can be judged the system on the SDB
2. Allocate newly added disk space
Added 50G to the root directory
In addition, there is a 85G of space, and so on when not enough time can be added
This flexibility is higher
Historical commands to use:
1019 2014-04-03 14:07:41 FDISK/DEV/SDA
1020 2014-04-03 14:08:07 Partprobe
1023 2014-04-03 14:08:41 MKFS.EXT4/DEV/SDA
1025 2014-04-03 14:10:17 PVCREATE/DEV/SDA
1028 2014-04-03 14:11:06 Vgextend VOLGROUP/DEV/SDA
1030 2014-04-03 14:11:43 Lvextend-l +50g/dev/mapper/volgroup-lv_root
1031 2014-04-03 14:12:00 resize2fs-p/dev/volgroup/lv_root
1032 2014-04-03 14:13:43 DF-LH
3, if it is a virtual machine, the history command is as follows
Mkfs.ext4/dev/vdb
Pvcreate/dev/vdb
Vgextend Vmvg/dev/vdb
Lvextend-l +49g/dev/mapper/vmvg-root
Resize2fs-p/dev/vmvg/root
Third, adjust the existing partition size
During the use of the fedora13-x86_64 process, it was found that the system assigned to the root user LVM shares too little.
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root
50G 11G 37G 23%/
Tmpfs 878M 100K 878M 1%/DEV/SHM
/DEV/SDA1 485M 28M 432M 7%/boot
/dev/mapper/volgroup-lv_home
406G 411M 385G 1%/Home
/DEV/SDC 124M 107M 18M 86%/media/16f0-286f
[Email protected] ~]#
A total of only 50G, decided to give it an increase in share, now do important file backup, just in case.
Ideas:
First lose the share of volgroup-lv_home, and then increase the lost share to Volgroup-lv_root.
[Email protected] ~]# Pvscan
Pv/dev/sda2 VG VolGroup lvm2 [465.25 gib/0 Free]
Total:1 [465.25 Gib]/in use:1 [465.25 GIB]/in no vg:0 [0]
[Email protected] ~]# resize2fs-p/dev/mapper/volgroup-lv_home 206G
RESIZE2FS 1.41.10 (10-feb-2009)
Filesystem at/dev/mapper/volgroup-lv_home is mounted on/home; On-line resizing required
On-line shrinking from 107954176 to 54001664 not supported.
[Email protected] ~]# Umount/home
[Email protected] ~]# resize2fs-p/dev/mapper/volgroup-lv_home 206G
RESIZE2FS 1.41.10 (10-feb-2009)
Please run ' e2fsck-f/dev/mapper/volgroup-lv_home ' first.
[Email protected] ~]# e2fsck-f/dev/mapper/volgroup-lv_home
E2fsck 1.41.10 (10-feb-2009)
Pass 1:checking inodes, blocks, and sizes
Pass 2:checking directory structure
Pass 3:checking Directory Connectivity
Pass 4:checking Reference counts
Pass 5:checking Group summary Information
/dev/mapper/volgroup-lv_home:1534/26992640 files (1.2% non-contiguous), 1799101/107954176 blocks
[Email protected] ~]# resize2fs-p/dev/mapper/volgroup-lv_home 206G
RESIZE2FS 1.41.10 (10-feb-2009)
Resizing the filesystem on/dev/mapper/volgroup-lv_home to 54001664 (4k) blocks.
Begin Pass 3 (max = 3295)
Scanning Inode Table Xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
The filesystem on/dev/mapper/volgroup-lv_home is now 54001664 blocks long.
[Email protected] ~]# Mount/home
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root
50G 11G 37G 23%/
Tmpfs 878M 100K 878M 1%/DEV/SHM
/DEV/SDA1 485M 28M 432M 7%/boot
/DEV/SDC 124M 107M 18M 86%/media/16f0-286f
/dev/mapper/volgroup-lv_home
203G 400M 193G 1%/Home
[Email protected] ~]# lvreduce-l 206g/dev/mapper/volgroup-lv_home
Warning:reducing Active and open logical volume to 206.00 GiB
This May DESTROY YOUR DATA (filesystem etc)
Does really want to reduce lv_home? [y/n]: Y
Reducing logical volume Lv_home to 206.00 GiB
Logical Volume Lv_home successfully resized
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root
50G 11G 37G 23%/
Tmpfs 878M 100K 878M 1%/DEV/SHM
/DEV/SDA1 485M 28M 432M 7%/boot
/DEV/SDC 124M 107M 18M 86%/media/16f0-286f
/dev/mapper/volgroup-lv_home
203G 400M 193G 1%/Home
[Email protected] ~]# Vgdisplay
---Volume Group---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 5
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
ACT PV 1
VG Size 465.25 GiB
PE Size 32.00 MiB
Total PE 14888
Alloc pe/size 8302/259.44 GiB
Free Pe/size 6586/205.81 GiB
VG UUID Ymbjk0-sndq-dwhg-mlpu-31sg-zpo1-kcrumu
[email protected] ~]# man Lvextend
[Email protected] ~]# lvextend-l +205.81g/dev/mapper/volgroup-lv_root
Rounding up size to full physical extent 205.81 GiB
Extending logical Volume Lv_root to 255.81 GiB
Logical Volume Lv_root successfully resized
[Email protected] ~]# resize2fs-p/dev/mapper/volgroup-lv_root
RESIZE2FS 1.41.10 (10-feb-2009)
Filesystem at/dev/mapper/volgroup-lv_root is mounted on/; On-line resizing required
Old desc_blocks = 4, new_desc_blocks = 16
Performing an on-line resize of/dev/mapper/volgroup-lv_root to 67059712 (4k) blocks.
The filesystem on/dev/mapper/volgroup-lv_root is now 67059712 blocks long.
Let's see,
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup-lv_root
252G 11G 229G 5%/
Tmpfs 878M 100K 878M 1%/DEV/SHM
/DEV/SDA1 485M 28M 432M 7%/boot
/DEV/SDC 124M 107M 18M 86%/media/16f0-286f
/dev/mapper/volgroup-lv_home
203G 400M 193G 1%/Home
Linux, how to add a new hard drive