Hi there. Just wanted to see if anyone had any experience with this. I inherited an Oracle Linux vm that has virtual disks that are on a paravirtual scsi controller. We tried to expand one of these disks by first adding space to the vmdk then using fdisk on the Linux side. After running fdisk the disk would not mount again as its UUID was now different than what was listed in the fstab file. Has anyone seen this before or have any idea what can be done to prevent it? We have other disks that need to be grown out as well. Thanks!
IMO fdisk cannot handle disk expansion tasks. If you configured the disks with LVM during installation, you could use the LVM commands to expand the disk to the new capacity. However expanding / (root) partition can be challenging. If you need additional disk space, the ideal solution (if you haven't used LVM) would be to add another disk to the VM and configure it as additional partition (space) such as "/home".
To better understand what your partition and filesystem layout looks like, please post the output of the following commands:
# fdisk -ul /dev/sda
# df -Th
# cat /etc/fstab
I have a script to automatically extend lvm partitions on RHEL and CentOS, it should work with any other Linux as well. This method doesn't change the LVM UUIDs. Here is an excerpt of the relevant fdisk portion of it:
Caution: Use at your own risk and test thoroughly.
cat <<FDISKEND | fdisk /dev/sda
u #switch to disk sector-based instead of cylinder-based configuration
p #print partition table
d #delete partition
2 #partition to delete is #2 (the one you want to grow, must be last partition on the disk)
n #create new partition
p #new primary partition
2 #new partition is #2
1026048 #starting sector of the new partition. MUST be identical to the original starting point of partition #2 as asserted by a previous fdisk -ul /dev/sda
#newline without input here, will automatically select the last disk sector as partition end
t #change partition type
2 #of partition #2
8e #set partition type to Linux LVM
p #print new partition table
w #write partition table to disk
This fdisk procedure above is tailored to work with my default template partition layout which looks like the one below. It's important to note the partition number and starting sector of the partition you want to expand and adjust the above fdisk script accordingly. Also you can only extend the last partition of a disk this way and not a partition that sits between two others (a default installation should always put the LVM last).
# fdisk -ul /dev/sda
Disk /dev/sda: 10.7 GB, 10737418240 bytes
64 heads, 32 sectors/track, 10240 cylinders, total 20971520 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: 0x00000fcc
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
/dev/sda2 1026048 20971519 9972736 8e Linux LVM
After the disk partition has been extended with fdisk, you have to reboot the system before you resize the actual filesystem.
Once rebooted use this to grow the LVM volume, make sure you use the correct logical volume name (/dev/VolGroup/lv_root in my case) :
#Extend LVM physical volume on the partition first
#Extend the LVM logical volume, using 100% of the free allocation units and resize filesystem
lvextend --extents +100%FREE /dev/VolGroup/lv_root --resizefs
You don't even need to power-off the VM to extend a disk. You can expand the VMs disk through the VM settings and then just rescan the SCSI bus in the OS before extending the partition:
echo 1 > /sys/class/scsi_device/*\:0\:0\:0/device/rescan
echo "- - -" > /sys/class/scsi_host/host*/scan
Probably should have clarified. These disks are not the root volume and they were for one reason or another not configured for LVM. These were inherited so the why's of things are not known to me. Management's preference is to grow disks instead of adding new ones.
Probably should have clarified. These disks are not the root volume and they were for one reason or another not configured for LVM
In that case it should make things even easier, provided you want to grow the last partition of the disk. Please post the output of the commands I requested to make things clear.
Assuming you have a normal MBR and not a GPT partition layout, basically you should just need to unmount the filesystem, re-create the partition with the same starting sector, expand the filesystem with resize2fs and then re-mount the filesystem again. There are tons of tutorials describing this in detail out on the web.
With this method should be no changing UUIDs involved whatsoever.
That is what we have been doing. Problem is that after the re-create, if the disk in question has been storage vMotioned, the UUID is changing and the disk can't be mounted again.If the disk hasn't been storage vMotioned the re-create doesn't cause a UUID change. This has been tested numerous times with several disks. The only difference we can find between these servers and others where this hasn't happened is that these servers are using paravirtual scsi controllers for the disks being grown. I need to figure out why this is happening.
My Linux admin is busy at the moment so I can't get those commands run yet.