get_unused_blockdev_info can return used blockdevices

Bug #1489521 reported by Scott Moser
24
This bug affects 4 people
Affects Status Importance Assigned to Milestone
curtin
Confirmed
Medium
Unassigned

Bug Description

get_unused_blockdev_info works by using lsblk and looking at MOUNTPOINT.

That does not always work right on trusty.
example:
$ sudo mount /dev/vdb1 /mnt
$ sudo PYTHONPATH=$PWD python -c 'from curtin import block; print(block.get_unused_blockdev_info())'
{'vdb': {'GROUP': 'disk', 'OPT-IO': '0', 'DISC-MAX': '0', 'LABEL': '', 'MODEL': '', 'RQ-SIZE': '128', 'MODE': 'brw-rw----', 'ROTA': '1', 'RM': '0', 'RO': '0', 'device_path': '/dev/vdb', 'DISC-ZERO': '0', 'UUID': '', 'STATE': '', 'MOUNTPOINT': '', 'FSTYPE': '', 'SIZE': '42949672960', 'MAJ:MIN': '253:16', 'DISC-GRAN': '0', 'NAME': 'vdb', 'LOG-SEC': '512', 'DISC-ALN': '0', 'ALIGNMENT': '0', 'MIN-IO': '512', 'OWNER': 'root', 'KNAME': 'vdb', 'TYPE': 'disk', 'PHY-SEC': '512'}}

$ cat /proc/mounts
rootfs / rootfs rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
udev /dev devtmpfs rw,relatime,size=1020072k,nr_inodes=255018,mode=755 0 0
devpts /dev/pts devpts rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=205008k,mode=755 0 0
/dev/disk/by-label/cloudimg-rootfs / ext4 rw,relatime,data=ordered 0 0
none /sys/fs/cgroup tmpfs rw,relatime,size=4k,mode=755 0 0
none /sys/fs/fuse/connections fusectl rw,relatime 0 0
none /sys/kernel/debug debugfs rw,relatime 0 0
none /sys/kernel/security securityfs rw,relatime 0 0
none /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
none /run/shm tmpfs rw,nosuid,nodev,relatime 0 0
none /run/user tmpfs rw,nosuid,nodev,noexec,relatime,size=102400k,mode=755 0 0
none /sys/fs/pstore pstore rw,relatime 0 0
systemd /sys/fs/cgroup/systemd cgroup rw,nosuid,nodev,noexec,relatime,name=systemd 0 0
/dev/vdb1 /mnt ext4 rw,relatime,data=ordered 0 0

Revision history for this message
Scott Moser (smoser) wrote :

Note, this works correctly on wily, lsblk does thh right thing.

Revision history for this message
Ryan Harper (raharper) wrote :

What does lsblk -o MOUNTPOINT /dev/vdb1 show?

Revision history for this message
Zhanglei Mao (zhanglei-mao) wrote :

I get this issues too on 20.04 ( maas is 2.8.2). The failed deploy log for this node are below:

Running command ['sgdisk', '--new', '5:516689152:976752895', '--typecode=5:8300', '/dev/nvme2n1'] with allowed return codes [0] (capture=True)

Running command ['udevadm', 'info', '--query=property', '--export', '/dev/nvme2n1'] with allowed return codes [0] (capture=True)/dev/nvme2n1 is multipath device? False

Running command ['blockdev', '--rereadpt', '/dev/nvme2n1'] with allowed return codes [0] (capture=True)

Error rescanning devices, possibly known issue LP: #1489521

cmd: ['blockdev', '--rereadpt', '/dev/nvme2n1']

stdout:''

stderr:blockdev: ioctl error on BLKRRPART: Device or resource busy

exit_code:1

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

I doubt that recent failure is the same thing, this looks like a race with, well, something else. Possibly the blockdev --rereadpt call should be protected with flock.

Revision history for this message
Nish Aravamudan (nacc) wrote :

There are some recent reports in other distributions too: https://github.com/coreos/bugs/issues/152

Revision history for this message
Michael Hicks (nooneofconsequence) wrote :
Download full text (51.9 KiB)

I came across this PXE booting the Subuiquity auto-installer with the following cloud-init supplied curtin config:

```
  storage:
    config:

    # https://www.molnar-peter.hu/en/ubuntu-jammy-netinstall-pxe.html
    # https://www.rodsbooks.com/efi-bootloaders/index.html
    # GPT Partition table of two disks
    - ptable: gpt
      path: /dev/sda
      wipe: superblock-recursive
      preserve: false
      name: ''
      grub_device: false
      type: disk
      id: disk-sda

    - ptable: gpt
      path: /dev/sdb
      wipe: superblock-recursive
      preserve: false
      name: ''
      grub_device: false
      type: disk
      id: disk-sdb

    # make EFI partition and flag for GRUB on first disk
    ## partition
    - device: disk-sda
      size: 512M
      wipe: superblock-recursive
      flag: boot
      number: 1
      preserve: false
      grub_device: true
      type: partition
      id: sda-partition-1
    ## fat32 fs
    - fstype: fat32
      volume: sda-partition-1
      preserve: false
      type: format
      id: format-sda-p-1
    ## specify mountpoint
    - path: /boot/efi
      device: format-sda-p-1
      type: mount
      id: mount-sda-efi
    # make EFI partition and flag for GRUB on second disk
    ## partition
    - device: disk-sdb
      size: 512M
      wipe: superblock-recursive
      flag: boot
      number: 1
      preserve: false
      grub_device: true
      type: partition
      id: sdb-partition-1
    ## fat32 fs
    - fstype: fat32
      volume: sdb-partition-1
      preserve: false
      type: format
      id: format-sdb-p-1
    ## specify mountpoint
    - path: /boot/efi2
      device: format-sdb-p-1
      type: mount
      id: mount-sdb-efi

    # see https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/storage_administration_guide/ch-swapspace
    # swap partitions
    - device: disk-sda
      size: 10G
      wipe: superblock-recursive
      flag: raid
      number: 2
      preserve: false
      type: partition
      id: partition-swapa

    - device: disk-sdb
      size: 10G
      wipe: superblock-recursive
      flag: raid
      number: 2
      preserve: false
      type: partition
      id: partition-swapb

    # subiquity extension to curtin lets you specify a % for partitions
    # and for last partition -1 as size meaning all the rest
    # https://github.com/canonical/subiquity/blob/main/documentation/autoinstall-reference.md#partitionlogical-volume-extensions
    # MD root partition

    - device: disk-sda
      size: -1
      wipe: superblock-recursive
      flag: raid
      number: 3
      preserve: false
      type: partition
      id: partition-roota

    - device: disk-sdb
      size: -1
      wipe: superblock-recursive
      flag: raid
      number: 3
      preserve: false
      type: partition
      id: partition-rootb

    # raid devs on those partitions for swap and root
    - id: swap_raid
      type: raid
      name: md0
      raidlevel: 1
      devices:
        - partition-swapa
        - partition-swapb

    - id: root_raid
      type: raid
      name: md1
      raidlevel: 1
      devices:
        - partition-roota
        - partition-rootb

    # filesys...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.