Manually performed partitioning changes get reverted on reboot

Bug #1839491 reported by Rodrigo Barbieri
12
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Triaged
Medium
Unassigned
cloud-init
Invalid
Undecided
Unassigned

Bug Description

Hello,

I am facing an issue where I need to make changes to the initially deployed partition layout, but upon making those changes and rebooting, the partition layout gets reverted.

My env:
MAAS version: 2.6.0 (7802-g59416a869-0ubuntu1~18.04.1)
System vendor: HP
System product: ProLiant DL360 Gen9 (780021-S01)
System version: Unknown
Mainboard product: ProLiant DL360 Gen9
Mainboard firmware version: P89
Mainboard firmware date: 12/27/2015
CPU model: Intel(R) Xeon(R) CPU E5-2690 v3
Deployed (16.04 LTS "Xenial Xerus")
Kernel: xenial (ga-16.04)
Power type: ipmi
Power driver: LAN_2_0 [IPMI 2.0]
Power boot type: EFI boot
Architecture amd64/generic
Minimum Kernel: no minimum kernel
Interfaces: eno1, eno2, noe3, eno4, eno49, eno50. Only eno49 is used.
Storage: sda Physical 1TB, sdb Physical 1TB.

Steps to reproduce:

1. Deploy MAAS with the following partition configuration:
sda-part1 536.9 MB Partition fat32 formatted filesystem mounted at /boot/efi
sda-part2 100.0 GB Partition ext4 formatted filesystem mounted at /

2. Check the partitions on the node:

$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
|-sda1 8:1 0 512M 0 part /boot/efi
`-sda2 8:2 0 931G 0 part /
sdb 8:16 0 931.5G 0 disk

Here we notice the initial partitioning scheme is not respected. This could be related to the main issue of partitioning changes being reverted, but could also be a separate issue.

3. Boot an ubuntu ISO and go into rescue mode. I used ubuntu-16.04.6-server-amd64.iso

4. Choose "Do not use a root filesystem" and "Execute a shell in the installer environment".

4. Run the following commands:

$ e2fsck -f /dev/sda2

$ resize2fs /dev/sda2 150G

$ e2fsck -f /dev/sda2

$ sudo parted /dev/sda

(parted) unit GiB print

(parted) resizepart

Partition number? 2

End? 200GiB

(parted) print

You should see partition 2 resized.

(parted) quit

$ e2fsck -f /dev/sda2

5. Confirm

$ fdisk -l

6. Sync writes

$ sync

7. Reboot the node. Remove ISO image.

8. Let system boot, check partitions again:

$ lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 931.5G 0 disk
|-sda1 8:1 0 512M 0 part /boot/efi
`-sda2 8:2 0 931G 0 part /
sdb 8:16 0 931.5G 0 disk

We can see see that the changes were reverted.

If I remove cloud-init, I can successfully re-partition and reboot, without the changes being reverted.

Attached logs before and after repartition.

Revision history for this message
Rodrigo Barbieri (rodrigo-barbieri2010) wrote :
Revision history for this message
Rodrigo Barbieri (rodrigo-barbieri2010) wrote :

Hello,

After speaking with some folks, we realized the resizefs or growpart modules are growing back the partitions on every reboot.

However, it should do so only when /var/lib/cloud/instance changes. In my case it never changed, I was using the same MAAS machine all the time. There could be a bug in the way it the instance value to previous values, causing it to think it is a new machine every time I reboot.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Cloud-init is the one performing the resize and MAAS images are based off the Ubuntu cloud images, it is more an issue with cloud-init and the cloud images than MAAS.

Changed in maas:
status: New → Invalid
Revision history for this message
Dan Watkins (oddbloke) wrote :

Hi Rodrigo,

Thanks for using cloud-init, and for filing this bug report!

> After speaking with some folks, we realized the resizefs or growpart modules are growing back the partitions on every reboot.

Yes, this is expected behaviour.

> However, it should do so only when /var/lib/cloud/instance changes.

What is the basis for this statement? Looking at the docs for growpart[0] and resizefs[1], they both document that they run "always" (i.e. every boot). Looking at the code, this has been the case since 2013 and 2012 respectively.

If you are looking for a way to disable the growpart behaviour, you may want to look at /etc/growroot-disabled in the docs[0].

I don't believe there's any cloud-init work here, so I'm going to mark this as Incomplete. Please feel free to set it back to New, with an explanatory comment, if you disagree!

Thanks!

Dan

[0] https://cloudinit.readthedocs.io/en/latest/topics/modules.html#growpart
[1] https://cloudinit.readthedocs.io/en/latest/topics/modules.html#resizefs

Changed in cloud-init:
status: New → Incomplete
summary: - Manully performed partitioning changes get reverted on reboot
+ Manually performed partitioning changes get reverted on reboot
Revision history for this message
Trent Lloyd (lathiat) wrote :

You can disable this using cloudinit-userdata

For juju:

lathiat@optane ~$ cat userdata.yaml
cloudinit-userdata: |
  growpart:
    mode: off
lathiat@optane ~$ juju model-config userdata.yaml
lathiat@optane ~$

For MAAS, refer to here: https://discourse.maas.io/t/customizing-maas-deployments-with-cloud-init/165 - it's only possible with the MAAS CLI and not through the MAAS UI - if you want it to work with the MAAS UI I thin you need to edit the yaml templates on the MAAS machine but that's not really supported I don't think.

From what I observed when using this myself, MAAS seems to grow the filesystem to the actual configured size during deployment without cloud-inits help during boot (which is when it is often done for 'cloud' VMs). So disabling it should still get you the correct size, and prevent it growing into the rest of the partition.

As a hacky alternative if you can't disable growpart with the above steps - if you add another partition after the root filesystem, it will no longer grow into that space. So you could add for example a blank un-used partition taking up either a little space or the entire rest of the device. And then delete that and put whatever partitions you wanted there post-deployment.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Sounds like this is indeed an issue in MAAS then. MAAS should turn off growpart, since we know how big the disks are already and can set up the right partition size during installation.

Changed in maas:
status: Invalid → Triaged
importance: Undecided → High
milestone: none → 2.7.0alpha1
Revision history for this message
Björn Tillenius (bjornt) wrote :

Rodrigo, you can work around this bug by creating /etc/growroot-disabled. If that file is present, cloud-init won't resize the partition.

Revision history for this message
Ryan Harper (raharper) wrote :

Moving cloud-init task to invalid, no bug/work for cloud-init.

Changed in cloud-init:
status: Incomplete → Invalid
Revision history for this message
Rodrigo Barbieri (rodrigo-barbieri2010) wrote :

Thanks folks, I was able to workaround the problem.

I agree that MAAS shoulnd't be resizing in this particular situation and growpart should be disabled by default.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

MAAS would need to conditionalize this because in some cases you would want that behaviour, say deploying a Windows image, where it is dd based. On reboot you want cloudbase-init to resize the partition, something that curtin cannot do for Windows.

Changed in maas:
importance: High → Medium
Changed in maas:
milestone: 2.7.0b1 → 2.7.0b2
Changed in maas:
milestone: 2.7.0b2 → none
Revision history for this message
Jerzy Husakowski (jhusakowski) wrote :

See comment #10 for solution direction.

Changed in maas:
milestone: none → 3.4.0
Revision history for this message
James Falcon (falcojr) wrote :
Alberto Donato (ack)
Changed in maas:
milestone: 3.4.0 → 3.4.x
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.