Cloning a Hard Drive With Linux

Yeah well calling it Linux means I most likely lost 97% of the market.


Windows people don’t realize that there is a painless way to get their windows computer to do some of this stuff – a Live Linux Distribution like Ubuntu.  If you get a live disc working, you can copy this shell into it, then follow the instructions.  It should work.

Mac people may even be able to run this natively.

Maybe.  Depends if PV is Mac Friendly, if not, convert the PV line to a copy of your choice.


A Live Linux can be “burned” to a USB stick or to a DVD and your computer can be booted from that.


And now you know!


But none the less…

What this is basically is my own shell.  I use this to completely back up my computer.  All the drive specifications are found and known, and do not change.

I run fdisk -l as root and use the information in there to edit the shell script to change things as needed.

This assumes that you know what your drive devices are, are willing to edit a shell script to make your own changes as is, then have an external USB hard drive slightly larger than your boot device.  My boot device is /dev/sda and most likely yours is as well.

This assumes that you have a second drive sitting in your chip reader.  If not, you can comment out the line that copies it to the hard drive.

This assumes that you have room enough to do everything.

I am doing this on Debian Linux, however the commands here are so very generic that you should be able to run this on most “full” distributions of Linux.  Debian, Ubuntu, Linux Mint, Centos, Fedora and the like come to mind.

Standard Internet Warranty – I make no warranties and it is at your own risk.  If you lose data, it is on you.  I take zero responsibilities for any miscoding or changing or whether a magic dragon comes out of the skies and takes you onward to valhalla.  Really.  None at all.

I will say that I ran this exact shell this morning and it worked for me.  You WILL have to change the file specifications to fit.   

Finally:

  • My boot drive is a 240gb SSD with about 120gb free.
  • My chip has about 12 gb worth of data on it.
  • Debian thinks that the chip is called “128GB” and it typically comes up in the file manager (thunar) on /media/bill/128 GB/

Prerequisites:

Installed versions of

How it runs:

  • This must be run as Root in Terminal.
  • This will pause after each step with an OK message in the Dialog box.
  • For me, the entire shell runs in about 2 hours on my i7 laptop with a USB 2.0 external hard drive.

First the shell in its entirety through to the end comment:

#! /bin/bash


#backup.sh from http://www.ramblingmoose.com

dialog –no-lines –title ‘Run This As Root’ –msgbox ‘This shell will backup SDA to SDB\nYou must click OK after each step so watch this.\nYour Disaster Recovery will thank you!’ 10 70

dialog –no-lines –sleep 3 –title “update your sources” –prgbox “apt-get -y update” 10 70
dialog –no-lines –sleep 3 –title “update your software” –prgbox “apt-get -y upgrade” 10 70
dialog –no-lines –sleep 3 –title “update your distribution” –prgbox “apt-get -y dist-upgrade” 10 70

arg1=”‘/media/bill/128 GB'”

dialog –title “copying the chip to the drive” –prgbox “cp -avr $arg1 /home/bill/128GB” 10 70

(pv -n -i 2 /dev/sda > /dev/sdb) 2>&1 | dialog –title “Backup SDA to SDB” –gauge ‘Progress…’ 7 70

dialog –title ‘Message’ –msgbox ‘Cloning is done, click ok to clean up and end’ 5 70

dialog –no-lines –sleep 3 –title “Removing the copy of the chip” –prgbox “rm -r /home/bill/128GB” 10 70 

dialog –no-lines –sleep 3 –title “Synchronize your drives” –prgbox “sync” 10 70
#end backup.sh

To actually use that mess…

  • Copy the entire text and paste it into your favorite text editor.
  • Save the file with a “.sh” extension somewhere you will be able to get to it – in your path.
  • Change the mode to executable – chmod 0770 backup.sh
  • Change the owner to root.  You never want to use this as a regular user – chown root backup.sh
  • Change the group to root.  chgrp root backup.sh
  • Run the shell as root: sudo ./backup.sh

Now, each line in excruciating detail!

—- Run the programs using bash interpreter

#! /bin/bash

—- I’m signing my work here

#backup.sh from http://www.ramblingmoose.com

—- This puts up a message box

dialog –no-lines –title ‘Run This As Root’ –msgbox ‘This shell will backup SDA to SDB\nYou must click OK after each step so watch this.\nYour Disaster Recovery will thank you!’ 10 70

—- The next three steps gets your distribution to date.  Don’t want this, comment it out

