Sunday, June 28, 2015

PPC Linux Backups: Part I

So I've again taken an opportunity to step away from the G4 upgrades project as I have again become frustrated, this time with trying to make the upgraded CPU work. More on that when the post is completed and published.

I decided it would be more than worth it to put together a three part series on backing up your PPC Linux machines.  I myself use of combination of PowerPC machines, including a G4 PowerBook, G4 PowerMac QS, dual core G5 PowerMac, and a G4 iBook.  Much of the configurations between the 4 are quite similar, but different enough that I'd like the peace of mind knowing that these configurations and other valuable data are backed up and backed up on a scheduled basis. Part I will cover creating bootable hard drive clones; Part II will cover available software that could automate backups to an external drive or a storage location out on the network; Part III will cover how to create more of a DIY solution using custom scripts and automation tools.  I'm going to refrain from using any cloud/offsite backup solutions as they usually cost money and require my personal information.

So onto Part I covering the process involved in creating an exact bootable clone of your existing hard drive.  We are going to use the well-known and trusted command line tool dd to complete this task.  This is quite the powerful tool that at its basic core simply reads and writes files. With this in mind, this tool should allow us to either make a copy of the entire drive or a single partition if we would like.

As an example, I am going to be cloning my 40 GB Maxtor HD in the G4 PowerMac GS containing my Debian install.  I'm going to clone the entire drive instead of just specific partitions, so in essence, it should be an exact bootable clone.  I would like to use a drive of the same vendor and capacity, but I do not exactly have many spare 3.5" IDE drives laying around, so for this task I am going to clone the existing drive to a 40 GB Western Digital (WD400JB/WD Cavier SE) HD.  The QS has the ability to mount two IDE drives, but I already have both occupied, so I turned to my IDE/SATA to USB 2.0 adapter kit to attach the backup drive.

Below is a screenshot of my current Debian disk and its existing partitions and partition layout.  After the cloning operation, which should expect to see the exact same layout on the hard drive clone.


Once your external drive is attached and recognized by your system, you will want to figure out its file name in /dev.  From my reading of the Debian installation guide, all disks detected by the system start with sd (I'm assuming this stands for SCSI device or something similar?) and the first drive is detected as a, the second b, third c, and so on. So for my setup, the external drive happens to be the third attached disk, so its filename is /dev/sdc.

Now it is time to run the disk cloning command:
sudo dd if=/dev/sda of=/dev/sdc

As you will notice, this command requires root privileges.  The 'if" part stands for input file and if you are catching on, "of" stands for output file.  We are not reading or writing just files, but technically a drive itself is a file (e.g. /dev/sda) within the EXT4 file system. Hopefully that makes sense. Your input and output files will vary depending on your system setup. If you need help identifying this information or if you are just wanting to copy certain partitions, leave me a comment below.

The amount of time it takes to clone the drive or partition depends on both the size and speed of the drive, but expect it to take quite a bit of time.  For this 40 GB drive clone, it took between 4-5 hours total (I did not time it, although I should for comparisons in drive read/write performance when upgrading to an SSD).

Here are the results from my cloning process:
dd: writing to ‘/dev/sdc’: No space left on device
78165361+0 records in
78165360+0 records out
40020664320 bytes (40 GB) copied, 8500.46 s, 4.7 MB/s

As you can see there are no error messages, but simply a warning that the destination file ran out of space. This is because my Debian system sees the Maxtor as having 41 GB and the Western Digital as having a 40 GB capacity. Either way, there is no harm in this case.  Here is a screenshot of the Western Digital HD after the clone.


I shutdown my system and pulled the live Debian HD and replaced it with the cloned Western Digital HD to test out the backup.  Here is my last screenshot of this post showing us with WD drive booted and located at /dev/sda.

 
So a definite success.  Now that I have this cloning process down, I will do the same with the other PPC machines and schedule it to be done on a periodic basis.

Of course, you'll want to tag team this backup approach with another such as backing up with a piece of backup software or writing shell scripts to do the backups for you, which again happens to be part II and part III of this series respectively.  As I learned early on in computing, a smart man backups up his data, but a wise man makes backups for his backups.

Friday, June 12, 2015

Updates, Aliases, and Network No-Nos

Long time no post (at least it feels like that). My work on the graphics card upgrade was moving along quite nicely, but I've hit a brick wall after compiling the latest nouveau drivers/modules, libdrm, and mesa libraries.  On the G5, I simply get an error regarding a GPU lockup, and a botched graphics glitch on the G4 with the updated kernel.  Because of that, I've decided two things: 1) I'm going to work on the CPU upgrade next on the G4 and 2) I'm going to table the nouveau drivers project for just a bit and go with a Radeon 9800 Pro for an upgraded graphics card.

Right now, I feel like I'll have a better chance of getting 3D acceleration working with the nVidia Quadro card on the G5, so look for updates on that over on the PowerPCLiberation blog.

On an unrelated note, I want to take a few minutes to discuss command aliases you can setup for your bash shell environment. I've been meaning to do this on my Debian installs for some time as I've set them up on all the Linux machines at my full-time job. Basically you can create aliases to make shortened versions of longer commands you run on a regular basis. For example instead of typing the following:
sudo apt-get update && sudo apt-get upgrade

You can shorten this command to simply the word update, which when ran will actually run the command above.  To get started with aliases, you'll want to change directories into your home directory.  Create/open a new file you'll call .bash_aliases.  The syntax for setting up a new alias is as follows:
alias [alias_name]='[full command you are aliasing]'

So for the example I provided above, I would set it up like so:
alias update='sudo apt-get update && sudo apt-get upgrade

Upon saving the changes, you should immediately be able to make use of the new alias.  To test it out type update and watch as this short one word command runs both the update and upgrade commands!

Here are just a couple of others I usually implement on each of my installs.
alias cdh='cd /home/[username]'
alias cde='cd /etc'
alias cdv='cd /var'
alias ls='ls -alh'

They may not do a whole lot, but the small amount of time these aliases can save does add up over time in the same way the utility kupfer does.  I'd encourage you to come up with your own.  Feel free to share them in the comments below as they may be helpful for the rest of us.

Also, if you happen to run a really long command and say forgot to add sudo to the beginning of it or need to move towards the beginning of the command to retype or add additional commands, simply hit Command + a (or Control + a if you haven't swapped out the Command and Control keys).  This moves your cursor to the beginning of the command.  I happen to use this quite a bit.

One last thing I've learned recently when working with Debian I thought might be helpful to share. If you are using the well-known NetworkManager, don't manually edit the /etc/network/interfaces file with network interface configurations or vice versa.  The two separate configurations will conflict with each other and produce unusual, unpredictable, and unusable results.  For some time now, I couldn't figure out why I couldn't just plug in an ethernet cable to any of my PPC machines and receive an IP via DHCP without restarting network services or rebooting with the cable already plugged into the machine. Such a simple concept, but it took me awhile to figure out.

Oh yeah, and if you'd like to use the GUI wrapper for NetworkManager, simply type  nm-connection-editor. That right there might be an excellent candidate for creating an alias in order to shorten it up.  Of course you can also tab to auto-complete the command, but the choice is yours.

So nothing too exciting.  Just a few helpful tips for growing and expanding your Linux experience and expertise. Look for the CPU upgrade soon!  I'm also running into issues with that as well, but I'm more hopeful I'll be able to resolve those quicker than the nouveau drivers. Not only that, the CPU is such a sloth, that an upgrade should help move the rest of my posts on the upgrades along much faster.