Thumbos - Load disk images to your thumbdrive

Source code I have written openly published for your viewing pleasure.


Re: Thumbos - Load disk images to your thumbdrive

Postby BBOSAK2143 » Mon Jan 20, 2014 10:32 am

Thanks Xan is great to get an answer! Do you know the lines needed to access, if do would greatly appreciate you let me know as so far nothing I have typed in works it! This is why I was starting to think could be OS specific. Either that or I am well known to just type in a word or two wrong!!! Any way really appreciate getting an answer as those other two just always give me hassles! Of course only one I can get to function at all is Unetbootin. The other will go through the motions and nothing but garbage ever comes out of it!
Firm believer in Asus, Linux and Technology
"Art is to be enjoyed by all that enjoy it"
Asus M5A97 Plus motherboard
AMD FX 4350 Processor
Asus R7250 2GD5 graphics card
16gig DDR3-1333
2TB Hitachi Hard Drive
24in Asus VE248 LED Monitor
OS=My 8th OS Star Trek(Ubuntu 16.04)
Desktops=Gnome 3.20 and LXDE
Warp Speed!
ASUS Laptop R503U
AMD E2-1800
ATI HD7340
4gig Memory
500gig Hitachi HD
OS= Win7 SP1/8th OS Star Trek(Ubuntu 16.04)
Desktops Gnome 3.20 and LXDE
2nd 500gig Seagate HD R.I.P
User avatar
BBOSAK2143
U.E. God
U.E. God
 
Posts: 923
Joined: Tue Jul 03, 2012 7:56 pm
Location: Mount Pleasant, Tennessee
Age: 55
Operating System: Ultimate Edition 3.5 64 BIT



Re: Thumbos - Load disk images to your thumbdrive

Postby Celtic Ferret » Tue Jan 21, 2014 5:48 am

Actually ended up being PCLinuxOS KDE32 Full Version 2013.12, as neither Ultimate Edition v3.5.2 x32 nor Linux Mint 13 "Maya" (LTS) KDE x32 would install. :( The installer would start and run a few seconds and then give an overflow error: some python lines were too long.
--CF
Celtic Ferret
U.E. Newbie
U.E. Newbie
 
Posts: 3
Joined: Sun Jul 21, 2013 3:43 pm
Operating System: Ultimate Edition 3.5 64 BIT



Re: Thumbos - Load disk images to your thumbdrive

Postby BBOSAK2143 » Tue Jan 21, 2014 10:09 am

Hmm. See I built my OS, installed ThumbOS but it does not show anywhere and have no idea how to engage it by command line. So would absolutely love to know how to get it to engage cause I had no problem installing. When I type anything in on command line nothing happens. Still looking for an answer on it! I get that a lot these days that no one seems to want to answer me! Just my good luck I suppose!!!
Firm believer in Asus, Linux and Technology
"Art is to be enjoyed by all that enjoy it"
Asus M5A97 Plus motherboard
AMD FX 4350 Processor
Asus R7250 2GD5 graphics card
16gig DDR3-1333
2TB Hitachi Hard Drive
24in Asus VE248 LED Monitor
OS=My 8th OS Star Trek(Ubuntu 16.04)
Desktops=Gnome 3.20 and LXDE
Warp Speed!
ASUS Laptop R503U
AMD E2-1800
ATI HD7340
4gig Memory
500gig Hitachi HD
OS= Win7 SP1/8th OS Star Trek(Ubuntu 16.04)
Desktops Gnome 3.20 and LXDE
2nd 500gig Seagate HD R.I.P
User avatar
BBOSAK2143
U.E. God
U.E. God
 
Posts: 923
Joined: Tue Jul 03, 2012 7:56 pm
Location: Mount Pleasant, Tennessee
Age: 55
Operating System: Ultimate Edition 3.5 64 BIT



Re: Thumbos - Load disk images to your thumbdrive

Postby TheeMahn » Thu Jan 23, 2014 1:10 am

BBOSAK2143 wrote:Hmm. See I built my OS, installed ThumbOS but it does not show anywhere and have no idea how to engage it by command line. So would absolutely love to know how to get it to engage cause I had no problem installing. When I type anything in on command line nothing happens. Still looking for an answer on it! I get that a lot these days that no one seems to want to answer me! Just my good luck I suppose!!!


open a terminal and type:
Code: Select all
thumbos --help


it does not matter what directory you are in. The binary is in /bin which is in your path. ThumbOS supports bash auto-completion. Which means if you type thumbos -- and hit the tab twice the following will happen:

theemahn@JackHammer:~/Music$ thumbos --
--erase --help --load --scan --test --version
theemahn@JackHammer:~/Music$ thumbos --


I suggest you start with the scan switch:
theemahn@JackHammer:~/Music$ thumbos --scan
Number of switches passed: 1
Switch 1: --scan
Thumbos 1.0.4, 01/14/2014
GNU Thumbos home page: <http://ultimateedition.info/>.
E-mail bug reports to: <theemahn@ultimateedition.info>.
Be sure to include the word Thumbos somewhere in the Subject: field.
Number of USB drives detected: 6
# DEV VENDOR LABEL TYPE SIZE
================================================================================
1 sdi Generic UNKNOWN UNKNOWN 0 GB
2 sdj MUSHKIN Ultimate Edition Lite 3.4.2 LTS iso9660 31.62 GB
3 sdl PatriotMemory Ultimate Edition 4.0 iso9660 4.00 GB
4 sdm SanDisk Ultimate Edition 4.0 iso9660 4.00 GB
5 sdk SanDisk ThumbOS ntfs 4.02 GB
6 sdn USBMSDC UNKNOWN dos 3.90 GB
================================================================================
theemahn@JackHammer:~/Music$

In the above case sdi is a card reader, which I do indeed want to be shown only if there is a card in it. So I personally concider this an error. Perhaps a grep on size = 0 do not show device. More work everytime I look at this program ;)
Home of Ultimate Edition. Got a question? Please review the F.A.Q. Browse the How to section.

Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: 4K Samsung 28", HannsG HH281, Various others
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers

Servers in the basement.
User avatar
TheeMahn
Site Admin
 
Posts: 4199
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 47
Operating System: Ultimate Edition Developer



Re: Thumbos - Load disk images to your thumbdrive

Postby BBOSAK2143 » Thu Jan 23, 2014 6:04 pm

Thanks!!! I must have been typing upper case cause this time came up right away! Probably get a chance to use it soon. One rule, I keep blowing is "case sensitive" and how I wish I would not! Been a little tied up with some things, will post back when after I give it a shot! Thanks for answering really really appreciate it!!!
Firm believer in Asus, Linux and Technology
"Art is to be enjoyed by all that enjoy it"
Asus M5A97 Plus motherboard
AMD FX 4350 Processor
Asus R7250 2GD5 graphics card
16gig DDR3-1333
2TB Hitachi Hard Drive
24in Asus VE248 LED Monitor
OS=My 8th OS Star Trek(Ubuntu 16.04)
Desktops=Gnome 3.20 and LXDE
Warp Speed!
ASUS Laptop R503U
AMD E2-1800
ATI HD7340
4gig Memory
500gig Hitachi HD
OS= Win7 SP1/8th OS Star Trek(Ubuntu 16.04)
Desktops Gnome 3.20 and LXDE
2nd 500gig Seagate HD R.I.P
User avatar
BBOSAK2143
U.E. God
U.E. God
 
Posts: 923
Joined: Tue Jul 03, 2012 7:56 pm
Location: Mount Pleasant, Tennessee
Age: 55
Operating System: Ultimate Edition 3.5 64 BIT



Re: Thumbos - Load disk images to your thumbdrive

Postby BBOSAK2143 » Sat Feb 08, 2014 7:11 pm

Okay now am liking this! This ThumbOS gets its behind going faster than I can get to step 1 on unetbootin!!!! Did one on Unetbootin the other day and it took about a half hour to get it to make it! Did not budge for about 10 minutes, ThumbOS has surpassed that as is moving right away! Not sure if this image is going to work the way I want it to, but least ThumbOS is! Right now am estimating about 15 minutes from start to finish on my computer. This means is twice the speed of Unetbootin and not even a quarter of the aggravation! I was an idiot to invoke command with upper case letters, have to knock that stupidity off and fast! Here is what am seeing with output and is great!