dialog –no-lines –sleep 3 –title “update your sources” –prgbox “apt-get -y update” 10 70
dialog –no-lines –sleep 3 –title “update your software” –prgbox “apt-get -y upgrade” 10 70
dialog –no-lines –sleep 3 –title “update your distribution” –prgbox “apt-get -y dist-upgrade” 10 70

—- Store the directory that Linux mounts the chip to in “arg1”  If no chip to backup you can comment this.

arg1=”‘/media/bill/128 GB'”

—- Wrap the actual work of copying the chip out to a dialog box.  The flags “-avr” say copy the whole drive in $arg1 recursively to the destination.  If no chip to copy, comment this line.

dialog –title “copying the chip to the drive” –prgbox “cp -avr $arg1 /home/bill/128GB” 10 70

—- This line does the real work.  Now that you copied your chip out to the hard drive, clone the actual hard drive.  The flags on pv tell it to report to stdout the percentage of work done so that dialog can show a pretty gauge.  Ahh, so pretty!

(pv -n -i 2 /dev/sda > /dev/sdb) 2>&1 | dialog –title “Backup SDA to SDB” –gauge ‘Progress…’ 7 70

—- Copy is done, it is time to clean up message

dialog –title ‘Message’ –msgbox ‘Cloning is done, click ok to clean up and end’ 5 70

—- remove the data that you copied from the chip from the hard drive to be neat. if no chip, comment this out.

dialog –no-lines –sleep 3 –title “Removing the copy of the chip” –prgbox “rm -r /home/bill/128GB” 10 70 

—- Your work is done, make sure you flush your cache by doing a “sync”.

dialog –no-lines –sleep 3 –title “Synchronize your drives” –prgbox “sync” 10 70  

#end backup.sh

The Little Mysteries Of Writing

Sitting down at a keyboard and writing, rambling on, can be an odd preoccupation.

You end up having a conversation with the inside of your skull.  An imaginary person is sitting there, and you’re talking away.

It is possible to be entertaining, instructional, and engaging.  It is even possible to do all of that all at once.

It is possible to annoy, anger, and enrage.  I’ve done that as well.  In fact I’ve had someone once, thankfully just once, threaten me.

I laughed it off.  Being “On The Net” since the dusty old days of when dinosaurs roamed the Earth and the years started with 19, I have watched things go from being an academic discussion to the current obsession with cats, selfies, selfies with cats, and butts. 

Thanks to some pseudo-celebrities, it’s even Selfies with Cats and with Butts. 

We’re doomed I tell you, Doooomed!

This audience is always imagined, and sometimes it shows its head.  Mostly polite of course.  Most people are, or at least try to be, or at least think they are.

I’ve been at this for quite a while, and probably will continue for a while.  After all, it’s easy to take a picture.  It’s even easier to write about what you were thinking about.  I tend to do that and keep a few pictures in abeyance – that’s in my back pocket.  Bang out a few paragraphs and so forth.

But you really never know what will get people excited. 

I’ve found that the recipes and the dog postings are very popular.  There are, however, some days you just don’t understand.

This business with statistics.  You go into your favorite blogging platform and you can find out what people were looking at.  You also can do that with Google Analytics.  Both of which I do on a daily basis.

But I think I had a statistical anomaly that I am still scratching my head about.

Linux.

No don’t run away.  It’s not going to be banging on about how wonderful it is, or how it’s the perfect thing to do with your old computer that got replaced on Xmas or Chanukah or your birthday. 

It is, but that’s not the point.

While I do talk about Linux from time to time, I don’t do it frequently enough to become an authority about the subject.  I’m kind of “middle of the road” with my knowledge on the subject.  Level 2 support, maybe Level 3, if you’re taking notes.

When you look at your statistics and see that you got so many hits from so many places, you have to scratch your head.  Yeah that again.

I got 75 percent of my readers in yesterday from people sitting on a Linux computer.

3 out of 4 readers yesterday agreed that Linux was the platform of choice.

As opposed to about 1.5 percent of them in the real world.

Fifty times more people hit this blog with a Linux computer than in the real world?  Is my math correct?

Penguins unite!  You have nothing to lose but your Microsoft shackles!

As I write this on Windows 8.1 on a rather nice laptop…

Cross platform here.  Platform agnostic.

Dry, I’ll stop that before I confuse you.

I just … don’t… get… it.

