Created
December 30, 2022 05:24
-
-
Save jbobbylopez/fe5e07566c6799cb9add4338cc4e823c to your computer and use it in GitHub Desktop.
Quickly query disk formatting progress from the command line (linux/bash)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Based on "How to know when formatting disk has finsihed - Ubuntu 16.04?" AskUbuntu post: | |
# https://askubuntu.com/questions/962866/how-to-know-when-formatting-disk-has-finsihed-ubuntu-16-04 | |
device=sdb | |
device_path=/dev/$device | |
disk_sectors=`sudo fdisk -l $device_path | grep [D]isk | awk '{print $7}'` | |
disk_progress=`sudo cat /sys/block/$device/stat | awk '{print $7}'` | |
progress_percent=`echo "scale=4; ($disk_progress/$disk_sectors)*100"| bc` | |
echo -e "% ${progress_percent} formatting progress for $device_path." | |
# The above is just my quick and dirty to serve my own needs (tested under Ubuntu 22.04). | |
# A better script can be found here: | |
# https://askubuntu.com/a/1209474 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment