MBR disk setup fails because sfdisk no longer accepts M as a valid unit
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Ubuntu Image |
Invalid
|
Undecided
|
Unassigned | ||
cloud-init |
Fix Released
|
Medium
|
Dan Watkins | ||
cloud-init (Ubuntu) |
Fix Released
|
Medium
|
Unassigned | ||
Xenial |
Fix Released
|
Medium
|
Scott Moser | ||
Yakkety |
Fix Released
|
Medium
|
Unassigned |
Bug Description
=== Begin SRU Template ===
[Impact]
Cloud-init has function to partition disks on devices.
Creating partitions on a disk no longer works with sfdisk as recent versions of
sfdisk no accept the unit 'M' as input, this function is broken.
[Test Case]
1. Launch an instance with provided user-data
On Azure, this will work:
#cloud-config
disk_setup:
ephemeral0:
layout: [66, [33, 82]]
fs_setup:
- device: ephemeral0.1
- device: ephemeral0.2
mounts:
- ["ephemeral0.1", "/mnt2"]
- ["ephemeral0.2", "none", "swap", "sw", "0", "0"]
On a typical kvm openstack use:
#cloud-config
disk_setup:
/dev/vdb:
layout: [66, [33, 82]]
fs_setup:
- device: /dev/vdb1
- device: /dev/vdb2
mounts:
- ["/dev/vdb1", "/mnt2"]
- ["/dev/vdb2", "none", "swap", "sw", "0", "0"]
2. Add proposed, update, and reboot as fresh instance.
# enable proposed
echo deb http://
sudo apt-get -qy update && sudo apt-get -qy install cloud-init </dev/null
# clear out previous state in cloud-init
sudo rm -Rf /var/lib/cloud /var/log/
# wipe the partition table and filesystem from the disk
sudo dd if=/dev/zero of=/dev/[sv]db bs=1M count=10
# remove cloud-init written entries in /etc/fstab to mimic clean first boot
sudo sed -i '/cloudconfig/d' /etc/fstab
sudo reboot
3. login to system and look around.
The target disk should be partitioned with 2 partitions.
$ grep [sv]db /proc/partitions
253 16 41943040 vdb
253 17 27682406 vdb1
253 18 14259200 vdb2
There should entries in /etc/fstab for the configured devices
$ cat /etc/fstab
LABEL=
LABEL=UEFI /boot/efi vfat defaults 0 0
/dev/vdb1 /mnt2 auto defaults,
/dev/vdb2 none swap sw,comment=
A 'mount -a' will mount the necessary devices.
Note, these should ideally be already mounted, but an as-yet unidentified
issue (to be fixed in bug 1642383) means they are not mounted on first
boot.
$ mount -a
$ df -h /mnt2
Filesystem Size Used Avail Use% Mounted on
/dev/vdb1 26G 45M 25G 1% /mnt2
There should be swap used.
$ free
total used free shared buff/cache available
Mem: 2047792 73984 1804508 3252 169300 1825896
Swap: 14259196 0 14259196
$ grep [vs]db2 /proc/swaps
/dev/vdb2 partition 14259196 0 -1
[Regression Potential]
Change from using Megabytes to Sectors could have caused math errors,
most likely with sector sizes other than 512.
Partitioning with sfdisk was broken previously, so it wont be worse.
=== End SRU Template ===
Specifically, we get the following output in cc_disk_
sfdisk: --Linux option is unnecessary and deprecated
sfdisk: unsupported unit 'M'
and the manpage says:
-u, --unit S
So we'll need to shift to using sectors.
Related bugs:
* bug 1642383: Unable to configure swap space on ephemeral disk in Azure
Related branches
- Server Team CI bot: Needs Fixing (continuous-integration)
- cloud-init Commiters: Pending requested
-
Diff: 135 lines (+76/-8)2 files modifiedcloudinit/config/cc_disk_setup.py (+8/-8)
tests/unittests/test_handler/test_handler_disk_setup.py (+68/-0)
Changed in cloud-init: | |
assignee: | nobody → Dan Watkins (daniel-thewatkins) |
Changed in cloud-init: | |
status: | New → In Progress |
Changed in cloud-init: | |
importance: | Undecided → Medium |
description: | updated |
Changed in cloud-init: | |
status: | In Progress → Fix Committed |
Changed in cloud-init (Ubuntu): | |
status: | New → Fix Released |
importance: | Undecided → Medium |
Changed in cloud-init (Ubuntu Xenial): | |
status: | New → Confirmed |
Changed in cloud-init (Ubuntu Yakkety): | |
status: | New → Confirmed |
Changed in cloud-init (Ubuntu Xenial): | |
importance: | Undecided → Medium |
Changed in cloud-init (Ubuntu Yakkety): | |
importance: | Undecided → Medium |
Changed in cloud-init (Ubuntu Xenial): | |
status: | Confirmed → In Progress |
assignee: | nobody → Scott Moser (smoser) |
description: | updated |
Changed in cloud-init (Ubuntu Yakkety): | |
status: | Confirmed → In Progress |
I'll look at this in our next iteration (i.e. the second half of June).