Image File: /home/ubuntu-builder/Ubuntu-13.10-amd64.iso
Volume id: Ubuntu-13.10-amd64
Volume size: 1607399
Bootable: Yes
================================================================================

SCANNING FOR USB DRIVE(S)...
Number of USB drives detected: 1
# DEV VENDOR LABEL TYPE SIZE
================================================================================
ls: cannot access /dev/disk/by-label/: No such file or directory
1 sdc SanDisk UNKNOWN dos 4.00 GB
================================================================================
Verifying write premissions to thumbdrive /dev/sdc: Granted.
Load: /home/ubuntu-builder/Ubuntu-13.10-amd64.iso to: sdc thumbdrive?
================================================================================
WARNING: this will erase all content on device sdc. (Y/N)? y

Dumping /home/ubuntu-builder/Ubuntu-13.10-amd64.iso to thumbdrive sdc...
isohybrid: Warning: more than 1024 cylinders: 3140
isohybrid: Not all BIOSes will be able to boot this device
[84% of 3140Mb] 660 blocks (2640Mb) written. 00:01:24 remaining.

Sure is no guarantee on my old hardware here, but am not going to let go of this program for nothing!!!! Is already loaded in upcoming system which am loading right now! Looks as if am done so am correct on the timing. Also have to remember current OS has been stressed a bit! Am terrible with systems as I push them real hard! Very very impressive TheeMahn! How the hell you beat those other 2 programs by doubling the speed is incredible!!!! Absolutely love the output and you can bet if this is going to work for my bios will be the only one I use!!!!

Another awesome thing is the ability to check in Qemu what has been created!!!! This is something that I have not seen on any of these utilities to create a thumbdrive!!!! Thanks for this brilliant piece of software that is sure to be anyone's greatest when it comes to a thumbdrive! Also apologize as got hung up on some other things and was not able to test earlier. Big thanks TheeMahn as always you are the greatest!!!! Will post back in a few to let you know if it works on my bios!
Firm believer in Asus, Linux and Technology
"Art is to be enjoyed by all that enjoy it"
Asus M5A97 Plus motherboard
AMD FX 4350 Processor
Asus R7250 2GD5 graphics card
16gig DDR3-1333
2TB Hitachi Hard Drive
24in Asus VE248 LED Monitor
OS=My 8th OS Star Trek(Ubuntu 16.04)
Desktops=Gnome 3.20 and LXDE
Warp Speed!
ASUS Laptop R503U
AMD E2-1800
ATI HD7340
4gig Memory
500gig Hitachi HD
OS= Win7 SP1/8th OS Star Trek(Ubuntu 16.04)
Desktops Gnome 3.20 and LXDE
2nd 500gig Seagate HD R.I.P
User avatar
BBOSAK2143
U.E. God
U.E. God
 
Posts: 923
Joined: Tue Jul 03, 2012 7:56 pm
Location: Mount Pleasant, Tennessee
Age: 55
Operating System: Ultimate Edition 3.5 64 BIT



Re: Thumbos - Load disk images to your thumbdrive

Postby BBOSAK2143 » Sat Feb 08, 2014 7:34 pm

No problem does boot to system but of course the system am doing so far is trash! I guess Ubuntu 13.10 just did not count on people using the system outside of a touchpad or with anything that is usb related! Soon as it boots to desktop have no use of mouse or keyboard! No solution to that so far! Really sucks as this OS of mine is going down! Have a cascading problem here and need to dump it, but the one I have built does not work outside of virtualbox! So this really sucks!!!! Might have to use something other than Ubuntu if this one goes down. Seems as have asked for help here on this, no one knows how to fix this problem and even is apparent that even Ubuntu does not know how to fix this as there are other users out here suffering this same problem of usb just not functioning!!! Big boo goes to Ubuntu for doing something this cruel!!!!!
Firm believer in Asus, Linux and Technology
"Art is to be enjoyed by all that enjoy it"
Asus M5A97 Plus motherboard
AMD FX 4350 Processor
Asus R7250 2GD5 graphics card
16gig DDR3-1333
2TB Hitachi Hard Drive
24in Asus VE248 LED Monitor
OS=My 8th OS Star Trek(Ubuntu 16.04)
Desktops=Gnome 3.20 and LXDE
Warp Speed!
ASUS Laptop R503U
AMD E2-1800
ATI HD7340
4gig Memory
500gig Hitachi HD
OS= Win7 SP1/8th OS Star Trek(Ubuntu 16.04)
Desktops Gnome 3.20 and LXDE
2nd 500gig Seagate HD R.I.P
User avatar
BBOSAK2143
U.E. God
U.E. God
 
Posts: 923
Joined: Tue Jul 03, 2012 7:56 pm
Location: Mount Pleasant, Tennessee
Age: 55
Operating System: Ultimate Edition 3.5 64 BIT



Re: Thumbos - Load disk images to your thumbdrive

Postby BBOSAK2143 » Sun Feb 09, 2014 9:57 pm

I just have to brag about this gem again! I have been viewing complaints of all the other Thumb drive creators as I try to find a solution for my problem. Now will once again state, Unetbootin struggles to create Thumb drives but sure does work but time wise is terrible. You would think with a gui would be good! NOT SO! If you have a CD/DVD in your computer forget it will not work! The other startup disk creator pretends to work and nothing happens! Now ThumbOS created by TheeMahn does the trick in about 15minutes. A nice easy trick I used for it was just copy/pasted the command to text file and just put it into terminal and baboom that ThumbOS takes off like a rocket with one question. Do you want to make it? This program needs to be in repos to knock out those other junk programs as is now the only program I would ever think of using! Will also be awesome to see those complaints of those junk programs wiped out for good!!!! To wipe the Thumb drive clean takes longer but is much more efficient! TheeMahn, can never thank you enough for taking the hassle of making a thumb drive and turning it into a total pleasure!!! Absolutely love it!!! As have said over and over will say it again. You're the best developer out here!!! Total genius!!!
Firm believer in Asus, Linux and Technology
"Art is to be enjoyed by all that enjoy it"
Asus M5A97 Plus motherboard
AMD FX 4350 Processor
Asus R7250 2GD5 graphics card
16gig DDR3-1333
2TB Hitachi Hard Drive
24in Asus VE248 LED Monitor
OS=My 8th OS Star Trek(Ubuntu 16.04)
Desktops=Gnome 3.20 and LXDE
Warp Speed!
ASUS Laptop R503U
AMD E2-1800
ATI HD7340
4gig Memory
500gig Hitachi HD
OS= Win7 SP1/8th OS Star Trek(Ubuntu 16.04)
Desktops Gnome 3.20 and LXDE
2nd 500gig Seagate HD R.I.P
User avatar
BBOSAK2143
U.E. God
U.E. God
 
Posts: 923
Joined: Tue Jul 03, 2012 7:56 pm
Location: Mount Pleasant, Tennessee
Age: 55
Operating System: Ultimate Edition 3.5 64 BIT



Re: Thumbos - Load disk images to your thumbdrive

Postby TheeMahn » Thu Feb 13, 2014 8:56 am

BBOSAK2143 wrote:I just have to brag about this gem again! I have been viewing complaints of all the other Thumb drive creators as I try to find a solution for my problem. Now will once again state, Unetbootin struggles to create Thumb drives but sure does work but time wise is terrible. You would think with a gui would be good! NOT SO! If you have a CD/DVD in your computer forget it will not work! The other startup disk creator pretends to work and nothing happens! Now ThumbOS created by TheeMahn does the trick in about 15minutes. A nice easy trick I used for it was just copy/pasted the command to text file and just put it into terminal and baboom that ThumbOS takes off like a rocket with one question. Do you want to make it? This program needs to be in repos to knock out those other junk programs as is now the only program I would ever think of using! Will also be awesome to see those complaints of those junk programs wiped out for good!!!! To wipe the Thumb drive clean takes longer but is much more efficient! TheeMahn, can never thank you enough for taking the hassle of making a thumb drive and turning it into a total pleasure!!! Absolutely love it!!! As have said over and over will say it again. You're the best developer out here!!! Total genius!!!


