1

I am attempting to get a sub-4gb image to retain its image size on my rpi regardless of the sdcard size. I am looking at using the ubuntu server image built by Ryan Finnie ubuntu-16.04-preinstalled-server-armhf+raspi3.img from the ubuntu wiki

The suggestion in Temporarily disable expand filesystem during first boot by goldilocks of disabling of init=/usr/lib/raspi-config/init_resize.sh from /boot/cmdline.txt works on Ubuntu Mate.

But the server image does not have the init=/usr/lib/raspi-config/init_resize.sh in /boot/cmdline.txt - but first boot expands the image to the max capacity of the card.

Does anyone know where the partition resize is triggered on this ubuntu server image?

  • Where are you downloading this image from? Is it this one? – Hydraxan14 Jul 18 '17 at 22:50
  • That was latest official release, although it's for the rpi2. The Ubuntu wiki mentions an unofficial rpi3 port. Are you using that one? – Hydraxan14 Jul 18 '17 at 23:25
  • @Hydraxan14 Yes, that is the one I am using as unfortunately the official one doesnt boot up on rpi 3 yet. I have updated the question to reflect this now. – sith Jul 19 '17 at 5:55
  • /usr/lib/python3/dist-packages/cloudinit/config/cc_resizefs.py looks suspect. Now I just gotta figure out how it's getting called... – Hydraxan14 Jul 19 '17 at 16:09
1

cloud-init

The usual raspi-config script that resizes the root filesystem on boot isn't in this Ubuntu image.

The only init-related resize program I could find was /usr/lib/python3/dist-packages/cloudinit/config/cc_resizefs.py. This is apparently part of the Ubuntu cloud-init package, and has a function that will resize the root filesystem on boot.

The cloud-init package has a configuration file in /etc/cloud/cloud.cfg which contains:

# The modules that run in the 'init' stage
cloud_init_modules:
 - migrator
 - ubuntu-init-switch
 - seed_random
 - bootcmd
 - write-files
 - growpart
 - resizefs
 - set_hostname
 - update_hostname
 - update_etc_hosts
 - ca-certs
 - rsyslog
 - users-groups
 - ssh

Notice resizefs? That's probably what's triggering the resize.


Disabling

Removing resizefs from that config file might be sufficient, or you can just disable cloud-init.

The installed version of cloud-init (0.7.7) was the first version to include an easy way to completely disable it:

 This is fix-committed now with systemd.
2 ways to disable cloud-init and stop any bottlenecks it would put in place during boot:
 a.) touch /etc/cloud/cloud-init.disabled
 b.) boot with cloud-init=disabled on kernel command line.
  • thanks for the research Hydraxan14... I will test out the cloud-init=disabled and report back asap. – sith Jul 21 '17 at 5:55
  • Strangely, after booting with cloud-init=disabled in the cmdline.txt I am unable to login with username "ubuntu", password "ubuntu" - here is the comdline.txt "net.ifnames=0 dwc_otg.lpm_enable=0 console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline cloud-init=disabled rootwait" – sith Jul 21 '17 at 12:10
  • I think one of cloud-init's jobs is to set up a temporary 'ubuntu' user. So maybe completely disabling it isn't the best idea after all... – Hydraxan14 Jul 21 '17 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.