sprotheroe / vagrant-disksize

Vagrant plugin to resize disks in VirtualBox
MIT License
479 stars 51 forks source link

Readme: Write guide to resize guest fs #31

Open rodrigobdz opened 5 years ago

rodrigobdz commented 5 years ago

Add documentation on how-to resize guest filesystem to help users. There are a couple of additional steps involved after installing vagrant-disksize which are not straightforward.

noaho commented 5 years ago

These are the commands I used in my Vagrantfile for bento/ubuntu-18.04

#Extend Volume to take up free space
$resizescript = <<-SCRIPT
parted /dev/sda resizepart 1 100%
pvresize /dev/sda1
lvextend -r -l +100%FREE /dev/vagrant-vg/root
SCRIPT
config.vm.provision :shell, inline: $resizescript
blissdev commented 5 years ago

Unfortunately these instructions don't seem to work RHEL-based systems such as Fedora.

rodrigobdz commented 5 years ago

@blissdev Did you get an error? Please attach anything which could be useful identifying the problem

p0rkjello commented 5 years ago

I have a CentOS 7.7 box. The 8GB drive have been resized to 100GB using this plugin. I cannot figure out how to resize or even see the additional space. Could you recommend a solution?

[vagrant@habitat ~]$ sudo lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                1s3rZJ-khqL-pvYz-sRud-GPZR-XXON-QsMI6H
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-10-17 17:18:33 +0000
  LV Status              available
  # open                 2
  LV Size                800.00 MiB
  Current LE             200
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                dBzlWq-g9TK-YKvE-QS53-rhz8-BDzz-Hb3chv
  LV Write Access        read/write
  LV Creation host, time localhost, 2019-10-17 17:18:33 +0000
  LV Status              available
  # open                 1
  LV Size                <6.03 GiB
  Current LE             1543
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

[vagrant@habitat ~]$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               6.81 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1743
  Free PE               0
  Allocated PE          1743
  PV UUID               9oXjBX-43kf-qTl6-Nmyg-gq3J-eKu0-b2r2GE
pedrofurtado commented 4 years ago

For CentOS 7/8: https://github.com/sprotheroe/vagrant-disksize/issues/39

rodrigobdz commented 4 years ago

@sprotheroe Could you review this PR?

clbarnes commented 3 years ago

For reference, this is also discussed in #37 . The snippet posted by @noaho has worked for me in the past but does not after bumping the ubuntu version of my box.

rodrigobdz commented 3 years ago

@clbarnes Thanks for linking the issue. Regarding the snippet, it probably doesn't work anymore because the device partition number (/dev/sda1) is different. Please verify.

Ideally, the device partition selection should be done automatically in the script.

clbarnes commented 3 years ago

I tried with ubuntu/bionic64 (same ubuntu version, just a different provider). I provisioned without a disk resize, then SSH'd in, but according to df, /dev/sda1 is still the only device partition number. fdisk --list reports a partition /dev/sda1 and a disk /dev/sdb (10MiB)

However, despite failing, df, fdisk, and lsblk do report the desired size rather than the default size. Does this suggest it may not need the pvresize/lvresize?

rodrigobdz commented 3 years ago

Hard to say but here's a checklist to verify correct resizing.

Verify actual size of:

clbarnes commented 3 years ago

It seems the way to look at logical volumes, physical volumes, and volume groups is through the (lv|pv|vg)(s|display|scan) commands. I get no output from any of them (as root), even with the --all flag. Is it possible LVM is just being sidestepped entirely?

I tried to fallocate a file larger than the original disk space, and it succeeded. Doing that with a file larger than the desired disk space (aka the disk space reported by df/fdisk/lsblk) failed. I would take this to mean that resizing volumes and partitions is not necessary with ubuntu/* boxes or recent bento/ubuntu-* boxes.