• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Looking for someone with scripting knowledge...

Joined
Feb 22, 2019
Messages
757 (0.32/day)
Hey guys,

Long story short: I need to format hundreds of drives from 520KB sectors to 512KB sectors. I used to do this by hand and type out the commands every time... but I know it can be done easier.

Can someone here with the knowledge write me a quick script? I am willing to float some $$$ your way if it works as intended! :D

What I used to have to type was this:
This was on every boot as I used a live drive, but will be changing this to a full install on my server when it arrives. I assume this will irradicate the need for this portion but I may be wrong.
►sudo apt-get update
►sudo apt-get upgrade
►sudo apt-get install software-properties-common
►sudo apt-get install sg3-utils

This is the format segment:
►sudo sg_format --format --size=512 /dev/sg* - where * indicates drive number from terminal

Basically, I need it to run on 12 drives simultaneously and with room to expand up to 24. I will most likely install on to a spare drive to make this easier, if possible. :)

Thank you for your assistance. I will be trying to figure something out myself, but I will no doubt get stuck somewhere.
 
This seems trivial? Just write a bash script? Which is just a collection of commands.
 
I have absolutely zero scripting knowledge, but if it is that easy... maybe it's worthy of a (many) attempt(s). :D
 
I have absolutely zero scripting knowledge, but if it is that easy... maybe it's worthy of a (many) attempt(s). :D

You may ask Chris at Chris Titus Tech on Youtube (he may have a website even).
 
what debian based system is this? and what is its version?

How do you display and know the disk numbers?

EDIT:: im bored.

Code:
#!/bin/bash

#clear the screen so we can read stuff
clear

# Echos with nothing are just line seperators
echo
echo Updating repos and doing upgrades...
echo
# You can combine commands and use the -y flag to auto make changes.
sudo apt update && sudo apt -y upgrade
clear
echo
echo Installing prerequisite software...
echo
# Using a space we can list the packages we want installed. Again using -y to confirm automatically.
sudo apt install software-properties-common sg3-utils -y
clear
echo
echo Starting disk configuration. Please type the disk number you would like to reconfigure.
echo
# I might be able to do ranges but im lazy, and we can just loop back.
read -p 'Disk Number: ' disknum

sudo sg_format --format --size=512 /dev/sg$disknum

echo
echo
echo Done I think! super basic script run me again bye!
echo

# Maybe I can add loops and menus and stuff later idk.
# remember do chmod a+x scriptname.sh
# remember if modifying under windows run "sed -i -e 's/\r$//' sg3.sh" to remove weird CRs

exit
 

Attachments

Last edited:
I’ll give this a try when my server arrives and let you know. Thank you so much!!

I am totally clueless with Linux and programming in general, so I really appreciate that. Send me a PM if you’d like a few bucks for your troubles. :)
 
Send me a PM if you’d like a few bucks for your troubles

Not my cup of tea, remember to read the notes in the script, especially if you modify it on windows. Otherwise, curious how it pans out!
 
what debian based system is this? and what is its version?

How do you display and know the disk numbers?

EDIT:: im bored.

Code:
#!/bin/bash

#clear the screen so we can read stuff
clear

# Echos with nothing are just line seperators
echo
echo Updating repos and doing upgrades...
echo
# You can combine commands and use the -y flag to auto make changes.
sudo apt update && sudo apt -y upgrade
clear
echo
echo Installing prerequisite software...
echo
# Using a space we can list the packages we want installed. Again using -y to confirm automatically.
sudo apt install software-properties-common sg3-utils -y
clear
echo
echo Starting disk configuration. Please type the disk number you would like to reconfigure.
echo
# I might be able to do ranges but im lazy, and we can just loop back.
read -p 'Disk Number: ' disknum

sudo sg_format --format --size=512 /dev/sg$disknum

echo
echo
echo Done I think! super basic script run me again bye!
echo

# Maybe I can add loops and menus and stuff later idk.
# remember do chmod a+x scriptname.sh
# remember if modifying under windows run "sed -i -e 's/\r$//' sg3.sh" to remove weird CRs

exit

I'm disappointed you didn't add a line to fire up a bit miner:roll:
 
Back
Top