linux virtual machine disk space expansion

1. Mount physical memory, adding a new disk to expand space
and then restart the machine, enter the new setting webbios stored raid (do not move the old store raid, otherwise data loss). Note After you set up the machine to start, a new storage partitions using fdisk.
] -L # the fdisk
the fdisk / dev / SDB # operates on the second disk
Command (m for help): n # add a new partition
the Command Action
E Extended
P Primary Partition (1-4)

p # Select "Add primary partition"
the Partition Number (1-4): # 1 is selected as the partition 1

First cylinder (1-65270, default 1) : # direct the transport, the new hard disk partition from the beginning of the first sector of
the Using a default value
Last Cylinder, or Cylinders + size + {K, M, G} (1-65270 , default 65270): # direct the transport, the new hard disk partition at the end of the end, that is, the entire hard drive only to a district, but also the primary partition.
Using default value 65270

Command (m for help): t # Primary partition
the Selected Partition. 1
Hex code (type L to List Codes): No. 83 83 # Select partition type (linux type)

Command (m for help): w # saved to the hard disk
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

] # Fdisk -l # mount again see the hard disk, the hard disk has found new READY
Device the Boot Start End Blocks Id System
/ dev / sda1 * 1 64-512000 83 Linux
Partition 1 does not End ON Cylinder boundary.
/ Dev / sda2 3917 30,944,256 8E the Linux the LVM 64
/ dev / sda3 83 3917 133 674 1,042,279,125 the Linux

2. The new hard disk partition / dev / sda3 exist, then restart execution

[root @ JQ-AQSB-04 ~] # pvscan # View to allocate space
the PV / dev / sda2 VG of volgroup LVM2 [29.51 GiB / 6.51 GiB Free]
the Total:. 1 [29.51 GiB] / in use:. 1 [29.51 GiB] / in no VG: 0 [0]

## 3. The newly added volume to the specified disk
[root @ JQ-AQSB-04 dev] # ls | grep sda3 # to see if not in the logical volume, then enter the / dev directory ls see if this volume sda3
sda3
[ root @ JQ-AQSB-04 dev ] # vgs # View scalability space found sda3 not shown
VG of the Attr #PV #LV #SN VSize vfree
volgroup WZ. 1 0. 6 - 6.51 g 29.51g N-
[@ JQ the root-AQSB- 04 dev] # pvscan # View scalability space
the PV / dev / sda2 VG of volgroup LVM2 [29.51 GiB / 6.51 GiB Free]
the Total:. 1 [29.51 GiB] / in use:. 1 [29.51 GiB] / in NO VG of: 0 [0 ]

4, will add a new partition for expansion sda3
[root @ JQ-AQSB-04 dev] # pvcreate / dev / sda3 # will add a new partition for expansion sda3
Physical volume "/ dev / sda3" successfully created

[root @ JQ-AQSB-04 dev] # pvscan # View scalability has been shown that the space found sda3
the PV / dev / sda2 VG of volgroup LVM2 [GiB 29.51 / 6.51 GiB Free]
the PV / dev / sda3 LVM2 [993.99 GiB]

[root@JQ-AQSB-04 dev]# pvcreate /dev/sda3
[root@JQ-AQSB-04 dev]# vgextend VolGroup /dev/sda3 #将新的扩展卷加入
Volume group "VolGroup" successfully extended
vgextend 命令执行前
[root@JQ-AQSB-04 dev]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 7
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 6
Open LV 6
Max PV 0
Cur PV 1
Act PV 1
VG Size 29.51 GiB
PE Size 4.00 MiB
Total PE 7554
Alloc PE / Size 5888 / 23.00 GiB
Free PE / Size 1666 / 6.51 GiB
VG UUID oKMt1Q-GlFT-xZrr-TtgM-zi6a-cxLx-8b29sA
vgextend 命令执行后
[root@JQ-AQSB-04 dev]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 8
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 6
Open LV 6
Max PV 0
Cur PV 2
Act PV 2
VG Size 1023.50 GiB
PE Size 4.00 MiB
Total PE 262016
Alloc PE / Size 5888 / 23.00 GiB
Free PE / Size 256128 / 1000.50 GiB
VG UUID oKMt1Q-GlFT-xZrr-TtgM-zi6a-cxLx-8b29sA

[root @ JQ-AQSB-04 dev] # vgs # spatial scalable
VG of the Attr #PV #LV #SN VSize vfree
volgroup WZ 2. 6 0 - N- 1023.50g 1000.50g

[root@JQ-AQSB-04 dev]# df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01 4.0G 449M 3.3G 12% /
tmpfs 48G 0 48G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolGroup-LogVol04 4.0G 1.9G 1.9G 50% /home
/dev/mapper/VolGroup-LogVol05 4.0G 136M 3.7G 4% /opt
/dev/mapper/VolGroup-LogVol02 4.0G 3.2G 632M 84% /usr
/dev/mapper/VolGroup-LogVol03 4.0G 413M 3.4G 11% /var

[root @ JQ-AQSB-04 dev] # lvextend -L + 1000G / dev / mapper / VolGroup-LogVol04 # added to add a new volume to the specified directory
the Extending Logical Volume 1004.00 GiB LogVol04 to
the Logical Volume LogVol04 successfully Resized

[root@JQ-AQSB-04 dev]# resize2fs /dev/mapper/VolGroup-LogVol04 #格式化新扩展分区
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-LogVol04 is mounted on /home; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 63
Performing an on-line resize of /dev/mapper/VolGroup-LogVol04 to 263192576 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-LogVol04 is now 263192576 blocks long.

[root@JQ-AQSB-04 dev]# timed out waiting for input: auto-logout
[wangguan@JQ-AQSB-04 ~]$ timed out waiting for input: auto-logout
Connection to 10.10.121.26 closed.

添加后展示
[wangguan@JQ-AQSB-04 ~]$ df -lh
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-LogVol01 4.0G 449M 3.3G 12% /
tmpfs 48G 0 48G 0% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/mapper/VolGroup-LogVol04 989G 1.9G 937G 1% /home
/dev/mapper/VolGroup-LogVol05 4.0G 136M 3.7G 4% /opt
/dev/mapper/VolGroup-LogVol02 4.0G 3.2G 632M 84% /usr
/dev/mapper/VolGroup-LogVol03 4.0G 413M 3.4G 11% /var

Guess you like

Origin blog.51cto.com/14613575/2454003