This tool somewhat saved my rear yesterday. I was writing a program called keysnatcher, should I say revising the app and adding new features on my girlfriends machine. It started getting really sluggish, mouse skipping across the screen. I at first thought it was the 30 or so tabs I had open in Firefox. Couldnt even close it it just sit there when I tried to click the X, so I hit ctrl + alt+ f3 dropped to a terminal logged in and sudo killall firefox it croaked it, ctrl + alt +f7 back to the still jittery desktop. Saved my work and logged out. When I logged back in what seemed like 1000 Caja's opened up it would open 4 or 5 to me closing just one. ctrl + alt + f3 sudo killall caja was in vein it just kept opening them. sudo killall Xorg and re-logging in greeted me with the same situation.

Surely a reboot would rectify the situation, nope. O.K. kill Xorg and scrap .config and login, nope still screwed. lynx http://www.google.com from the terminal and a search of multiple caja and attempt to fix all said issues yeilded nil results. What am I going to do now? This is my girlfiends computer when she wakes up she is going to have a stroke....

Luckily I have my Copy account tied and synced to her PC close to 1/2 a TB of data on it including unreleased Operating Systems. From the terminal I mind you, cd /media/3TB/Copy/Ultimate\ Edition/Public/Operating\ Systems/ cp ultimate-edition-3.8-x64.iso ~ cd ~ Inserted a thumbdrive thumbos --load ultimate-edition-3.8-x64.iso sdd had it reinstalled her bookmarks imported, restricted drivers, dual monitors set up, all upgrades installed before she got up. Did she notice, yes. When she went to login to facebook it did not remember her password, now comes the explaining ;)

I do have a newer version of this tool currently unreleased, I have alot of applications being worked at the same time I hope to bring all together. The keysnatcher is being re-written for tmosb it fixes core operating system issues. These issues reside in every Ubuntu based Operating System. A fix here goes a long way.
Code: Select all
KeySnatcher 1.0.2, 02/12/2014
GNU KeySnatcher home page: <http://ultimateedition.info/>.
E-mail bug reports to: <theemahn@ultimateedition.info>.
Be sure to include the word KeySnatcher somewhere in the Subject: field.
Usage: KeySnatcher -<-COMMAND>
Mandatory arguments to long options are identical for short options.
   possible commands...      

   -e   --errors   fix 404 errors with repositories
   -f   --fetch      fetch missing keys
   -h   --help      this help message
   -r   --rescan   rescan servers to determine which is fastest
   -t   --timeout   fix IPV6 timeout issues
   -v   --version   dump version info

KeySnatcher --help [COMMAND] for further information.

wip.png

#SAMPLE FIX FOR A MISSING KEY:
#KEY SERVER AVG PING

#keyserver.ubuntu.com 100
#pool.sks-keyservers.net 47
#subkeys.pgp.net DOWN
#pgp.mit.edu DOWN
#keys.nayr.net 64
#keys.gnupg.net 32
#Setting default keyserver as fastest server: keys.gnupg.net | 32
#Scanning for missing keys.
#Hit http://us.archive.ubuntu.com raring Release.gpg
#...
#Fetched 316 B in 40s (7 B/s)

#Processing key: 2E183FA1E260F5B0
#gpg: requesting key E260F5B0 from hkp server keys.gnupg.net
#gpg: /home/tonie/.gnupg/trustdb.gpg: trustdb created
#gpg: key E260F5B0: public key "Launchpad PPA for Ubuntu Tweak Testing Team" imported
#gpg: Total number processed: 1
#gpg: imported: 1 (RSA: 1)

#In the above example the software has determined keys.gnupg.net is the
#fastest server, this operation is only preformed once to accelerate any future
#grabbing of missing keys. The sofware then scans for missing keys and retrieves
# any missing key from that server.

the --timeout switch will insert a 2 second timeout for repositories, IPV6 based servers will hang for like 3 minutes why it attempts to resolve them:
#Fix for the following:
#[Connecting to mirror1.mate-desktop.org (2a01:4f8:100:7003::10)]
#(2a01:4f8:100:7003::10) is IPV6 and causes great delays in retriving package lists
#The work around is to set a 2 second timeout in apt conf


Setting deliberation failures:
fixing.png

The app will fix the top error w/o a doubt, the rest I am working on...
time.png
It's just a matter of time...

I hate debugging sed ;) sed is an awesome tool, however very finicky. Requires perfect expressions. The tool is so heavy there are pdfs written about it over 500 pages long.
all I have to do is get sed to add a # to the begining of each offending line, in this case those ppa's do not have a saucy release.

This is a thumbos thread, sorry for getting off the beaten path:
Code: Select all
#!/bin/bash
# ==============================================================================
# title         :thumbos
# description      :Loads disk images to thumbdrive from the CLI.
# author      :theemahn <theemahn@ultimateedition.info>
# date         :01/14/2014
# version      :1.0.4
# usage         :thumbos --help
# manual      :man thumbos
# notes         :See change-log below for further information.
# ==============================================================================
# Change-log:   1.0.1:   Initial Internal Beta release
#
#      1.0.2:   Bug fixes
#         Erase feature added.
#         Test feature added.
#         Display ISO and Image info
#
#      1.03   Minor bugfix see comment in code.
#
#         Supress errors if end user does not possess a thumbdrive,
#         exit graciously.
#
#      1.04   Edited erase routine, NTFS set as default.
#
#         Added partition detection function in case user has
#         multiple partitions on the thumbdrive.
#
#         Added initial ©Microsft Windows support & detection
#         routine.
# ==============================================================================

PROGNAME="Thumbos"
BUILDDATE="01/14/2014"
VERSION="1.0.4"

#Initiate a few arrays and vars
declare -a USBDRIVE=();
declare -a ISOINFO=('System id' 'System id' 'Volume id' 'Publisher id' 'Data preparer' 'Volume size');
((blockSize = 4 * 1024 * 1024))
sp="/-\|"
sc=0

#Not required, but optional
QEMUINSTALLED=$(which qemu)

# set colors so errors etc. stand out.
txtblk='\e[0;30m' # Black - Regular
txtred='\e[0;31m' # Red
txtgrn='\e[0;32m' # Green
txtylw='\e[0;33m' # Yellow
txtblu='\e[0;34m' # Blue
txtpur='\e[0;35m' # Purple
txtcyn='\e[0;36m' # Cyan
txtwht='\e[0;37m' # White
bldblk='\e[1;30m' # Black - Bold
bldred='\e[1;31m' # Red
bldgrn='\e[1;32m' # Green
bldylw='\e[1;33m' # Yellow
bldblu='\e[1;34m' # Blue
bldpur='\e[1;35m' # Purple
bldcyn='\e[1;36m' # Cyan
bldwht='\e[1;37m' # White
unkblk='\e[4;30m' # Black - Underline
undred='\e[4;31m' # Red
undgrn='\e[4;32m' # Green
undylw='\e[4;33m' # Yellow
undblu='\e[4;34m' # Blue
undpur='\e[4;35m' # Purple
undcyn='\e[4;36m' # Cyan
undwht='\e[4;37m' # White
bakblk='\e[40m'   # Black - Background
bakred='\e[41m'   # Red
badgrn='\e[42m'   # Green
bakylw='\e[43m'   # Yellow
bakblu='\e[44m'   # Blue
bakpur='\e[45m'   # Purple
bakcyn='\e[46m'   # Cyan
bakwht='\e[47m'   # White
txtrst='\e[0m'    # Text Reset

#Prerequisite check - mkntfs
MKNTFS=$(which mkntfs)
if ! [ $MKNTFS ]; then
   MKNTFS=$(which mkfs.ntfs)
fi
if ! [ $MKNTFS ]; then
   echo -e "${bldred}Error: mkntfs or mkfs.ntfs program not found!${txtrst}" >&2
   exit 1
fi

function CommandLineIntrepreter(){
echo -e "${bldgrn}Number of switches passed: $#"
for var in "$@"
do
   array_counter=$(($array_counter + 1))
   echo "Switch $array_counter: $var"
done
}

function DiskImageInfo {
   # Set needed varibles, we do not need to check for existance of $1 we
   # would not be here if it does not exist
   EXTENSION="${1##*.}"
   FILENAME="${1%.*}"
   BOOTABLE=$(file $1 | grep -m1 "bootable")

   #Don't put full trust in utility "file" for ISO's use the right tool
   #for the right job if file failed.
   if [[ $EXTENSION == 'iso' && $BOOTABLE == '' ]]; then
      BOOTABLE=$(isoinfo -f -d $1 | grep -m1 "bootable")
   fi
   
   # Set Boot Flag
   if [[ ${BOOTABLE} ]]; then
      BOOTABLE='Yes'
   else
      BOOTABLE='No'
   fi

   #Come here my pretty ;)
   echo -e -n "${txtwht}\n================================================================================${txtrst}\n"

   #ISO Image? Dump info defined in Array. Makes it simple to add remove info.
   printf '%-15s %s\n' \
   "Image File:" "$1"
   array_counter=1
   for number in ${ISOINFO[@]}
      do
         TITLEINFO=${ISOINFO[$array_counter]}
         GREPINFO=${ISOINFO[$array_counter]}
         DISPLAYINFO=$(isoinfo -d -i $1 | grep -m1 "$GREPINFO" | cut -d: -f2 | sed -e 's/^[ \t]*//')
         if [[ $DISPLAYINFO && $TITLEINFO ]]; then
            printf '%-15s %s\n' \
            "$TITLEINFO:" "$DISPLAYINFO"
         fi
         array_counter=$(($array_counter + 1))
      done

   # Dump info on boot info as detected, we may need some work here,
   # lots of different types of iso's and image files
   printf '%-15s %s\n' \
   "Bootable:" "$BOOTABLE"

   # Thusly inform end user.
   if ! [[ $BOOTABLE ]]; then
      echo -e "${txtred}Note: This image most likely will not boot. Proceeding.${txtrst}"
   fi
   WINISO=$(isoinfo -d -i $1 | grep -i "win\|microsoft")
   LINUX=$(isoinfo -d -i $1 | grep -i "LINUX")
   APPLE=$(isoinfo -d -i $1 | grep -i "APPLE")
   echo -e -n "${txtwht}================================================================================${txtrst}\n"

   # Drop additional info if acclible
   if [[ $BOOTABLE && $WINISO ]]; then
      echo -e "${bldgrn}This is a ©Microsoft Windows bootable ISO and will be treated as such.${txtrst}"
   fi
   if [[ $BOOTABLE && $LINUX ]]; then
      echo -e "${bldgrn}This is a bootable Linux based operating system and will be treated as such.${txtrst}"
   fi
   if [[ $BOOTABLE && $APPLE ]]; then
      echo -e "${bldgrn}This is a bootable Apple/ MAC based operating system and will be treated as such.${txtrst}"
   fi
}

