canonical / cloud-init

Official upstream for the cloud-init: cloud instance initialization
https://cloud-init.io/
Other
3.01k stars 887 forks source link

cloud-init disk_setup fails to partition disk for Ubuntu18 #3490

Closed ubuntu-server-builder closed 1 year ago

ubuntu-server-builder commented 1 year ago

This bug was originally filed in Launchpad as LP: #1851438

Launchpad details
affected_projects = ['util-linux (Ubuntu)', 'util-linux (Ubuntu Xenial)', 'util-linux (Ubuntu Bionic)', 'util-linux (Ubuntu Eoan)', 'util-linux (Ubuntu Focal)']
assignee = None
assignee_name = None
date_closed = 2023-02-22T16:52:15.582654+00:00
date_created = 2019-11-05T21:58:53.627476+00:00
date_fix_committed = 2023-01-05T16:55:12.572257+00:00
date_fix_released = 2023-02-22T16:52:15.582654+00:00
id = 1851438
importance = medium
is_complete = True
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1851438
milestone = None
owner = csaikia
owner_name = Chaynika Saikia
private = False
status = fix_released
submitter = csaikia
submitter_name = Chaynika Saikia
tags = ['cloud-init']
duplicates = []

Launchpad user Chaynika Saikia(csaikia) wrote on 2019-11-05T21:58:53.627476+00:00

Pasting disk_setup for cloud-config:

disk_setup: /dev/xvde: layout: True overwrite: False type: mbr fs_setup: -device: /dev/xvde filesystem: ext4 label: data overwrite: false partition: auto

I want to attach and mount a /data disk on the VM using cloud-init so I just want to single partition 100% of the disk.

Error while running the sfdisk command for partitioning the disk (please see attached file). OS: Ubuntu18

How I repro-ed it outside cloud-init environment:

  1. Open XenCenter, add a new disk, say /dev/xvdc
  2. Run /sbin/sfdisk --Linux --unit=S --force /dev/xvdc and specify start sector as 0. Because from the cloud-init logs and source code, I figured that it was picking start sector as 0. Save it and see the error.
ubuntu-server-builder commented 1 year ago

Launchpad user Chaynika Saikia(csaikia) wrote on 2019-11-05T21:58:53.627476+00:00

Launchpad attachments: cloud-init-disk-setup-err.PNG

ubuntu-server-builder commented 1 year ago

Launchpad user Chaynika Saikia(csaikia) wrote on 2019-11-05T22:02:51.264274+00:00

Launchpad attachments: cloud-init-disk-setup-err-2.PNG

ubuntu-server-builder commented 1 year ago

Launchpad user Chaynika Saikia(csaikia) wrote on 2019-11-05T22:27:21.251491+00:00

util-linux package version output from dpkg -l : Version: 2.31.1-0.4ubuntu3.3 Arch: amd64 Name: util-linux

ubuntu-server-builder commented 1 year ago

Launchpad user Ryan Harper(raharper) wrote on 2019-11-05T22:45:19.465971+00:00

https://marc.info/?l=util-linux-ng&m=142920033601419&w=2

Seems to say this is by-design.

util-linux/fdisk versions in Xenial and newer all have this issue.

The workaround for user-data is to specify:

disk_setup:

: layout: [100] Which will create a single partition spanning the whole disk. And cloud-init will need to emit ",," as input to sfdisk moving forward.
ubuntu-server-builder commented 1 year ago

Launchpad user Ryan Harper(raharper) wrote on 2019-11-05T22:50:43.369078+00:00

This should include an integration test in cloud_tests since it involves #cloud-config

ubuntu-server-builder commented 1 year ago

Launchpad user Ryan Harper(raharper) wrote on 2019-11-05T22:58:16.050640+00:00

On trusty; this complains but works.

ubuntu@ubuntu:~$ dpkg --list | grep util-linux ii util-linux 2.20.1-5.1ubuntu20.9 amd64 Miscellaneous system utilities ubuntu@ubuntu:~$ cat /proc/partitions major minor #blocks name

253 0 10485760 vda 253 1 10484736 vda1 253 16 10485760 vdb 253 32 366 vdc 11 0 1048575 sr0 ubuntu@ubuntu:~$ sudo bash sudo: unable to resolve host ubuntu root@ubuntu:~# echo "0," | sfdisk --Linux --unit=S --force /dev/vdb Checking that no-one is using this disk right now ... OK

Disk /dev/vdb: 20805 cylinders, 16 heads, 63 sectors/track

sfdisk: ERROR: sector 0 does not have an msdos signature /dev/vdb: unrecognized partition table type Old situation: No partitions found Warning: bad partition start (earliest 1) New situation: Units = sectors of 512 bytes, counting from 0

Device Boot Start End #sectors Id System /dev/vdb1 1 20971519 20971519 83 Linux /dev/vdb2 0 - 0 0 Empty /dev/vdb3 0 - 0 0 Empty /dev/vdb4 0 - 0 0 Empty Warning: no primary partition is marked bootable (active) This does not matter for LILO, but the DOS MBR will not boot this disk. Successfully wrote the new partition table

Re-reading the partition table ...

If you created or changed a DOS partition, /dev/foo7, say, then use dd(1) to zero the first 512 bytes: dd if=/dev/zero of=/dev/foo7 bs=512 count=1 (See fdisk(8).) root@ubuntu:~# cat /proc/partitions major minor #blocks name

253 0 10485760 vda 253 1 10484736 vda1 253 16 10485760 vdb 253 17 10485759 vdb1 253 32 366 vdc 11 0 1048575 sr0

ubuntu-server-builder commented 1 year ago

Launchpad user Alberto Contreras(aciba) wrote on 2023-01-05T16:55:05.208356+00:00

Fixed in https://github.com/canonical/cloud-init/pull/1932

ubuntu-server-builder commented 1 year ago

Launchpad user Alberto Contreras(aciba) wrote on 2023-02-22T16:52:16.969115+00:00

This bug is believed to be fixed in cloud-init in version 23.1. If this is still a problem for you, please make a comment and set the state back to New

Thank you.