Due to an influx of spam, we have had to impose restrictions on new accounts. Please see this page for instructions on how to get full permissions. Sorry for the inconvenience.
On SD-Cards we should enlarge the filesystem / partition to take up all the space on first boot, scripts could be take from the raspberry pi. This would also help users using the qemu image sine they'd only need to resize the qcow2.
The rpi script is really old but helpful. I tried the fdisk steps manually but am not getting the disk to resize after a reboot. Here's what I have done:
purism@pureos:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTvda 254:0 0 31.4G 0 disk |-vda1 254:1 0 181M 0 part /boot`-vda2 254:2 0 31.2G 0 part /purism@pureos:~$ sudo fdisk /dev/vda[sudo] password for purism: Welcome to fdisk (util-linux 2.32).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Command (m for help): pDisk /dev/vda: 31.4 GiB, 33664771072 bytes, 65751506 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x888b203eDevice Boot Start End Sectors Size Id Type/dev/vda1 * 2048 372735 370688 181M 83 Linux/dev/vda2 372736 65751505 65378770 31.2G 83 LinuxCommand (m for help): dPartition number (1,2, default 2): 2Partition 2 has been deleted.Command (m for help): nPartition type p primary (1 primary, 0 extended, 3 free) e extended (container for logical partitions)Select (default p): pPartition number (2-4, default 2): 2First sector (372736-65751505, default 372736): Last sector, +sectors or +size{K,M,G,T,P} (372736-65751505, default 65751505): Created a new partition 2 of type 'Linux' and of size 31.2 GiB.Partition #2 contains a ext4 signature.Do you want to remove the signature? [Y]es/[N]o: NCommand (m for help): wThe partition table has been altered.Syncing disks.
It doesn't matter if I say "Y" or "N" to the question about removing the ext4 signature. Either way, after a reboot, the /dev/vda2 partition is still 3.1GB:
The rpi script works on thousands of machines, that's why it's IMHO a good source. For the qcow2 image we could resize during the build with guestfish but since that won't help for the SD cards it would be better to fix with a resize. If that's too much of a hazzle a single guestfish/virt-resize call would do the trick:
@bob.ham mentioned an initiative in Debian to and there's indeed cloud-initramfs-growroot. We should look into adjusting that (if it doesn't work out of the box).
clout-initramfs-growroot works nicely. The only thing left is to do a
resize2fs /dev/vda
after an initial boot (which we could put into a systemd unit). @heather.ellsworth can you verify that it works for you too? If so we can just add it to the image.
For the nitrogen boards we need to switch to an initramfs to make that work but that's fine and a separate issue.
I haven't done anything with cloud-initramfs-growroot... but I can tell you that resize2fs /dev/vda works after doing the above fdisk steps I've listed.
@guido.gunther Do you want to add a modified version of the rpi script to the image? Or did you want to just add something simpler like just the fdisk steps + resize2fs? Do we want this to be done automatically for the user on like a first boot? Or do we want to just have a script on the image and tell users about it so they can choose to resize or not?
@heather.ellsworth you just need to install cloud-initramfs-growroot , no additional script needed. The only thing we then need to do is to run resize2fs, the hard part of reliable partition resizing can be taken from Debian.
Note that the resize2fs is on /dev/vda2 and not just /dev/vda (as we said in earlier comments).
Also, the I'm not sure if the final reboot is even required since df -h shows that /dev/vda2 is at 31G immediately after the resize2fs.
@guido.gunther How does this sound... We can add the cloud-initramfs-growroot to the list of packages for qemu-x86_64 builds and we could just provide the resize2fs command to users via documentation. Since it's just oneline, we don't really need a script for it and can just tell folks the command to execute.
Progress: with any version past 0.22ubuntu1 , cloud-initramfs-growroot seems to be working. The current Debian version is 0.18, bug report sent. It doesn't seem to trigger reliably, but when it did, I got:
I tried to resize in the initrd, after cloud-initramfs-growroot does its thing. Ideally, growroot acts, then resizefs, and then we mount the rootfs and ride into the sunset.
Unfortunately, growroot is in the local-bottom phase, when the rootfs is mounted read only, presumably in order to check for the presence of a file indicating it's not needed. When trying to resize root, resize2fs will fail, because it's mounted and it's read-only.
I came up with a solution that unmounts and mounts it back again, but initrd's mount balks, making me think that this is too fragile.
Growroot could be moved to an earlier phase when the rootfs is not mounted at all, but I doubt it would be accepted upstream, because it's a large change. Forking another package doesn't sound fun.
Unfortunately, growroot is in the local-bottom phase, when the rootfs is mounted read only, presumably in order to check for the presence of a file indicating it's not needed. When trying to resize root, resize2fs will fail, because it's mounted and it's read-only.
You can do this way after the rootfs has been mounted read write since resize2fs can do that while the filesystem is mounted. A tiny systemd unit invoking resize2fs after the rootfs is mounted is all that's needed.