VMware allows to extend the size of a virtual disk online - when the VM is running. The next expected steps for Linux system are:
- extend the partition: delete and create a larger one with
fdisk
- extend the PV size with
pvresize
- use free extents for
lvresize
operations - and then
resize2fs
for file system
But I am stuck on the first step: fdisk
and sfdisk
still display the old size for the disk.
My disk is a SCSI virtual disk connected thanks to the virtual LSI Logic controller.
How to refresh the virtual disk size and partition table information available in Linux kernel without reboot ?
As far as I know all that steps are possible for a running Windows, without reboot and even without any user actions thanks to VMWare tools. On Linux, I expects to do all steps online too and I already know steps 2, 3 and 4 work online. But the first one - change partition size declared in the partition table (still) seems to require a reboot.
Update: My system is a Debian Lenny with kernel 2.6.26 and the disk I have extended is the main disk with a large PV containing the "root" LV for "/".
You can do this without a reboot. pvresize doesn't resize the physical volume until the partition is updated with the added space. You must fdisk the partition and recreate it with the the new full size of the disk, after you can rescan'd the drives for it to see the extra space in the first place.
More info: http://theducks.org/2009/11/expanding-lvm-partitions-in-vmware-on-the-fly/
The other answered provided do not address your question, I've identified the correct command to rescan an already connected disk.
We must rescan your already connected disk, first identify which disk you want to rescan.
In my example, I see a symlink named
0:0:0:0
, so we rescan this scsi-disk.I just extended my VMware disk also, and had to scour other answers to find the correct command. Hopefully this will save future searchers from futile attempts.
As far as the root file system
/
is mounted on the disk that has been resized, the partition table and disk size are not refreshed by a SCSI rescan with Linux 2.6.26.I really hope it will be better soon with newer kernel versions.
So I had to:
fdisk
fdisk
partprobe
fromparted
package only if/
is not mounted therepvresize
to get new free space,lvextend
andresize2fs
to allocate some more space to a file systemI have been recommended to simply discard that stupid old partition table and run
pvcreate
directly on the device as Grub2 is able to load a kernel image directly from a file system on a LVM partition. But such a setup is not obvious at all with distribution installers.Update: I have just checked with Debian GNU/Linux Jessie 8.2 running kernel 3.16 and
parted
3.2, thepartprobe
now succeeds after partition table edition withcfdisk
with no reboot.pvresize
works immediately after.If you want to extend a PV stored as logical PC partition, for instance
/dev/sda5
on extended primary partition/dev/sda2
, do not usefdisk
but preferparted
:You need to rescan the disks before you can make the bigger partition.
In Centos you can do this by
then for each host
(replace # with the number)
There is also one more step to the above which is expanding ext or whatever filesystem you are using once you have resized the partition.
You are still going to have to unmount that partition though at some point. What we tend to do is add a 2nd vmware disk and use lvm to extend onto the new disk (and reduce off the old if it is a replacement) as this allows the whole process to happen live.
My PV was not in a partition, but existed on /dev/sdb directly.
On Ubuntu 16.04.1 I was able to do the following to resize a volume from 1024GB to 1.4TB:
No
fdisk
required, and the space was immediately available.You've not provided us enough detail to tell you the exact commands you'll need but essentially you'll need to use the
lvextend
command to extend the logical volume, then thee2fsck
command and then theresize2fs
command to actually expand your filesystem. Each of these commands will need additional parameters, specifically device and filesystem information, that we can't provide but you'll need to know these, just use the --help option for each command to tell you how to use them specifically, plus you'll probably end up using thepvdisplay
,lvdisplay
andmount
commands to help fill out these parameters.No one has posted a complete set of commands, so here we go:
If you dont partition your PV before adding it and instead add the raw disk (/dev/sda instead of /dev/sda1) then you can skip the fdisk part entirely and just pvextend /dev/sda
Sorry for the necro