# Q: how to resize root partition live without reboot

## dirtbag

Just curious if anyone has come up with a good way to do this with 

root partition on an ext3 filesystem under lvm2 control

we are trying to figure out if this can be done on a linux guest under ESXi server.

I have gotten as far as getting Linux to see the "resized" disk, but not lvm.

maybe with another filesystem type?

any ideas? CAN IT BE DONE?!  :Wink: 

-db

----------

## NeddySeagoon

dirtbag,

It should justwork as it does with any other partition. ext3 supports online resizing.

I must say that I've only ever grown partitions in LVM, then its grow the partition, grow the filesystem

For a shrink, its the other way round, shrink the filesystem, shrink the partition. Do make sure that the partition is bigger than the filesystem at all times.

```
man resize2fs
```

may be your friend.

----------

## dirtbag

yeah, know how it all is *supposed* to work.. but it just doesnt seem to work on a live / partition without reboot..

-db

----------

## stobbsm

It has always worked for me.

What commands are you using?

I always do:

```
lvextend -L+100M /path/to/lvm/devfile

resize2fs /path/to/lvm/devfile
```

and have never had a problem.

----------

## dirtbag

ok, so here is mr linux box:

```

[root@tacsuns-linux ~]# fdisk -l /dev/sdb

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1   *           1        2885    23173731   8e  Linux LVM

[root@tacsuns-linux ~]# 

[root@tacsuns-linux ~]# pvs

  /dev/hdc: open failed: No medium found

   PV         VG   Fmt  Attr PSize  PFree 

  /dev/sdb1  vg0  lvm2 a-   22.09G 96.00M

```

I delete the partition and re-add it with the "bigger" size..

```

[root@tacsuns-linux ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 3916.

There is nothing wrong with that, 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 other OSs

   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1   *           1        2885    23173731   8e  Linux LVM

Command (m for help): d

Selected partition 1

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-3916, default 1): 

Using default value 1

Last cylinder or +size or +sizeM or +sizeK (1-3916, default 3916): 

Using default value 3916

Command (m for help): t

Selected partition 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdb: 32.2 GB, 32212254720 bytes

255 heads, 63 sectors/track, 3916 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1               1        3916    31455238+  8e  Linux LVM

Command (m for help): w

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 will be used at the next reboot.

Syncing disks.

[root@tacsuns-linux ~]# 

make linux rescan it.. 

echo 1 > /sys/bus/scsi/drivers/sd/0:0:1:0/rescan

partprobe

[root@tacsuns-linux ~]# pvresize /dev/sdb1

  /dev/hdc: open failed: No medium found

  Physical volume "/dev/sdb1" changed

  1 physical volume(s) resized / 0 physical volume(s) not resized

[root@tacsuns-linux ~]# pvs

  /dev/hdc: open failed: No medium found

  PV         VG   Fmt  Attr PSize  PFree 

  /dev/sdb1  vg0  lvm2 a-   22.09G 96.00M

[root@tacsuns-linux ~]# 

```

fdisk clearly shows the disk as having ~30 gigs, but pvs still reports the size as 22.09G

-db

----------

## stobbsm

Why wouldn't you just create a new partition and then add it to the vg? That is the power of lvm.

----------

## dirtbag

I guess that just gets messy after a while.

-db

----------

## stobbsm

If you have maybe 500 different HD's to do it with, otherwise it's the way it's designed to work.

I don't think it can be resized that way without re-creating the vg.

----------