So instead I will just post a picture of the beach at Fort Lauderdale and call it even.  After all, my own family is suffering through some below 0 F wind chills today.  It won’t even hit 70 here today or as we say “It’s not a beach day … unless you’re from Minnesota”.

But the Linux thing…. I just don’t know!

Reminds me that I need to find the chip reader.  There’s an i7 laptop that needs a copy of CentOS dropped on it for a server project I want to complete with WordPress and a proper LAMP stack.

Shellshock – A BASH bug that effects Linux and Mac OSX … and everyone on the web

Yeah, scaremongering isn’t the best.  Luckily for those of us who run Linux, the fix is easy.

It also effects some Mac systems, although you will need to test and get your own upgrades.

It is possible that it effects Android systems as well.  I did the test on my tablet running CyanogenMod this morning and it was safe.  Your Mileage May Vary.

How this effects Windows is straightforward, it’s another one of those low level things in a web server that can bite us later and since Linux powers many websites, you are effected indirectly.  Think of what the Heartbleed problem was and how you went in and changed all your passwords to protect yourself.  Good idea to start changing them again!

The bug is called “Shellshock”.  The specifics is that it allows a ne’er do well to hack into an unpatched Linux server and gain full control via something called the BASH shell.  That is a bad thing because with control over bash, you can gain full control of the entire computer.

There is a test and full explanation of all the geekery under the hood here at this link at www.ArsTechnica.com if you care to dig deeper.  Basically, just go in and do a full update of your machine and make sure you see bash updated. 

The test is this line in terminal.

 env x='() { :;}; echo vulnerable’ bash -c “echo this is a test”

If the system is vulnerable, the output will be:

vulnerable
 this is a test