# Some eyecandy?
function spin() {

   printf "\b${sp:sc++:1}"
   ((sc==${#sp})) && sc=0
}

function endspin() {

   printf "\r%s\n" "$@"
}

function DumpArray {

   #Yank on Devkit to retrieve availible USBDrives, we will process the data later
   #1.0.3 fix for 0 thumbdrives dump to /dev/null to avoid output of errors.
   #Open a subshell parse values.
   NUSBDRIVES=$((ls -l /dev/disk/by-id/*usb* | sed 's/^.*\///g' | sed 's/[0-9]*//g' | uniq | wc -l) 2>/dev/null)
   USBDRIVE=$((ls -l /dev/disk/by-id/*usb* | sed 's/^.*\///g' | sed 's/[0-9]*//g' | uniq) 2>/dev/null)
   #if user has at least one USB drive dump array to screen.
   if [[ $NUSBDRIVES ]]; then
      echo -e "${undwht}Number of USB drives detected${txtrst}: $NUSBDRIVES"
      printf '%-1s %-1s %-15s %-25s %-10s %s\n' \
      "#" "DEV" "VENDOR" "LABEL" "TYPE" "SIZE"
      echo -e "${txtwht}================================================================================${txtrst}"
      echo -e -n "${bldgrn}${txtrst}"
      array_counter=1
      #Stack out a database if you will of detected USB Drives, we will strip out
      #Non, hackers as we roll.  No, I do not want my 1TB external showing up as
      #as a thumbdrive.
      for number in ${USBDRIVE[@]}
      do
         TESTVALUE=${USBDRIVE[$array_counter]}
         REMOVABLE='2'
         REMOVABLE=$(lsblk | grep -m1 $number | cut -d ':' -f2 | cut -d" " -f3)
         # Removable is for debugging at this stage of development.
            #Bust out udisks we need raw data on the device(s) in question.
            VENDOR=$(udisks --show-info /dev/$number | grep 'vendor' | cut -d":" -f2 | sed 's/ //g')
            MODEL=$(udisks --show-info /dev/$number | grep 'model' | cut -d":" -f2 | sed 's/ //g')
            if [[ $VENDOR == "" ]]; then
               VENDOR=$MODEL
            fi
            #Still no Vendor?
            if ! [[ $VENDOR ]]; then
               VENDOR='UNKNOWN'
            fi
            BYTES=$(udisks --show-info /dev/$number 2>&1 | grep -m1 'size:' | cut -d":" -f2 | sed 's/ //g')
            LABEL=$(udisks --show-info /dev/$number | grep 'label:' | cut -d ":" -f2 |  sed -e 's/^[ \t]*//')
   
            if [[ $LABEL == "" ]]; then
               LABEL=$(ls -l /dev/disk/by-label/ | grep $number | cut -d ":" -f2 | cut -d " " -f2 | sed 's/\\x20/ /g' 2> /dev/null)
            fi
   
            if ! [[ $LABEL ]]; then
               LABEL="UNKNOWN"
            fi
   
            TYPE=$(udisks --show-info /dev/$number | grep 'type:' | cut -d ":" -f2 |  sed -e 's/^[ \t]*//' | sed 's/ //g')
            if [[ $TYPE == "" ]]; then
               TYPE=$(blkid /dev/$number'1' | cut -d " " -f4 | cut -d'"' -f2)
               if [[ $TYPE == "" ]]; then
                  TYPE=$(udevadm info --query=all --name=$number | grep 'ID_PART_TABLE_TYPE' | cut -d '=' -f2)
               fi
            fi
   
            if ! [[ $TYPE ]]; then
               TYPE="UNKNOWN"
            fi
   
            SIZE=$(echo "scale=2;${BYTES%/*}/1000/1000/1000"|bc)
   
            #print discovered date in nice columns
            printf '%-1s %-1s %-15s %-25s %-10s %-6s %s\n' \
            "$array_counter" "$number" "$VENDOR" "$LABEL" "$TYPE" "$SIZE" "GB"
            array_counter=$(($array_counter + 1))
   
      done
      echo -e "${txtwht}================================================================================${txtrst}"
   else
      echo -e "${bldred}Error: No thumbdrive(s) detected.  Exiting...${txtrst}"
      exit 0;
   fi
}

function copyFile(){
   # uncomment below for debugging.
   # echo "copyFile RECIEVED 1:$1 2:$2 3:$3 4:$4"
   inFile="$1"
   outFile="$2"
   wholeCurrentSize="$3"

   # Size in blocks
   size=$(stat --format=%s "$inFile")
   ((stepNb = size / blockSize + 1))

   # Prior existance Remove file.
   if [ -f "$outFile" ]; then
      rm "$outFile"
   fi

   # Initiate Copying
   i=0
   while [ "$i" -lt "$stepNb" ]; do
      dd if="$inFile" bs="$blockSize" skip="$i" seek="$i" of="$outFile" count=1 2> /dev/null
      ((i = i + 1))
      # output current copied size
      local copiedSize=$(stat --format=%s "$outFile")
      ((totalCopiedSize = copiedSize + wholeCurrentSize)) || true
      ((percent = (totalCopiedSize * 100) / totalSize)) || true
      echo -en "$percent%\r"
   done
   return 0
}

function progressCp(){
   # uncomment below for debugging.
   # echo "progressCp Switches RECEIVED 1:$1 2:$2 3:$3 4:$4"
   totalSize=$(du -s "$1" --bytes | awk '{print $1}')
   currentSize=0

   targetDir="$2"
   mkdir -p "$targetDir"
   targetDir=$(readlink -f "$targetDir")

   cd "$1"
   fileList=$(find .)
   INDICATOR='='
   while read inFile; do
      if [ "$inFile" != '.' ]; then
         outFile="$targetDir/$inFile"

         fileSize=$(stat --format=%s "$inFile")

         if [ -d "$inFile" ]; then
            mkdir -p "$outFile"
         elif [ -f "$inFile" ]; then
            if [ "$fileSize" -lt "$blockSize" ]; then
               cp "$inFile" "$outFile"
            else
               copyFile "$inFile" "$outFile" "$currentSize"
            fi
         else
            echo "Error: Unknown type of '$inFile' !" >&2
            exit 1
         fi

         # Mode
         #chmod "$(stat --format=%a "$inFile")" "$outFile"

         # Progress spinner and precentage
         i=1
         sp="/-\|"
         echo -n ' '
         ((currentSize = currentSize + fileSize)) || true
         ((percent = (currentSize * 100) / totalSize)) || true
         echo -en "$percent%\r"
      fi
   done < <(echo "$fileList")
}

function UnmountIso(){
   RETURN="$?"

   set +o errexit # We need to clean up everything we can

   trap - HUP QUIT KILL SEGV PIPE INT TERM EXIT

   echo "Syncing..."
   cd /
   sync
   wait 2> /dev/null
   sleep 1

   echo -e "${bldgrn}Umounting and removing '$1'...${txtrst}"
   umount "$1" && rm -rf "$1" || true

   echo -e "${bldgrn}Umounting and removing '$2'...${txtrst}"
   umount "$2" && rm -rf "$2" || true
}

function STARTTIMER {
   # Start the counter, we are off to the races.
   STARTM=`date -u "+%s"`
}

function STOPTIMER {
   STOPM=`date -u "+%s"`
   RUNTIMEM=`expr $STOPM - $STARTM`
   if (($RUNTIMEM>59)); then
      TTIMEM=`printf "%dm%ds\n" $((RUNTIMEM/60%60)) $((RUNTIMEM%60))`
   else
      TTIMEM=`printf "%ds\n" $((RUNTIMEM))`
   fi
   echo "Execution Time: $TTIMEM"
}

function QuickWipeFat() {
   #Display initial header
   VersionDump
   #Verify the switch interpreter, if not provide short help message example.
   if [[ $1 == "" ]]; then
      DumpArray $1
      echo -e "\n${bldred}ERROR: Please specify a device to wipe.${txtrst}"
      echo -e "${bldwht}Example: thumbos --erase /dev/sdb${txtrst}"
      echo -e "${bldylw}Note: the partition number is unecessary as it will erase the entire drive.${txtrst}"
      exit 0;
   fi
   #Begin scanning for USB Devices.
   echo -e "${bldgrn}\nSCANNING FOR USB DRIVE(S)..."
   DETECTED=$(ls -l /dev/disk/by-id/*usb* 2> /dev/null)
   #None found?
   if ! [[ $DETECTED ]]; then
      echo -e "${bldred}No USB drives detected. Exiting.${txtrst}"
      exit 0;
   fi
   if [[ -b /dev/$1 ]]; then
      DumpArray $1
   else
      echo -e "${bldred}Error: Device /dev/$1 is not vaild block device."
      echo -e "${bldgrn}Example usage: thumbos --erase sdk full${txtrst}"
      exit 0;
   fi
   NUMERALS=$(echo $2 |grep -o '[0-9]*')
   if [[ $NUMERALS ]]; then
      echo -e "${bldred}Error: Please provide drive letters only no numerals.${txtrst}"
      exit 0;
   fi
   #Final check.  Did the user specify a valid device?
   array_counter=1
   for number in ${USBDRIVE[@]}
   do
      REMOVABLE='2'
      REMOVABLE=$(lsblk | grep -m1 $number | cut -d ':' -f2 | cut -d" " -f3)
      #Debugging - future implementation?
      #if [[ $REMOVABLE == 1 ]]; then
         if [[ $number == $1 ]]; then
            VALIDITY='YES'
         fi
      #fi
   done
   
   if [[ $VALIDITY ]]; then
      if [[ $2 == "full" ]]; then
         ETYPE='Full'
      elif [[ $2 == 'secure' ]]; then
         ETYPE='Secure'
      else
         ETYPE='Quick'
      fi
      #Verify write premissions to drive
      THUMBDRIVE="/dev/"$1
      echo -e -n "${txtwht}Verifying write permission of thumbdrive: /dev/$1: ${txtrst}"
      if [[ -w ${THUMBDRIVE} ]]; then
         echo -e "${bldgrn}Granted.${txtrst}"
      else
         echo -e "${bldred}Denied."
         echo -e "Please run the command sudo thumbos --erase $@"
         echo -e "${txtwht}Exiting.${txtrst}"
         exit 0
      fi
      #User has provided valid switches / permission. Drop information and final warning in bold red to standout.

      echo -e "${bldgrn}$ETYPE Erase: /dev/$1 thumbdrive?${txtwht}"
         while true; do
            echo -e "================================================================================${bldred}"
            read -p "WARNING: this will erase all content on device /dev/$1. (Y/N)? " yn
            case $yn in
               [Nn]* ) echo -e "${txtrst}"; exit 0;;
               [Yy]* ) echo -e "${txtgrn}"
               echo "Erasing $1 thumbdrive...";
               break;;
               * ) echo "Please answer y or n.";;
            esac
         done
   else
      echo -e "${bldred}ERROR: $1 is not a valid device.${txtrst}"
      exit 0;
   fi

   UNMOUNT=$(umount /dev/$1 2>/dev/null)

   case "$ETYPE" in
      Full) echo -e "${txtwht}Full wiping drive: $1"; dcfldd if=/dev/zero of=/dev/$1;;
      Secure) echo -e "${txtwht}Securely wiping drive: $1"; dcfldd if=/dev/urandom of=/dev/$1 bs=1M;;
      *) echo -e "${txtwht}Quickly wiping drive: $1"; QUICK=$(mkfs.msdos -I -n 'Blank' -F 32 /dev/$1);;
   esac
   echo -e "${txtwht}Syncing..."
   sync
   echo -e "${txtwht}Refreshing partition ..."
   sudo partprobe /dev/$1 2> /dev/null
   echo -e "${bldgrn}All operations completed successfully.${txtrst}"
}

function Clear() {

   # Wipe Thumbdrive
   # Debugging switches... Uncomment to see output.
   # echo "1:$1 2:$2 3:$3 4:$4"
   # exit 0;
   # FORCE is an internally called switch to format drive in preparation
   # for loading out M$ Windows.

   if [[ $2 != "FORCE" ]]; then
      #Display initial header
      VersionDump
      #Verify the switch interpreter, if not provide short help message example.
      if [[ $1 == "" ]]; then
         DumpArray $1
         echo -e "\n${bldred}ERROR: Please specify a device to wipe.${txtrst}"
         echo -e "${bldwht}Example: thumbos --erase /dev/sdb${txtrst}"
         echo -e "${bldylw}Note: the partition number is unecessary as it will erase the entire drive.${txtrst}"
         exit 0;
      fi
      #Begin scanning for USB Devices.
      echo -e "${bldgrn}\nSCANNING FOR USB DRIVE(S)..."
      DETECTED=$(ls -l /dev/disk/by-id/*usb* 2> /dev/null)
      #None found?
      if ! [[ $DETECTED ]]; then
         echo -e "${bldred}No USB drives detected. Exiting.${txtrst}"
         exit 0;
      fi
      if [[ -b /dev/$1 ]]; then
         DumpArray $1
      else
         DumpArray $1
         echo -e "${bldred}Error: Device /dev/$1 is not vaild block device."
         echo -e "${bldgrn}Example usage: thumbos --erase sdk full${txtrst}"
         exit 0;
      fi
      NUMERALS=$(echo $2 |grep -o '[0-9]*')
      if [[ $NUMERALS ]]; then
         echo -e "${bldred}Error: Please provide drive letters only no numerals.${txtrst}"
         exit 0;
      fi
      #Final check.  Did the user specify a valid device?
      array_counter=1
      for number in ${USBDRIVE[@]}
      do
         REMOVABLE='2'
         REMOVABLE=$(lsblk | grep -m1 $number | cut -d ':' -f2 | cut -d" " -f3)
         #Debugging - future implementation?
         #if [[ $REMOVABLE == 1 ]]; then
            if [[ $number == $1 ]]; then
               VALIDITY='YES'
            fi
         #fi
      done
      
      if [[ $VALIDITY ]]; then
         if [[ $2 == "full" ]]; then
            ETYPE='Full'
         elif [[ $2 == 'secure' ]]; then
            ETYPE='Secure'
         else
            ETYPE='Quick'
         fi

         #Verify write premissions to drive
         THUMBDRIVE="/dev/"$1
         echo -e -n "${txtwht}Verifying write permission of thumbdrive: /dev/$1: ${txtrst}"
         if [[ -w ${THUMBDRIVE} ]]; then
            echo -e "${bldgrn}Granted.${txtrst}"
         else
            echo -e "${bldred}Denied."
            echo -e "Please run the command sudo thumbos --erase $@"
            echo -e "${txtwht}Exiting.${txtrst}"
            exit 0
         fi

         #User has provided valid switches / permission. Drop information and final warning in bold red to standout.
         echo -e "${bldgrn}$ETYPE Erase: /dev/$1 thumbdrive?${txtwht}"
            while true; do
               echo -e "================================================================================${bldred}"
               read -p "WARNING: this will erase all content on device /dev/$1. (Y/N)? " yn
               case $yn in
                  [Nn]* ) echo -e "${txtrst}Exiting..."; exit 0;;
                  [Yy]* ) echo -en "${txtgrn}"
                  echo "Erasing $1 thumbdrive...";
                  break;;
                  * ) echo "Please answer y or n.";;
               esac
            done
      else
         echo -e "${bldred}ERROR: $1 is not a valid device.${txtrst}"
         exit 0;
      fi
   fi
   STARTTIMER
   # Detect number of partitions currently on thumbdrive.
   TOTALPARTS=0
   TOTALPARTS=$(parted -s "/dev/$1" print | tail --lines 2 | grep '^\s[0-9]\+\s\+.*$' | awk '{print $1}'| bc)
   DISKSIZE=$( sudo parted -s /dev/$1 unit B print | grep "^Disk /dev/$1:" | cut -f 3 -d " " | tr -d B )
   # Information overkill, the end user probably does not care
   # echo "Disk size detected: $DISKSIZE"
   # Unmount Volume(s) - Suppress errors for non-existant volumes
   I=0;
   if [[ $TOTALPARTS -gt 0 ]]; then
      echo -e "${txtwht}$TOTALPARTS existing partitions detected.${txtrst}"
      while [ $I -lt $TOTALPARTS ]; do
         I=$(($I + 1))
         TRUEDEV='/dev/'$1$I
         UNMOUNT=$(umount $TRUEDEV 2>/dev/null)
      done
   else
      echo -e "${txtylw}No existing partitions detected.${txtrst}"
   fi
   #Unmount Success?
   if ! [[ $UNMOUNT ]]; then
      echo -e "${bldgrn}Device $1 successfully unmounted the $TOTALPARTS partition(s).${txtrst}"
   else
      echo -e "${bldred}ERROR: $1 can not be unmounted. Are you root?${txtrst}"
      exit 0;
   fi

   I=0;
   #DUMP ALL PARTITIONS - Do not assume the enduser is in the United States.
   if [[ $TOTALPARTS -gt 0 ]]; then
      while [ $I -lt $TOTALPARTS ]; do
         I=$(($I + 1))
         TRUEDEV='/dev/'$1$I
         echo -e "${txtwht}Deleting partition: $TRUEDEV${txtrst}"
         sudo parted -s "/dev/$1" rm "$I"
      done
   else
      echo -e "${txtylw}No partitions to delete.${txtrst}"
   fi
   #Check for non-existant partition table
   ERRORCHECK=$(sudo parted -s "/dev/$1" print| grep 'unrecognised disk label')
   if [[ $ERRORCHECK ]]; then
      echo -e "${bldred}ERROR: No partition table exists at all, attempting to rectify.${txtrst}"
      sfdisk /dev/$1 << EOF
;
EOF
      sudo dd if=/dev/zero of=/dev/$1 bs=512 count=1
      sudo sfdisk -A1 /dev/$1 > /dev/null 2>&1
   fi
   TRUEDEV='/dev/'$11
   #Ensure empty table is reflected to the kernel before proceeding.
   echo -e "${bldgrn}Creating a single partition 100% in size."
   #Suppress standard output, we don't need to update the fstab for a thumbdrive.
   sudo parted -a opt /dev/$1 unit MB mkpart primary 0% 100% > /dev/null 2>&1
   sudo sync > /dev/null 2>&1
   sudo partprobe $TRUEDEV > /dev/null 2>&1

   #Create a single default partition
   I=1
   TRUEDEV='/dev/'$1$I
   #Set default as NTFS
   sudo sfdisk -c --change-id /dev/$1 1 07 > /dev/null 2>&1
   case "$ETYPE" in
      Full) echo -e "${txtwht}Full wiping drive: $1"; dcfldd if=/dev/zero of=/dev/$1;;
      Secure) echo -e "${txtwht}Securely wiping drive: $1"; dcfldd if=/dev/urandom of=/dev/$1 bs=1M;;
      *) echo -e "${txtwht}Quick formating drive in NTFS Format: $1"; QUICK=$(mkfs.ntfs -Q -L 'ThumbOS' "$TRUEDEV");;
   esac
   if [[ $QUICK ]]; then
      echo -e "${txtwht}Drive $1 successfully formatted.${txtrst}"
   fi
   echo -e "${txtwht}Syncing...${txtrst}"
   sudo sync
   echo -e "${txtwht}Setting $TRUEDEV as bootable.${txtrst}"
   sudo sfdisk -A1 /dev/$1 > /dev/null 2>&1
   echo -e "${txtwht}Refreshing partition ...${txtrst}"
   sudo partprobe /dev/$1  2> /dev/null
   echo -e "${bldgrn}All partition and format operations completed successfully.${txtrst}"
   STOPTIMER
}

function WindowsISO {
   echo -e "${bldgrn}©Microsoft Windows ISO detected.${txtrst}"
   #Debugging Switches
   # echo "SENT 1:$1 2:$2 3:$3 4:$4"
   #Exclusive internally called switch to force a wipe, we
   #already know we have a valid device.
   Clear $2 FORCE
   #Create temporary mount points we will clean up later
   isoMountPath="/media/thumbos_iso_$(date +%s)_$$"
   partitionMountPath="/media/thumbos_target_$(date +%s)_$$"
   STARTTIMER
   # Mounting
   REALDEV="/dev/$2"1
   echo "Mounting $1 ISO..."
   mkdir -p "$isoMountPath"
   if [ -f "$1" ]; then # ISO
      mount -o loop "$1" "$isoMountPath"
   else # Real DVD drive (block)
      mount "$1" "$isoMountPath"
   fi
   mkdir -p "$partitionMountPath"
   mount "$REALDEV" "$partitionMountPath"

   # Calculate needed space
   freeSpace=$(df --block-size 1 "$partitionMountPath" | grep "$REALDEV" | awk '{print $4}')
   neededSpace=$(du -s "$isoMountPath" --bytes | awk '{print $1}')
   neededSpace=$((neededSpace + 1000 * 1000 * 30))

   if [ "$neededSpace" -gt "$freeSpace" ]; then
      echo -e "${bldred}Error: Not enough free space on '$REALDEV'!${txtrst}" >&2
      exit 1
   fi

   # Copy data
   echo "Copying ISO data..."
   progressCp "$isoMountPath" "$partitionMountPath"

   # boot dir should be lower case
   if [ -d "$partitionMountPath/BOOT" ]; then mv "$partitionMountPath/BOOT" "$partitionMountPath/boot"; fi
   if [ -d "$partitionMountPath/Boot" ]; then mv "$partitionMountPath/Boot" "$partitionMountPath/boot"; fi

   # Install Grub
   echo "Installing grub, please wait ..."
   grub-install --root-directory="$partitionMountPath" "$REALDEV" > /dev/null 2>&1

   uuid=$(blkid -o value -s UUID "$REALDEV")

   # grub.cfg
   echo "Installing grub.cfg..."
   cfgFilename="$partitionMountPath/boot/grub/grub.cfg"
   mkdir -p "$(dirname "$cfgFilename")"
   echo -n "" > "$cfgFilename"

   echo "echo '------------------------------------'" >> "$cfgFilename"
   echo "echo '|        ThumbOS - Loading...      |'" >> "$cfgFilename"
   echo "echo '------------------------------------'" >> "$cfgFilename"
   echo "insmod ntfs" >> "$cfgFilename"
   echo "search --no-floppy --fs-uuid $uuid --set root" >> "$cfgFilename"
   echo "chainloader +1" >> "$cfgFilename"
   echo "boot" >> "$cfgFilename"

   # Cleanup and exit
   echo -e "${bldgrn}Cleaning up.${txtrst}"
   UnmountIso "$isoMountPath" "$partitionMountPath" 'Cleanup'
   STOPTIMER
   #Prompt for testing?
   if [[ $QEMUINSTALLED ]]; then
      while true; do
         echo -e "================================================================================"
         read -p "Would you like to test the drive now in a virtual machine?. (Y/N)? " yn
         case $yn in
            [Nn]* ) echo -e "${txtrst}"; exit 0;;
            [Yy]* ) echo -e "${txtgrn}"
            echo "Booting $2...";
            break;;
            * ) echo "Please answer y or n.";;
         esac
      done
      qemu-system-x86_64 -enable-kvm -m 256 --boot menu=on -usb $REALDEV
   fi
   exit 0
}

function Loadit() {
   #Display initial header
   VersionDump

   #Verify the switch interpreter, if not provide short help message example & exit.
   if [[ $1 == "" ]]; then
      echo -e "\n${bldred}ERROR: Please specify an ISO to load to thumbdrive.${txtrst}"
      echo -e "${bldwht}Example: thumbos --load ultimate-edition-4.0-x64.iso sdc${txtrst}"
      echo -e "${bldylw}Note: the partition number is unecessary as it will replace the entire drive.${txtrst}"
      exit 0;
   fi

   #display information about selected iso:
   if [[ -e $1 ]]; then
      DiskImageInfo $1
   else
      echo -e "${bldred}$1 does not exist. Please specify an ISO to load.${txtrst}"
      exit 0;
   fi

   #Begin scanning for USB Devices.
   echo -e "${bldgrn}\nSCANNING FOR USB DRIVE(S)..."
   DETECTED=$(ls -l /dev/disk/by-id/*usb* 2> /dev/null)
   #None found?
   if [[ $DETECTED == "" ]]; then
      echo -e "${bldred}No USB drives detected. Exiting.${txtrst}"
      exit 0;
   fi
   #proper switches provided?
   if [[ -e $1 && $2 != "" ]]; then
      DumpArray $1
      
   else
      DumpArray $1
      if [[ -e "$1" ]]; then
         if [[ ${USBDRIVE[@]} && $2 == "" ]]; then
            echo -e "${bldred}Please provide one of the destinations above.${txtrst}"
            echo -e "${bldwht}Example: thumbos --load ultimate-edition-4.0-x64.iso sdc${txtrst}"
            echo -e "${bldylw}Note: the partition number is unecessary as it will replace the entire drive.${txtrst}"
            exit 0;
         fi
      else
         echo -e "${bldred}$1 does not exist. Please specify an ISO.${txtrst}"
         exit 0;
      fi

   fi
   #Scan for partition numbers a no, no.
   NUMERALS=$(echo $2 |grep -o '[0-9]*')
   if [[ $NUMERALS ]]; then
      echo -e "${bldred}Error: Please provide drive letters only no numerals.${txtrst}"
      exit 0;
   fi
   #Final check.  Did the user specify a valid device?
   array_counter=1
   for number in ${USBDRIVE[@]}
   do
      REMOVABLE='2'
      REMOVABLE=$(lsblk | grep -m1 $number | cut -d ':' -f2 | cut -d" " -f3)
      #Debugging - future implementation?
      #if [[ $REMOVABLE == 1 ]]; then
         if [[ $number == $2 ]]; then
            VALIDITY='YES'
            THUMBDRIVE='/dev/'$2
         fi
      #fi
   done
   if [[ $VALIDITY ]]; then
      #Verify write premissions to drive
      echo -e -n "${txtwht}Verifying write premissions to thumbdrive ${THUMBDRIVE}: ${txtrst}"
      if [[ -w ${THUMBDRIVE} ]]; then
         echo -e "${bldgrn}Granted.${txtrst}"
      else
         echo -e "${bldred}Denied."
         echo -e "Please run the command sudo thumbos --load $@"
         echo -e "${txtwht}Exiting.${txtrst}"
         exit 0
      fi

      #User has provided valid switches.  Drop information and warning.
      echo -e "${bldgrn}Load: $1 to: $2 thumbdrive?${txtwht}"
         while true; do
            echo -e "================================================================================${bldred}"
            read -p "WARNING: this will erase all content on device $2. (Y/N)? " yn
            case $yn in
               [Nn]* ) echo -e "${txtrst}Exiting ..."; exit 0;;
               [Yy]* ) echo -en "${bldgrn}"
               echo -e "Dumping $1 to thumbdrive $2...${txtrst}";
               break;;
               * ) echo "Please answer y or n.";;
            esac
         done

      #Whack the thumbdrive and load it as requested.
      #Is drive mounted? If so unmount drive. Suppress errors if not
      #mounted.
      #Windows Bootable ISO?
      if [[ $BOOTABLE && $WINISO ]]; then
         WindowsISO $1 $2 $3 $4
      fi
      #Click the timer, we are starting.
      STARTTIMER

      DUMPIT=$(umount /dev/$2 2>/dev/null)

      #convert image to hybrid bootable image.
      isohybrid $1

      #Use dcfldd - forensic based version of dd aka "Disk Destroyer"
      #we like nice toys.
      dcfldd sizeprobe=if statusinterval=10 bs=4M if=$1 of=/dev/$2

      #Ensure all data even buffered is written to the disk.
      sync

      #Set drive active
      echo -e "${bldgrn}Setting $2 device as bootable.${txtrst}"
      SUPPRESS=$(sfdisk -A /dev/$2 2>/dev/null)
   else
      echo -e "${bldred}$2 is not a vaild device.  Please refer to the table above.${txtrst}"
      # Correction in #1.0.3, no sence in syncing or refreshing the
      # Partition table if an invaild device was specified. Exit.
      exit 0;
   fi
   echo -e "${txtwht}Syncing..."
   sync
   echo -e "${txtwht}Refreshing partition ..."
   sudo partprobe /dev/$2  2> /dev/null
   echo -e "${bldgrn}All operations completed successfully.${txtrst}"
   STOPTIMER
   #Prompt for testing?
   if [[ $QEMUINSTALLED ]]; then
      while true; do
         echo -e "================================================================================"
         read -p "Would you like to test the drive now in a virtual machine?. (Y/N)? " yn
         case $yn in
            [Nn]* ) echo -e "${txtrst}"; exit 0;;
            [Yy]* ) echo -e "${txtgrn}"
            echo "Booting $2...";
            break;;
            * ) echo "Please answer y or n.";;
         esac
      done
      qemu-system-x86_64 -enable-kvm -m 256 --boot menu=on -usb /dev/$2
   fi
}

function Help() {
VersionDump
   if [[ $1 == "" ]];
   then
      PRAM="ALL"
   else
      PRAM=$1
   fi

   case $PRAM in
      ALL)
echo -e "
${bldgrn}Usage: $PROGNAME -<-COMMAND> [option]${txtrst}
Mandatory arguments to long options are identical for short options.
   possible commands...      

   -e   --erase      erases the entire thumbdrive
   -l   --load      load ISO image to thumbdrive
   -h   --help      this help message
   -s   --scan      scans / reports thumbdrive(s) and exits
   -t   --test      test boot device and exit
   -v   --version   dump version info

${bldgrn}$PROGNAME --help [COMMAND] for further information.${txtrst}";;
      ALL|e|erase)
         echo -e "
${bldwht}Usage erase;${txtrst}
${txtgrn}$PROGNAME -e <DEVICE> [quick|secure|full]${txtrst}
  Quickly erases the contents of <DEVICE> thumbdrive.
  Example: ${bldgrn}$PROGNAME --erase sdi secure${txtrst}
  If the [full] or [secure] option is used it will wipe the entire drive. This
  is a  slow process and the information is non-recoverable. Specifing no option
  is the same as using the default [Quick] option.

  ${bldred}Warning: The contents of the device will be entirely wiped and
  unrecoverable using the secure or full option.${txtrst}

  ${txtylw}Note: The partition number is not necessary as the entire drive will be wiped.${txtrst}";;
      ALL|s|scan)
         echo -e "
${bldwht}Usage scan;${txtrst}
${txtgrn}$PROGNAME -s${txtrst}
  Scans and reports availible thumbdrive(s).";;
      ALL|t|test)
         echo -e "
${bldwht}Usage test;${txtrst}
${txtgrn}$PROGNAME -t [DEVICE]${txtrst}
  Invokes a virtual machine to boot [DEVICE].";;
      ALL|l|load)
         echo -e "
${bldwht}Usage load;${txtrst}
${txtgrn}$PROGNAME -l <ISONAME> <DEVICE>${txtrst}
  Loads selected ISO to selected thumbdrive. Optionally will launch kvm for
  testing.

  Example: ${bldgrn}thumbos --load utimate-edition-4.0-x64.iso sdi
  ${bldred}Warning: The contents of the device will be entirely wiped.${txtrst}
  ${bldylw}Note: the partition number is unecessary as it will replace the entire drive.${txtrst}";;
      ALL|v|version)
         echo -e "
${bldwht}Usage version;${txtrst}
${txtgrn}$PROGNAME -v${txtrst}
  Displays $PROGNAMEs version number and exits.";;
      ALL|h|help|\?)
         echo -e "
${bldwht}Useage Help [COMMAND];${txtrst}
${txtgrn}$PROGNAME -h [COMMAND]${txtrst}
  Displays this message. For futher information $PROGNAME help [COMMAND]
  or refer to the manpages.

man $PROGNAME"
echo -e "${txtgrn}"
echo -e "Example: $PROGNAME -h version"
echo -e "${txtwht}Will display help about the command version${txtrst}"
esac
exit 0
}

function VersionDump {
echo -e "${undwht}$PROGNAME $VERSION, $BUILDDATE${txtrst}
GNU $PROGNAME home page: <http://ultimateedition.info/>.
E-mail bug reports to: <theemahn@ultimateedition.info>.
Be sure to include the word $PROGNAME somewhere in the Subject: field."
}

# Command line pre-processor
CommandLineIntrepreter $@
function Virtual {
   if [ -e "$1" ]; then
      echo -e "${bldgrn}Testing ISO: $1 in a virtual machine.${txtrst}"
      qemu-system-x86_64 -enable-kvm -m 256 --boot d menu=on cdrom=$1
   else
      echo -e "${bldgrn}Testing thumbdrive $1 in a virtual machine.${txtrst}"
      qemu-system-x86_64 -enable-kvm -m 256 --boot menu=on -usb /dev/$1
   fi
}

    case "$1" in
      -s|--scan) VersionDump; DumpArray; exit 0;;
      -t|--test) VersionDump; Virtual $2; exit 0;;
      -e|--erase) Clear $2 $3 $4; exit 0;;
      -l|--load) Loadit $2 $3 $4; exit 0;;
      -h|--help|-\?) Help $2; exit 0;;
      -v|--version) VersionDump; exit 0;;
      *) Help; exit 0;;
    esac


Substantially larger. I can no longer say currently unreleased ;) Feel free to report bugs / errors.

I am looking into building a new PC, not for me but as a server to build operating systems. A nasty machine that is the tip of the iceburg in cost. Drop 2 16 core AMD Operons on it SSD the whole ball of wax. I will probably have to buy it one part at a time, unless I hit the lottery lol They do get heavier 64 cores, can you imagine the raw speed?
Attachments
ultimate-edition-thumbos_1.0.4_all.deb
Version 1.0.4
(13.06 KiB) Downloaded 157 times
1.png
A couple hrs later ;)
Home of Ultimate Edition. Got a question? Please review the F.A.Q. Browse the How to section.

Main O/S: Builder of O/S Guess.
Mainboard: ASUS Hero VI (AM4)
CPU: AMD 1700X water cooled (Deepcool Captain Genome Cooling tower)
Ram: 16 GB GSkill Trident RGB Series Dual Channel DDR4 3200
Video: MSI RX470 8GB Gaming card.
Hard Disks: MASSIVE on the network.(10 Gigabit, 48 port, multiple servers)
Monitors: 4K Samsung 28", HannsG HH281, Various others
750 Watt modular PSU (Rosswell)
1100 Watt Amp & 4 X 600 Watt speakers

Servers in the basement.
User avatar
TheeMahn
Site Admin
 
Posts: 4199
Joined: Fri Oct 12, 2007 10:02 am
Location: U.S.A.
Age: 47
Operating System: Ultimate Edition Developer



Re: Thumbos - Load disk images to your thumbdrive

Postby BBOSAK2143 » Thu Feb 13, 2014 11:11 pm

You better bet I will download that keysnatcher the second it hits here! I love thumbOS and can also say sure tossed all the aggravation out!!!! Sounds as if you are confirming my suspicions about Ubuntu that all have problems like I have been experiencing!!! Is great to know I am not imagining things! This next OS is beating me to a pulp with hassles, that keysnatcher probably would have nipped it right in the bud before it started! Will rehash just in case you have not read the other posts. Am getting hassles with repos that are supposed to issue up-to-date files, instead I am getting old useless conflicting files! Now, I am assuming the way you are labeling keysnatcher that it would toss the out-of-date/conflicting files repo and set it straight with the updated file repos, right?

If I am correct in this assumption, someone needs to be issuing you some kind of reward, award or something! This I will say is going to be known as another miracle! Absolutely love your style, TheeMahn! Now you know why I call you the greatest developer out here. You always zero in on the problem. Never blow things off! Many others do, but not you!

Can understand the stroke part! My ole lady is a bit ticked about those windows not closing properly and some other things!!!! Is minor bugs with this one, dummy me wanted the latest greatest Gnome and simply trashed Gnome-Shell pretty badly! Next one has zip wrong with Gnome-Shell and windows close out the right way! Am hoping to do the 15 minute ThumbOS in a day or two after the rest of corrections made! Need this OS as have taken on some jobs and extra programs are there to help with them! Fun of holding an Associate's Degree is it's close to meaningless so have to bust a nut to make a living! Looks like will be doing 3 jobs at a time. Life is fun! Just hoping to keep my brain going well and advance slowly but surely! Love watching ThumbOS run is awesome countdown is accurate and damn I still can't believe how dependable it is!!!!

Also have to say, you always make me sigh in relief with how you zero in on those problems!!! Feels great to have someone who cares working hard for all of us! I hope one day I can add some things that are half as great! From the bottom of my heart I will continue to thank you for all you have done and keep doing for all of us!!
Firm believer in Asus, Linux and Technology
"Art is to be enjoyed by all that enjoy it"
Asus M5A97 Plus motherboard
AMD FX 4350 Processor
Asus R7250 2GD5 graphics card
16gig DDR3-1333
2TB Hitachi Hard Drive
24in Asus VE248 LED Monitor
OS=My 8th OS Star Trek(Ubuntu 16.04)
Desktops=Gnome 3.20 and LXDE
Warp Speed!
ASUS Laptop R503U
AMD E2-1800
ATI HD7340
4gig Memory
500gig Hitachi HD
OS= Win7 SP1/8th OS Star Trek(Ubuntu 16.04)
Desktops Gnome 3.20 and LXDE
2nd 500gig Seagate HD R.I.P
User avatar
BBOSAK2143
U.E. God
U.E. God
 
Posts: 923
Joined: Tue Jul 03, 2012 7:56 pm
Location: Mount Pleasant, Tennessee
Age: 55
Operating System: Ultimate Edition 3.5 64 BIT

PreviousNext

Return to Programming

Who is online

Users browsing this forum: No registered users and 3 guests