To expand the Linux hard drive in a exsi virtual machinepost by rocdk890/2015-5-18 14:45 Monday Linux technologyPost a commentToday, the company colleagues came to me to say that the company's Exsi server on a virtual machine hard disk expansion, well, even after exsi, directly on the original hard disk 40G added 20G, and so I added, colleagues just told me that the Linux system, OK, It can only be changed with SSH. Here's the experiment I did with another virtual machine.
System: CentOS 5.x
1.exsi expansion diagram
Before expansion:
After expansion:
2. Preparation before partitioning
Yum-y Install parted
Ps:centos Minimal installation By default there is no Partprobe command, so we will install it with Yum
3. View current drive status
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup00-logvol00
38G 3.2G 33G 9%/
/DEV/SDA1 99M 12M 82M 13%/boot
Tmpfs 506M 0 506M 0%/dev/shm
[Email protected] ~]# fdisk-l
disk/dev/sda:64.4 GB, 64424509440 bytes
255 heads, Sectors/track, 7832 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 104391 Linux
/dev/sda2 5221 41833260 8e Linux LVM
4. Start the drive expansion
[Email protected] ~]# FDISK/DEV/SDA
The number of cylinders for this disk was set to 7832.
There is nothing wrong with the, but this is larger than 1024,
And could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from the other OSs
(e.g., DOS fdisk, OS/2 fdisk)
Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 3
First cylinder (5222-7832, default 5222):
Using Default Value 5222
Last cylinder or +size or +sizem or +sizek (5222-7832, default 7832):
Using Default Value 7832
Command (M for help): T (Modify partition type Linux LVM, 8e) Partition number (1-4): 3Hex code (type L to list codes): 8eChanged system Type of partition 3 to 8e (Linux LVM)
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 is used at the next reboot.
Syncing disks.
And then do it again:
[Email protected] ~]# fdisk-l
disk/dev/sda:64.4 GB, 64424509440 bytes
255 heads, Sectors/track, 7832 cylinders
Units = Cylinders of 16065 * 8225280 bytes
Device Boot Start End Blocks Id System
/DEV/SDA1 * 1 104391 Linux
/dev/sda2 5221 41833260 8e Linux LVM
/dev/sda3 5222 7832 20972857+ 8e Linux
You can see that the Sda3 has already appeared, expressed as a usable state. Continue below:
[Email protected] ~]# Partprobe
[Email protected] ~]# Partprobe/dev/sda3
PS: Using the Fdisk tool just writes partition information to disk, and if you need to mkfs a disk partition, you need to restart the system, while using Partprobe will allow kernel to re-read the partition information to avoid rebooting the system.
5. Create physical volumes and join groups
[Email protected] ~]# Pvcreate/dev/sda3
Physical volume "/dev/sda3" successfully created
[Email protected] ~]# vgextend Volgroup00/dev/sda3
Volume Group "VolGroup00" successfully extended
View physical Volume conditions
[Email protected] ~]# Vgdisplay
---Volume Group---
VG Name VolGroup00
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access Read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
ACT PV 2
VG Size 59.88 GB
PE Size 32.00 MB
Total PE 1916
Alloc pe/size 1276/39.88 GB
Free Pe/size 640/20.00 GB
VG UUID Qljcmx-fzv2-neha-nze0-raoq-p1r0-qv5plu
[Email protected] ~]# lvresize-l +20g/dev/volgroup00/logvol00
Extending logical Volume LogVol00 to 58.88 GB
Logical Volume LogVol00 successfully resized
[Email protected] ~]# resize2fs/dev/volgroup00/logvol00
RESIZE2FS 1.39 (29-may-2006)
Filesystem at/dev/volgroup00/logvol00 is mounted on/; On-line resizing required
Performing an on-line resize of/dev/volgroup00/logvol00 to 15433728 (4k) blocks.
The filesystem on/dev/volgroup00/logvol00 is now 15433728 blocks long.
6. Verification
[Email protected] ~]# df-h
Filesystem Size used Avail use% mounted on
/dev/mapper/volgroup00-logvol00
58G 3.2G 51G 6%/
/DEV/SDA1 99M 12M 82M 13%/boot
Tmpfs 506M 0 506M 0%/dev/shm
Well, you can see that the new added capacity has been added in.
Source: https://blog.slogra.com/post-593.html
From for notes (Wiz)
To expand the Linux hard drive in a exsi virtual machine