An unaffected (or patched) system will output:

 bash: warning: x: ignoring function definition attempt
 bash: error importing function definition for `x’
 this is a test

Since Mac OSX is based on something called BSD and bash comes with it in their terminal.  If you have an older Mac that is acting as a server, look into a patch.

I personally did the fix last night on my Debian system while I was half asleep.  Really trivial to fix.

In a root terminal –

apt-get update
apt-get upgrade

It went out and updated my list of available updates, then upgraded those that needed it.  The package “bash” was included.

CentOS came up this morning with a bubble telling me to install updates.   It worked.  No problem.

I tried it out on my RaspberryPi machine and yes, that was affected.  The patch worked, and the picture is below. 

Here’s the thing, it may effect Android tablets and phones depending on whether bash is installed.  It’s a very basic and well known tool, so you will need to make sure you can patch the tablets. 

However, it’s highly unlikely that some average dude walking down the street with a year old Android phone with an unpatched system will have a problem.  Someone would have to know you’re there, get into your machine, and do the hack to gain control.  You aren’t the person they would be looking for, it’s that big web server sitting somewhere like a store or a bank that they’re going to hack.

Just accept the updates if you have manual control of whatever computer you are using, phones and tablets included.

If you are “going into” your machine, set your update preferences to allow security updates automatically while you’re at it since that makes it easier to administer the machines.

Need Excel or Word? Try Libre Office Free

Sure, it’s written like a spam or a sales document but the truth is that most people won’t need anything else and yes, it it is completely free.  Libre Office, is a complete office suite, and it really is free.

Ok, why am I talking like a salesman?  Simple, someone asked me if they could “borrow” my copy of Microsoft Word.  6:45 AM in the middle of my dog walk.  I told them to check my blog today for links for downloads for Libre Office instead.

First, you don’t really borrow software, you do that and it is considered piracy.
Second, you don’t really need to spend the money for a word processor or spreadsheet program when there is an excellent free piece of software out there.

Yes.  Free.

As in Free and Open Source Software.  “FOSS“.

Keeping this simple, basically “FOSS” works.  People do write software to do things and sometimes it is put out there for everyone to use.  You know, good guy stuff?

In the case of Libre Office, you can replace Microsoft Office with it.

Word is replaced by Libre Office Writer
Excel is replaced by Libre Office Calc.
Access is replaced by Libre Office Base.
Powerpoint is replaced by Libre Office Impress.
and Visio is replaced by Libre Office Draw.
They also have something called Libre Office Math, which I believe is a replacement for Mathematica but I don’t have any experience with it. It lets you solve equations like the ones you had in Algebra and Calculus by typing in the formula.  Don’t tell your high school kid but it should solve their homework for them.

Now, if you are a professional, you’ll realize that in certain cases you simply can’t use anything else.  Your IT Department decided this is what you’re going to use.  Go for it.

But if you are like the majority of computer users, on Linux, Mac or Windows, all you really need these days are a good browser and an occasional Word Processor and Spreadsheet.   The rest is overkill but hey, it’s all free.  They do make their money by donations, so if you’re fully employed you might want to drop some money in their tip jar

Think about it, Five Bucks for a Microsoft Office Work-alike Replacement.  Pretty cool, huh?

I use it on my machines here, Windows, Mac, and Linux.  In fact it came free with Linux Ubuntu, I didn’t have to think to install it … there it was.  It’s on my CentOS Linux Server that I’m building right now.  My Linux People will know – Synaptic has all this stuff for the asking on Ubuntu and Debian. I loves me some Synaptic!

The thing is that even the output files that you create using Libre Office are the same format as those out of the more popular programs like Microsoft Office.  The only rub is that you have to make sure you tell it to use the docx or xlsx formats when you save, or configure Libre Office to do that once and for all.  I forget once in a while and then get a little confused as to why my resume is not in docx.

The download page is here.  Like I said, you don’t have to pay for it.  It’s free.

It Hasn’t Hit The Market Yet But Windows 8 Has Been Pirated

I don’t know why I am surprised.  I guess Microsoft has the same problems with security as every other large organization.  But if you hunt around, Windows 8 has already hit the pirate Bit Torrent sites.

No word whether they found a way to fix that ugly “Construction Paper” interface.

Not mocking Microsoft at all, people pirate software for their own reasons, and there had to be an insider on that. 

There are alternatives out there for your trusty computer although most folks would not consider them because of lack of training or even being aware that they exist.  It’s a bit sad though that the software has not earned Microsoft a penny yet and people have already put it out on those sites.   Not quite fair is it?

I’m a big fan of open source software.  This particular machine is an Eee machine, a wee little thing that came to me without an operating system or any software at all.  I installed CentOS Linux, then Libre Office came with it, Skype and a few other pieces of software, all of which are free or open source.

FOSS – Free Open Source Software.

FOSS takes a bit of getting used to, but if I need anything to make this particular little machine run, I can get it without resorting to theft.

On the other hand, the graphics programs I use to put those pictures up with those annoying watermarks (I’m sorry, really I am) are FOSS and I can use them on my Mac or my Windows computers.   I use Gimp and Inkscape and they both get the job done quite well and work with accepted industry standards.

For the rest of us, Windows 8 will be released to the stores in October and you can decide then if it is for you.

Testing an Eee PC with Ubuntu and CentOS Linux

I was handed an old Eee PC lately. One of those small netbook things.  I usually describe them as “Barbie’s PC”.  Personally anything with a keyboard is something better than without, but that’s my preference.   Typing on a glass just does not have the feel of clicky or bouncy keys.

It didn’t have an operating system.  So very helpful, turn the thing on and it told you that.  I’m assuming that the person who had it didn’t want their data to be found, or it was one of the “refurbished” machines you see online. 

So here’s what you do when you have a machine that “doesn’t work at all”.  You know, a dead machine that you want to see if it’s intact or it needs to be recycled or you just have a machine with data on it you need to save before you start over.

Download a “Live CD” version of Linux.

They’re a full operating system that just runs from the cd or the memory stick that you’re using for the purpose.  You’ll need at the bare minimum 1GB, but a 4GB stick is the most I have ever needed for the task.

They’re an interesting thing.  In Windows and Mac machines, you’re wedded to the computer.  With a Live CD and a little dancing, the PC becomes just a box that runs what’s on the stick.  The stick doesn’t care, it can run on any fairly modern machine.

The thing with these Live CDs is that they’re completely independent of what’s going on on your machine.  If you’re off on vacation, you can have an environment that is tailored to your own use.  I’ve done that before, brought one with me.  Basically a complete computer on my keyring.  It only touches what is on the PC’s hard drive if you go out of your way to do so.

Grabbing the most friendly Live CD, Ubuntu, I managed to get it to the memory stick using the instructions that are found on Ubuntu’s site.  Plug that Memory Stick into the little Eee and power the thing on.  

I was presented with the Brown/Orange Ubuntu desktop.  Success.

Running through all the inventory of devices I managed to determine that the machine was complete, functional, intact, and ready for anything else I wanted to do with it.

After playing around and seeing that I was safe, I decided to click the helpful install icon on the desktop and let it go through the motions of a full install.  It worked beautifully.  At least the install did, but I eventually didn’t go with Ubuntu for a couple reasons.

The Wifi on the install didn’t work well.  I was constantly refreshing web pages that never loaded.  Since we’re using computers both on the web and with programs on the hard drive, that wouldn’t work.  Driver problems are the biggest problem with Linux.  It just isn’t supported as well with “Cutting Edge” hardware.

The other thing is that Ubuntu is butt ugly.  They have something called the Unity Interface which is like having a permanently opened start menu on the left hand of the screen.  I couldn’t figure out how to make it hide so I could ignore it.   This is the usual complaint.  I hate it and don’t have to use it.

Luckily there are other versions that work as well, if not better in some cases.  For small computers, and older ones like the one that is probably sitting in the back of your closet, you’ll want something called “Lubuntu“.  Think of “Lightweight Ubuntu”.  It uses an interface that looks very much like Windows, and runs blazingly fast because all the programs are the smaller ones.  On the Eee it ran beautifully except it had the same Wifi Problem.  If you don’t have an Eee or you want to experiment with drivers, you may get it to work.  I was lazy, I had bandwidth and time.  I took the “Path of Least Resistance”.

I eventually ended up installing CentOS which is a full server operating system.  This is the same thing that is running many websites and businesses around the world.  CentOS has a rock solid feel and an enormous amount of support since it is Red Hat Enterprise Linux, almost.  They took Red Hat, removed their branding, and put it out there for everyone to use free and since it is Linux it is all nice and legal.  I’ve never had a problem with CentOS, in fact since it is Linux, it runs on a very old machine with ease.  I had a 12 year old Pentium 3 laptop that had Centos 3 on it from back in the 1988 or so until it simply up and died one day.  Never had a problem with either CentOS or the ancient laptop at all and it ran as fast as the current hardware, going through update after update.

It just takes knowing what you’re doing.  A lot of that experimentation has been removed with the mainstream Windows and Mac OSX.  Running Linux is a much more raw experience but when you have it up and running, it will purr like a kitten for years or even decades.

New Firefox and Turn Off The Smoothscrolling

I love Firefox.

Well no, Pee Wee I don’t want to marry it.

On the other hand, I’m so very used to the way it works and its quirks that I can’t conceive of using anything else.

It works on all the computers I use – Linux, Windows, and Mac.   It does things well.  It can be extended so that I block advertisements and “nasty” websites.  It does not spy on me (Hear that Chrome?).  It’s not Bloated (I’m talking to you Internet Explorer).  It isn’t forced on me (I don’t want to go on a Safari to check into a website).

So yesterday I updated my Firefox.  If you click on the link, it will tell you if you are up to date.

After loading up my normal 150 web pages and muddling through most of the routine, I see only one problem.

Smoothscroll was turned on “accidentally” by the upgrade to Firefox 13.

I’m not the kind of person who likes Smoothscroll.   It reminds me of when I was a kid sitting on a swivel chair and spinning around faster and faster so that when I stopped the world kept moving.

On this particular laptop (2 year old Core2Duo with Windows 7 and 8 Gigs of Memory), Smoothscroll doesn’t smoothly scroll it fidgets to the next page.   In a spastic wretching and lurching forward, you get the next page of data instead of a quick “Snap!” to the next page.

I know Smoothscrolling is supposed to look like you are skimming down a written page but to me it is annoying.   Not nausea inducing, just annoys me while I sit there thinking why isn’t it there yet?

I don’t want to be that kid in the back seat saying “Are We There Yet” when I’m looking at pictures of cats or puppies, nor do I want to be wondering why it’s taking so long to scan to the bottom of a page of 100 jobs in a job search website.

Do the job.  Do it quickly, efficiently, and with a minimum of that eye candy nonsense.  You’re just slowing me down.

Ok, enough of the rant.  If you want to turn on or turn off Firefox’s “feature” of smooth scrolling down your pages – which doesn’t work, here are the basic instructions.

  1. Launch Firefox.
  2. Click on Tools.
  3. Click on Options.
  4. Click on the Advanced icon that looks like a gear.
  5. Click on the General Tab (No, not the one that looks like a light switch, the tab below that.  I’ll wait.  Good.)
  6. Look down to the middle of the panel in the browsing section and click the box to the left of “Use Smooth Scrolling”.
  7. Enjoy.

Now that you have finished, here’s your treat.  A short video about an adorable little girl being taught by a friendly Boxer dog how to drink from the hose.

Repeat after me… Awwwww.