• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.

Looking for someone with scripting knowledge...

Joined
Feb 22, 2019
Messages
757 (0.40/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.
 

W1zzard

Administrator
Staff member
Joined
May 14, 2004
Messages
27,028 (3.71/day)
Processor Ryzen 7 5700X
Memory 48 GB
Video Card(s) RTX 4080
Storage 2x HDD RAID 1, 3x M.2 NVMe
Display(s) 30" 2560x1600 + 19" 1280x1024
Software Windows 10 64-bit
This seems trivial? Just write a bash script? Which is just a collection of commands.
 
Joined
Feb 22, 2019
Messages
757 (0.40/day)
I have absolutely zero scripting knowledge, but if it is that easy... maybe it's worthy of a (many) attempt(s). :D
 

eidairaman1

The Exiled Airman
Joined
Jul 2, 2007
Messages
40,435 (6.59/day)
Location
Republic of Texas (True Patriot)
System Name PCGOD
Processor AMD FX 8350@ 5.0GHz
Motherboard Asus TUF 990FX Sabertooth R2 2901 Bios
Cooling Scythe Ashura, 2×BitFenix 230mm Spectre Pro LED (Blue,Green), 2x BitFenix 140mm Spectre Pro LED
Memory 16 GB Gskill Ripjaws X 2133 (2400 OC, 10-10-12-20-20, 1T, 1.65V)
Video Card(s) AMD Radeon 290 Sapphire Vapor-X
Storage Samsung 840 Pro 256GB, WD Velociraptor 1TB
Display(s) NEC Multisync LCD 1700V (Display Port Adapter)
Case AeroCool Xpredator Evil Blue Edition
Audio Device(s) Creative Labs Sound Blaster ZxR
Power Supply Seasonic 1250 XM2 Series (XP3)
Mouse Roccat Kone XTD
Keyboard Roccat Ryos MK Pro
Software Windows 7 Pro 64
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).
 

Solaris17

Super Dainty Moderator
Staff member
Joined
Aug 16, 2005
Messages
25,838 (3.79/day)
Location
Alabama
System Name Rocinante
Processor I9 14900KS
Motherboard EVGA z690 Dark KINGPIN (modded BIOS)
Cooling EK-AIO Elite 360 D-RGB
Memory 64GB Gskill Trident Z5 DDR5 6000 @6400
Video Card(s) MSI SUPRIM Liquid X 4090
Storage 1x 500GB 980 Pro | 1x 1TB 980 Pro | 1x 8TB Corsair MP400
Display(s) Odyssey OLED G9 G95SC
Case Lian Li o11 Evo Dynamic White
Audio Device(s) Moondrop S8's on Schiit Hel 2e
Power Supply Bequiet! Power Pro 12 1500w
Mouse Lamzu Atlantis mini (White)
Keyboard Monsgeek M3 Lavender, Akko Crystal Blues
VR HMD Quest 3
Software Windows 11
Benchmark Scores I dont have time for that.
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

  • sg3.zip
    709 bytes · Views: 261
Last edited:
Joined
Feb 22, 2019
Messages
757 (0.40/day)
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

Super Dainty Moderator
Staff member
Joined
Aug 16, 2005
Messages
25,838 (3.79/day)
Location
Alabama
System Name Rocinante
Processor I9 14900KS
Motherboard EVGA z690 Dark KINGPIN (modded BIOS)
Cooling EK-AIO Elite 360 D-RGB
Memory 64GB Gskill Trident Z5 DDR5 6000 @6400
Video Card(s) MSI SUPRIM Liquid X 4090
Storage 1x 500GB 980 Pro | 1x 1TB 980 Pro | 1x 8TB Corsair MP400
Display(s) Odyssey OLED G9 G95SC
Case Lian Li o11 Evo Dynamic White
Audio Device(s) Moondrop S8's on Schiit Hel 2e
Power Supply Bequiet! Power Pro 12 1500w
Mouse Lamzu Atlantis mini (White)
Keyboard Monsgeek M3 Lavender, Akko Crystal Blues
VR HMD Quest 3
Software Windows 11
Benchmark Scores I dont have time for that.
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

Linux Advocate
Staff member
Joined
Nov 13, 2006
Messages
15,441 (2.43/day)
Location
Mid-Atlantic
System Name Desktop
Processor i5 13600KF
Motherboard AsRock B760M Steel Legend Wifi
Cooling Noctua NH-U9S
Memory 4x 16 Gb Gskill S5 DDR5 @6000
Video Card(s) Gigabyte Gaming OC 6750 XT 12GB
Storage WD_BLACK 4TB SN850x
Display(s) Gigabye M32U
Case Corsair Carbide 400C
Audio Device(s) On Board
Power Supply EVGA Supernova 650 P2
Mouse MX Master 3s
Keyboard Logitech G915 Wireless Clicky
Software The Matrix
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:
 

Solaris17

Super Dainty Moderator
Staff member
Joined
Aug 16, 2005
Messages
25,838 (3.79/day)
Location
Alabama
System Name Rocinante
Processor I9 14900KS
Motherboard EVGA z690 Dark KINGPIN (modded BIOS)
Cooling EK-AIO Elite 360 D-RGB
Memory 64GB Gskill Trident Z5 DDR5 6000 @6400
Video Card(s) MSI SUPRIM Liquid X 4090
Storage 1x 500GB 980 Pro | 1x 1TB 980 Pro | 1x 8TB Corsair MP400
Display(s) Odyssey OLED G9 G95SC
Case Lian Li o11 Evo Dynamic White
Audio Device(s) Moondrop S8's on Schiit Hel 2e
Power Supply Bequiet! Power Pro 12 1500w
Mouse Lamzu Atlantis mini (White)
Keyboard Monsgeek M3 Lavender, Akko Crystal Blues
VR HMD Quest 3
Software Windows 11
Benchmark Scores I dont have time for that.
Top