Skip to content

blockdev.formatted fails on entire drive3 #42397

@mbiokyle29

Description

@mbiokyle29

Description of Issue/Question

I am working in a master-less configuration, attempting to provision a Virtual Box CentOS VM using salt. I am attempting to use salt.states.blockdev.formatted to create an ext4 file system directly on a device (not on a device partition). The salt state fails to execute due to a prompt that mkfs produces when attempting to format an entire drive.

Here is my salt state:

/dev/sdc:
   blockdev.formatted

Here are the relevant debug logs:
Note: as far as I can tell blkid only works on partitions, hence the bad return code. As far as I can tell the salt state continues execution and run the mkfs command via cmd.retcode which blocks util the command returns, which will never happen.

[INFO    ] Running state [/dev/sdc] at time 11:56:22.386837
[INFO    ] Executing state blockdev.formatted for [/dev/sdc]
[INFO    ] Executing command 'blkid -o value -s TYPE /dev/sdc' in directory '/root'
[ERROR   ] Command 'blkid -o value -s TYPE /dev/sdc' failed with return code: 2
[ERROR   ] output:
[INFO    ] Executing command ['mkfs', '-t', 'ext4', '/dev/sdc'] in directory '/root'
# this hangs

Strace shows the mkfs waiting for input:

strace -p `pgrep mkfs`
Process 3965 attached
read(0,

If I run the command directly:

mkfs -t ext4 /dev/sdc
mke2fs 1.41.12 (17-May-2010)
/dev/sdc is entire device, not just one partition!
Proceed anyway? (y,n)

Finally, I think the solution is to not format unpartitioned drives and instead make partitions. But good to have in-place in case someone really wants to do this.

Versions Report

Salt Version:
           Salt: 2017.7.0

Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: Not Installed
      docker-py: Not Installed
          gitdb: Not Installed
      gitpython: Not Installed
          ioflo: Not Installed
         Jinja2: 2.8.1
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: Not Installed
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: Not Installed
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.13 (default, Jul 12 2017, 17:32:34)
   python-gnupg: Not Installed
         PyYAML: 3.11
          PyZMQ: 14.5.0
           RAET: Not Installed
          smmap: Not Installed
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5

System Versions:
           dist: centos 6.7 Final
         locale: UTF-8
        machine: x86_64
        release: 2.6.32-696.6.3.el6.x86_64
         system: Linux
        version: CentOS 6.7 Final

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugbroken, incorrect, or confusing behaviorseverity-medium3rd level, incorrect or bad functionality, confusing and lacks a work around

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions