-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
blockdev.formatted fails on entire drive3 #42397
Comments
This is definitely a situation we should account for, there are several use cases for when you would want to format the entire drive and not use a partition. Initially I thought there could be a |
Here is the workaround I currently have: format_dev_sdb:
cmd.run:
- stateful: True
- name: |
ext4_lines=$(file -sL /dev/sdb | grep ext4 | wc -l)
if [ $ext4_lines -eq 0 ]; then
yes | mkfs.ext4 /dev/sdb
echo
echo "changed=yes comment='drive /dev/sdb was formatted'"
else
echo
echo "changed=no comment='drive /dev/sdb was already ext4'"
fi [root@dev ~]# file -sL /dev/sdb
/dev/sdb: data
[root@dev ~]# mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@dev ~]# file -sL /dev/sdb
/dev/sdb: Linux rev 1.0 ext4 filesystem data (extents) (large files) (huge files) The |
@garethgreenaway, mkfs.xfs doesn't care. However, it actually has a -force option to allow overwriting an already existing filesystem on the device. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
This is still a bug. Please reopen. |
Thank you for updating this issue. It is no longer marked as stale. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue. |
This is still a bug. Reopening... |
Thank you for updating this issue. It is no longer marked as stale. |
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 anext4
file system directly on a device (not on a device partition). The salt state fails to execute due to a prompt thatmkfs
produces when attempting to format an entire drive.Here is my salt state:
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 themkfs
command viacmd.retcode
which blocks util the command returns, which will never happen.Strace shows the mkfs waiting for input:
If I run the command directly:
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
The text was updated successfully, but these errors were encountered: