# Automatic resizing of partition (VMware)

**URL:** <https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308>\
**Category:** RancherOS\
**Created:** [July 5, 2016, 9:55am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308 "2016-07-05T09:55:48Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![giezi](https://avatars.discourse-cdn.com/v4/letter/g/edb3f5/32.png) [@giezi](https://forums.suse.com/u/giezi)\
**Post date:** [July 5, 2016, 9:55am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/1 "2016-07-05T09:55:48Z")

</div>

Hi there,

we are using RancherOS v0.5.0 with the new resize option ([http://docs.rancher.com/os/configuration/resizing-device-partition/](http://docs.rancher.com/os/configuration/resizing-device-partition/)) in our cloud-config:

#cloud-config  
ssh\_authorized\_keys:

- ssh-rsa xxx  
hostname: xxx

rancher:  
resize\_device: /dev/sda  
network:  
dns:  
nameservers:  
- xxx  
- xxx  
interfaces:  
eth\*:  
dhcp: false  
eth0:  
address: 172.16.16.10/22  
gateway: 172.16.16.1  
mtu: 1500

We have now resized the VMDK form 10GB to 40GB.  
After a reboot, RancherOS still show us only 9.2 GB disk size:

df -h  
Filesystem Size Used Available Use% Mounted on  
overlay 9.2G 312.3M 8.4G 3% /

How does the automatic resizing of partition exactly work?

Thank you for your help.

Best regards  
Reto

---

<div class="post-metadata">

**Author:** ![joshwget](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/joshwget/32/704_2.png) [@joshwget](https://forums.suse.com/u/joshwget)\
**Post date:** [July 7, 2016, 3:48am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/2 "2016-07-07T03:48:09Z")

</div>

Did you install with the given cloud-config before resizing the VMDK? The resizing functionality is set to only resize once, so if you changed the disk size after the first install boot then it’ll not resize again.

You can test that this is the issue by removing `/var/lib/rancher/resize.done` and rebooting. If your disk isn’t properly resized afterwards then the issue is elsewhere.

---

<div class="post-metadata">

**Author:** ![hwaastad](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/hwaastad/32/225_2.png) [@hwaastad](https://forums.suse.com/u/hwaastad)\
**Post date:** [July 7, 2016, 12:01pm UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/3 "2016-07-07T12:01:55Z")

</div>

Hi,  
same issue here (OpenStack and 0.5.0)

in 0.4.5 i could do:  
environment:  
RESIZE\_DEV: /dev/vda  
FORCE: true  
services\_include:  
resize-fs: true

But this does not work anymore.

Have the same config as @giezi

There is no resize.done in /var/lib/rancher directory.

I was hoping to get disk resized on initial boot (device: /dev/vda).

br hw

---

<div class="post-metadata">

**Author:** ![joshwget](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/joshwget/32/704_2.png) [@joshwget](https://forums.suse.com/u/joshwget)\
**Post date:** [July 8, 2016, 3:49am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/4 "2016-07-08T03:49:42Z")

</div>

Resizing is basically done by running the following commands. Can you try running these manually (replacing the device as needed)?

```bash
growpart /dev/vda 1
partprobe
resize2fs /dev/vda1

```

---

<div class="post-metadata">

**Author:** ![hwaastad](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/hwaastad/32/225_2.png) [@hwaastad](https://forums.suse.com/u/hwaastad)\
**Post date:** [July 8, 2016, 7:29am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/5 "2016-07-08T07:29:52Z")

</div>

OK,  
made a machine with 20GB disk

[root@asdfasfd rancher]# df -h  
Filesystem Size Used Available Use% Mounted on  
overlay 7.4G 261.4M 6.7G 4% /  
tmpfs 1.9G 0 1.9G 0% /dev  
tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup  
none 1.9G 532.0K 1.9G 0% /run  
/dev/vda1 7.4G 261.4M 6.7G 4% /mnt  
/dev/vda1 7.4G 261.4M 6.7G 4% /media  
/dev/vda1 7.4G 261.4M 6.7G 4% /home  
/dev/vda1 7.4G 261.4M 6.7G 4% /opt  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/sbin/halt  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/sbin/iptables  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/lib/firmware  
devtmpfs 1.9G 0 1.9G 0% /host/dev  
shm 64.0M 0 64.0M 0% /host/dev/shm  
none 1.9G 532.0K 1.9G 0% /var/run  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/sbin/poweroff  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/sbin/reboot  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/lib/modules  
/dev/vda1 7.4G 261.4M 6.7G 4% /etc/selinux  
/dev/vda1 7.4G 261.4M 6.7G 4% /etc/docker  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/sbin/shutdown  
/dev/vda1 7.4G 261.4M 6.7G 4% /var/log  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/docker-containerd-shim.dist  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/share/ros  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/cloud-init  
/dev/vda1 7.4G 261.4M 6.7G 4% /var/lib/rancher  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/sbin/netconf  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/docker-containerd.dist  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/respawn  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/dockerlaunch  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/switch-console  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/docker.dist  
/dev/vda1 7.4G 261.4M 6.7G 4% /var/lib/docker  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/user-docker  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/sbin/wait-for-docker  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/ros  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/system-docker  
/dev/vda1 7.4G 261.4M 6.7G 4% /usr/bin/docker-runc.dist  
/dev/vda1 7.4G 261.4M 6.7G 4% /var/lib/rancher/conf  
/dev/vda1 7.4G 261.4M 6.7G 4% /var/lib/rancher/cache  
/dev/vda1 7.4G 261.4M 6.7G 4% /etc/ssl/certs/ca-certificates.crt.rancher  
/dev/vda1 7.4G 261.4M 6.7G 4% /etc/resolv.conf  
/dev/vda1 7.4G 261.4M 6.7G 4% /etc/hostname  
/dev/vda1 7.4G 261.4M 6.7G 4% /etc/hosts  
shm 64.0M 0 64.0M 0% /dev/shm  
devtmpfs 1.9G 0 1.9G 0% /dev  
shm 64.0M 0 64.0M 0% /dev/shm

* * *

growpart /dev/vda 1  
CHANGED: partition=1 start=2048 old: size=16775168 end=16777216 new: size=41940959,end=41943007  
partprobe  
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.  
Error: Partition(s) 1 on /dev/vda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.

Reboot

resize2fs /dev/vda1  
resize2fs 1.42.13 (17-May-2015)  
Filesystem at /dev/vda1 is mounted on /opt; on-line resizing required  
old\_desc\_blocks = 1, new\_desc\_blocks = 2  
The filesystem on /dev/vda1 is now 5242619 (4k) blocks long.

All is OK.

So,  
It needs a reboot before resize.

running commands in the sequence you describe is not working:  
growpart /dev/vda 1  
CHANGED: partition=1 start=2048 old: size=16775168 end=16777216 new: size=41940959,end=41943007  
partprobe  
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.  
Error: Partition(s) 1 on /dev/vda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.  
resize2fs /dev/vda1  
resize2fs 1.42.13 (17-May-2015)  
The filesystem is already 2096896 (4k) blocks long. Nothing to do!

However running:  
docker run --privileged -i --rm ubuntu bash \<\< EOF  
apt-get update  
apt-get install -y cloud-guest-utils parted  
growpart /dev/xda 1  
partprobe  
resize2fs /dev/vda1  
EOF

disk is grown without the need for rebooting.

So, what can be done fixing this?

/hw

---

<div class="post-metadata">

**Author:** ![joshwget](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/joshwget/32/704_2.png) [@joshwget](https://forums.suse.com/u/joshwget)\
**Post date:** [July 8, 2016, 8:33pm UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/6 "2016-07-08T20:33:33Z")

</div>

Would you mind filing an issue for this? It does seem like there is something incorrect about the default console that’s causing this. Maybe a missing package or something like that.

---

<div class="post-metadata">

**Author:** ![giezi](https://avatars.discourse-cdn.com/v4/letter/g/edb3f5/32.png) [@giezi](https://forums.suse.com/u/giezi)\
**Post date:** [July 12, 2016, 10:40am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/7 "2016-07-12T10:40:33Z")

</div>

> [@joshwget](#):
>
> Did you install with the given cloud-config before resizing the VMDK? The resizing functionality is set to only resize once, so if you changed the disk size after the first install boot then it’ll not resize again.

Thank you for your answer!  
Yes, we’ve installed the RancherOS with a cloud-config on a disk (10GB) with the resize option.  
Afterwards, we have resized the 10GB disk to 40GB.

In my perspective, it would be very nice if there will be an “always-on” option for the resizing, like CoreOS:  
If the disk will be extended on VM-Level, we just need to reboot the machine and the resize is done fully automatically.

What do you think about?

Best regards  
Reto

---

<div class="post-metadata">

**Author:** ![joshwget](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/joshwget/32/704_2.png) [@joshwget](https://forums.suse.com/u/joshwget)\
**Post date:** [July 14, 2016, 11:40pm UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/8 "2016-07-14T23:40:19Z")

</div>

I agree, this should be an option. Please fill an issue for this as well 🙂

---

<div class="post-metadata">

**Author:** ![giezi](https://avatars.discourse-cdn.com/v4/letter/g/edb3f5/32.png) [@giezi](https://forums.suse.com/u/giezi)\
**Post date:** [July 27, 2016, 9:10am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/9 "2016-07-27T09:10:15Z")

</div>

Hi Josh

Sure, I will do this - many thanks!

Best regards  
Reto

---

<div class="post-metadata">

**Author:** ![EugenMayer](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/eugenmayer/32/1415_2.png) [@EugenMayer](https://forums.suse.com/u/EugenMayer)\
**Post date:** [July 29, 2016, 8:18am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/10 "2016-07-29T08:18:07Z")

</div>

did you create the issue already? i had the same issue on KVM.

```auto
rancher:
  resize_device: /dev/vda
  services_include:
    resize-fs: true

```

i could get it down manually by

```auto
growpart /dev/vda 1
probpart
resize2fs /dev/vda1

```

resizefs hints, that its a online-resize:

```auto
Filesystem at /dev/vda1 is mounted on /opt; on-line resizing required

```

But it all works out

update: found the issue [https://github.com/rancher/os/issues/1131](https://github.com/rancher/os/issues/1131)

---

<div class="post-metadata">

**Author:** ![EugenMayer](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/eugenmayer/32/1415_2.png) [@EugenMayer](https://forums.suse.com/u/EugenMayer)\
**Post date:** [July 29, 2016, 11:47am UTC](https://forums.suse.com/t/automatic-resizing-of-partition-vmware/3308/11 "2016-07-29T11:47:33Z")

</div>

Littel upate

Actually with the resize\_fs setting, i did not need to call growpart, all you need is boot once, then reboot once again and then run resize2fs /dev/vda1

so at some degree growpart already works automated
