canonical / canonical/cloud-init

Failed mount of '/dev/sdb1' with Swap File cloud-init config

Open
#3,201 4 comments 0 reactions 0 assignees View on GitHub
bug launchpad
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

This bug was originally filed in Launchpad as [LP: #1779207](https://bugs.launchpad.net/cloud-init/+bug/1779207)

Launchpad details

affected_projects = []

assignee = None
assignee_name = None
date_closed = None
date_created = 2018-06-28T20:36:03.214964+00:00
date_fix_committed = None
date_fix_released = None
id = 1779207
importance = medium
is_complete = False
lp_url = https://bugs.launchpad.net/cloud-init/+bug/1779207
milestone = None
owner = danis
owner_name = Daniel Sol
private = False
status = triaged
submitter = danis
submitter_name = Daniel Sol
tags = []
duplicates = []

_Launchpad user **Daniel Sol(danis)** wrote on 2018-06-28T20:36:03.214964+00:00_

Environment : RHEL 7.5 on Azure, using cloud-init 18.2 rebase with these patches: https://git.launchpad.net/cloud-init/commit/?id=aa4eeb80

Scenario:
I provision an image with the above on Azure, in addition, i apply this cloud-init config:
#cloud-config
disk_setup:
    ephemeral0:
        table_type: gpt
        layout: [66, [33, 82]]
        overwrite: True
fs_setup:
    - device: ephemeral0.1
      filesystem: ext4
    - device: ephemeral0.2
      filesystem: swap
mounts:
    - ["ephemeral0.1", "/mnt"]
    - ["ephemeral0.2", "none", "swap", "sw", "0", "0"]

The VM provisions successfully, you see /sdb1 gets mounted and the swap file config succeeds.

If i deallocate the VM and start it, /sdb1 does not get mounted, you see the errors below.

2018-06-20 19:50:38,138 - util.py[WARNING]: Failed reading the partition table Unexpected error while running command.
Command: ['/usr/sbin/blockdev', '--rereadpt', '/dev/sdb']
Exit code: 1
Reason: -
Stdout:
Stderr: blockdev: ioctl error on BLKRRPART: Device or resource busy
2018-06-20 19:50:38,138 - util.py[DEBUG]: Failed reading the partition table Unexpected error while running command.
Command: ['/usr/sbin/blockdev', '--rereadpt', '/dev/sdb']
Exit code: 1
Reason: -
Stdout:
Stderr: blockdev: ioctl error on BLKRRPART: Device or resource busy
Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/cloudinit/config/cc_disk_setup.py", line 685, in read_parttbl
    util.subp(blkdev_cmd)
  File "/usr/lib/python2.7/site-packages/cloudinit/util.py", line 1958, in subp
    cmd=args)
ProcessExecutionError: Unexpected error while running command.

Running multiple deallocates and starts does not see the system resolve itself.

I check fstab:
UUID=6e4681f0-1ec3-4c27-9c16-afb90a4c4513 / xfs defaults 0 0
UUID=f2116236-4be6-4b72-b107-c2d7a68688c4 /boot xfs defaults 0 0
/dev/disk/cloud/azure_resource-part1 /mnt auto defaults,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig 0 2
/dev/disk/cloud/azure_resource-part2 none swap sw,comment=cloudconfig 0 0

As a test, i changed the FSTAB entry for the swap to add a dependency on cloud-init:
/dev/disk/cloud/azure_resource-part2 none swap sw,nofail,x-systemd.requires=cloud-init.service,comment=cloudconfig 0 0

I deallocated and started the VM, sdb mounts correctly, but the FSTAB is overwritten for swap with the previous config. I modified the FSTAB again, with the addition, then rebooted, again, everything works.

Does azure_resource-part2 need a dependency like azure_resource-part1?

You can also test this using the existing Azure cloud-init preview images (cloud-init 0.7.9.x)
az vm create
--resource-group rgName
--name vmName
--image RedHat:RHEL:7-RAW-CI:latest
--admin-username anotherusr
--custom-data /../swapconfig.txt
--ssh-key-value /.../my.pub

az vm deallocate --resource-group rgName --name vmName
az vm start --resource-group rgName --name vmName

Thanks,

Related bugs:
* bug 1785354: /etc/fstab: fs_passno is 0 for all file systems

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.