# Looking for someone with scripting knowledge...



## TheMadDutchDude (Dec 27, 2019)

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! 

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.


----------



## W1zzard (Dec 27, 2019)

This seems trivial? Just write a bash script? Which is just a collection of commands.


----------



## TheMadDutchDude (Dec 27, 2019)

I have absolutely zero scripting knowledge, but if it is that easy... maybe it's worthy of a (many) attempt(s).


----------



## eidairaman1 (Dec 28, 2019)

TheMadDutchDude said:


> I have absolutely zero scripting knowledge, but if it is that easy... maybe it's worthy of a (many) attempt(s).



You may ask Chris at Chris Titus Tech on Youtube (he may have a website even).


----------



## Solaris17 (Dec 28, 2019)

what debian based system is this? and what is its version?

How do you display and know the disk numbers?

EDIT:: im bored.



Spoiler





```
#!/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
```


----------



## TheMadDutchDude (Dec 28, 2019)

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.


----------



## Solaris17 (Dec 28, 2019)

TheMadDutchDude said:


> 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!


----------



## Easy Rhino (Jan 3, 2020)

Solaris17 said:


> what debian based system is this? and what is its version?
> 
> How do you display and know the disk numbers?
> 
> ...



I'm disappointed you didn't add a line to fire up a bit miner


----------



## Solaris17 (Jan 3, 2020)

Easy Rhino said:


> I'm disappointed you didn't add a line to fire up a bit miner


I’ll strive to do better in the next iteration


----------

