FINALLY! SOME UPDATES! This website is being reconstructed. Some content will go away soon. If you want to see my new stuff, visit my github: https://github.com/jrcharney/.

June 24, 2012

The Odd Couple of Disks

Today we go diving into an old disk for treasures left on the old disks.

Until a couple of years ago, my main computer was a custom built rig made from parts either bought at the local electronics store or eBay. I should warn you that unless you plan to buy peripherals or an entire system, don't buy motherboards and chipsets off of eBay. The performance was more sluggish than advertised and in the end, the "magic smoke" put my machine out of order.

So you could probably see how important it is for me to find a job that provides an income to re-establish the more important parts of the machine. The most expensive parts on the computer will always be the monitor, the graphics card (GPU), the motherboard (MoBo), and the Central Processing Unit (CPU). Since the first two of these items I still have and work perfectly, the last two are still in limbo in terms of financial planning is concerned.

So for now, I roll in this netbook. But there are some upsides to the netbook (when it's not being used as the primary computer, obviously). The nimble capabilities allow for today's hack to work.

I have my old hard disk, a USB 2.0 to IDE/SATA Adapter Kit, and my netbook.

The netbook is a 32-bit Ubuntu Linux system that uses an Intel processor. The old hard disk was used on a X86_64 Fedora Linux system that used an AMD64 processor. Let's call this set up The Odd Couple. We'll call my netbook's user oscar and my old harddrive's user felix.

Suppose Felix asked Oscar to fetch some old photos from the harddrive of a computer Oscar accidently broke one morning. Both gentlemen use Linux but like their personalities, their computers are asimilar like I mentioned earlier.

Oscar starts out by hooking up the old harddrive to his Bytecc USB 2.0 Drive Mate (you might use a different device). He plugs the power supply into the power strip. He connects the hard disk to the device. And he plugs in the devices USB plug into his computer.

Everything is working like Oscar intended. Or so he thought. While his Ubuntu system scanned the disk and found a partition with the disk he wanted, it was the other disk's boot partition. This would be completely useless to his friend Felix. So Oscar looks to see if there are any other partitions on the harddrive.

oscar@madison:~$ sudo fdisk -l
[sudo] password for oscar:

Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b3030

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   970631167   485314560   83  Linux
/dev/sda2       970633214   976771071     3068929    5  Extended
/dev/sda5       970633216   976771071     3068928   82  Linux swap / Solaris

Disk /dev/sdb: 200.0 GB, 200049647616 bytes
255 heads, 63 sectors/track, 24321 cylinders, total 390721968 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xba44ba44

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63      208844      104391   83  Linux
/dev/sdb2          208845   390716864   195254010   8e  Linux LVM
oscar@madison:~$ 

From this we can see the mounted partitions on Oscar's harddrive (all the /dev/sda* devices) and on Felix's disk (all the /dev/sdb*)

Oscar think's he has this in the bag. So he mounts the other partition on Felix's harddrive to a new directory.

oscar@madison:~$ sudo mkdir /media/felixdisk
oscar@madison:~$ sudo mount /dev/sdb2 /media/felixdisk
mount: unknown filesystem type 'LVM2_memember'

Again, what could have happened? Oscar did everything right, but he still hasn't recovered his neat friend's photos for the newspaper.

It then dawns on him, that is friend Felix uses Fedora. And Redhat-based Linux distributions use LVM2 (Linux Volume Manager 2) to mount logical volumes. Fortunately, for Oscar all he has to do is type in the following command to install LVM2 on his computer.

$ sudo apt-get install lvm2

Once that is installed, as well as any other software LVM2 needs to work, Felix is ready to roll again. He uses the following commands.

oscar@madison:~$ sudo vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2
oscar@madison:~$ sudo lvs
  LV       VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi--- 184.22g                                      
  LogVol01 VolGroup00 -wi---   1.94g
oscar@madison:~$ sudo modprobe dm-mod
oscar@madison:~$ sudo vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup00" using metadata type lvm2
oscar@madison:~$ sudo vgchange -ay VolGroup00
  2 logical volume(s) in volume group "VolGroup00" are now active

Oscar thinks that he's ready now. So he tries his mount command again.

oscar@madison:~$ sudo mount /dev/sdb2 /media/felixdisk
mount: unknown filesystem type 'LVM2_memember'

After all that, Oscar wonders what he did wrong. When mounting a LVM2, you need to mount according to the Logical Volume path.

sudo mount /dev/VolGroup00/LogVol00 /media/felixdisk

Eureka! Felix's disk is now mounted on Oscar's computer. In fact, there is a disk icon on Oscar's computer that has an "LV" icon on it. Oscar clicks on the icon and the window explorer program show Felix's root directory. He clicks on the home folder, then he clicks on Felix's home directory felix. And just when Oscar thinks he's got things taken care of, he gets an error message stating he cannot access the folder.

A trip through the harddrive using some ls -l commands confirms Oscar cannot access the folder because he doesn't have access to it.

oscar@madison:~$ cd /media/felixdisk/home
oscar@madison:/media/felixdisk/home$ ls -la
total 40
drwxr-xr-x.   3 root    root     4096 Apr 19  2010 .
dr-xr-xr-x.  27 root    root     4096 Nov 19  2010 ..
drwx------. 143 500     500     20480 Nov 10  2010 felix

Just about everywhere there is a 500, there would be a felix if Felix was using a Debian-based Linux distribution instead of a Redhat-based distribution. The best way for Oscar to fix this is to change the permission of each folder or file he needed to inspect.

oscar@madison:/media/felixdisk/home$ sudo chown oscar felix
oscar@madison:/media/felixdisk/home$ sudo chgrp oscar felix
oscar@madison:/media/felixdisk/home$ ls -la
total 40
drwxr-xr-x.   3 root    root     4096 Apr 19  2010 .
dr-xr-xr-x.  27 root    root     4096 Nov 19  2010 ..
drwx------. 143 oscar   oscar   20480 Nov 10  2010 felix

Of course, everytime Oscar dives deeper into Felix's harddrive, he'll need to use those chown and chgrp commands. He might also need to use chmod for command, but for now let's continue our story.

Oscar has saved Felix's skin by recovering Felix's work. It's now time to dismount the harddrive.

When you use a mount command, you will almost certainly need to use an umount (Note: no "n" after the first "u"). The changes made to Felix's harddrive should still be there, but Oscar is too lazy to change them back.

oscar@madison:/media/felixdisk/home$ cd ~
oscar@madison:~$ sudo umount /media/felixdisk

Of course, you will still need to "Safely remove" any disk that are still mounted on you device by right clicking on their icons and selecting "Safely Remove".

June 19, 2012

Projects Page v2.0

I think I've shared enough programs on this website to finally define my portfolio. But I'm not finished yet. I have more than a bunch of Bash shell scripts to offer.

Eventually, I'd like to upload some executable programs composed in C or C++, maybe even Java if I can find the interest to Java again.

I like using C and C++. Like Perl, Bash and PHP, the C and C++ languages are straightforward. You don't need to buy twelve different books on various things made for Java like Hibernate or Spring, which I may have mentioned previously.

From what I've learned recently, Objective-C and Objective-C++ are of interest. (Note I said OBJECTIVE-C, not C#). Objective-C claims to have made the pointers in C/C++ foolproof. If that is so, I will need to make a third version of my new_c.sh script.

At the moment, I'm still working on new_c.sh version 2.0, which I have been working on the past week and have made some significant breakthroughs. This script is so good, I wish I had a time machine to give this thing to myself over decade ago when I was just getting into C++ and Object-Oriented Programming.

June has been a very productive month at this website. Hopefully it will end with me working at a job where I can apply my knowledge.

In the meantime, projects are being completed. New projects are being started. And everyday I feel like I am one step closer to success.

Good things are coming soon. I can feel it!

June 16, 2012

Link List is now on.

Not as fancy as the Todo List widget, but the Link List Widget is now active. It mostly consists of previous links mentioned in this blog but the construction of the list is pretty simple. Eventually, links will show up according to a related tag.

Meanwhile SQL tables are being set up.

To fill some space on this blog, here's a short command line script whiped up to list all the directories in a directory.

#!/bin/bash
# File: lsdir.sh
# Info: List directories only.
ls -1F --color=always $1 | sed -n '/\//p' - | less -eFMXR

The less command is optional, as is the color attribute for the ls command.

If you want to list only directories you could add an exclamation point just before the p in the sed command.

#!/bin/bash
# File: lsfiles.sh
# Info: List everything except directories.
ls -1F --color=always $1 | sed -n '/\//!p' - | less -eFMXR

ls does have a --group-directories-first feature that does list the directories first even if you use ls's sorting or reverse-order attributes. But what if you wanted to see the directories last? There's no attribute for that, and using -r would still show the directories first only in reverse order. Enter this script.

#!/bin/bash
# File: lsdirlast.sh
# Info: List directories after listing files.
(ls -1F --color=always | sed -n '/\//!p' - ; ls -1F --color=always | sed -n '/\//p' - ) | less -eFMXR

Wasn't that a great example to illustrate how commands are piped with the pipe (|), separated by the semicolon (;) and grouped with the parenthesis (())? If you were wondering what the hyphen was after the sed command is, it basically takes the data from the ls command and uses it as the argument where the hyphen is. Normally a file would be there. less doesn't need that. It can just take the data piped in from the previous commands and use it as the input.

That's all I want to share for the day.

June 14, 2012

JRCBlog v3.0 beta

As always, the things that are on this site are constantly evolving.

Today, I went through the past 29 blog posts made some formatting changes to comply with HTML5 standards. (You should know that <tt></tt> is no longer part of HTML. Use <code></code> instead!) I am enamored with the <figure> and <figcaption> elements. If you don't have a browser that supports these elements, get one!

From now on, all code examples will be in <iframe> elements. Most everything that is in them will be downloadable with a link just below it.

On the PHP side of things, I no longer need to manually start each of my posts with an date. I just type in my title, and my blogware, wich I am calling JRCBlog at the moment, does the rest. A list of previous posts will be in the side bar and posts can now be viewed individually. Which is great cause post can now be sharable. None of it runs on a database yet. But given I have a pretty sold structure set up in this version of my blogware there is now room for expanision when the time comes.

Pagnation is now stablized. No more pages at the end saying "Error 404" at the end of the queue of posts.

Jill Integration will happen sometime before the end of the week for my posts with <canvas> elements.

Everything written from scratch. No Smarty templates. No crazy libraries. Just straightforward results that should be easy to comprehend and do what needs to be done.

Overall, I feel pretty good about what I've done today. I just wish I had a better computer with a larger screen so that I can make some real magic happen. Especially with all this WebGL stuff that is going on. It's funny, I could run a small 3D OpenGL program that does basically nothing, but the same Intel chipset this computer uses doesn't do WebGL. It loves to bottleneck up for 10 minutes doing I don't-know-what in the background while I am writing a program, but ask it to play a video on YouTube and it will do it but in a bit choppy manner.

So the Paypal button is back on. To anyone I know who objected to me posting it, perhaps when you have no job and run out of money in the middle of the month and no employer wants to hire you promptly in the same fashion that employers demand that you meet their work deadlines, you'll understand why I put the Paypal button on my page...again.

But enough of such critical responses. I think I've accumulated enough links on my site to start putting items into the link list widget. Which, by the way, enjoy the new previous posts widget.

June 10, 2012

Listen to the Music

So after the success of yesterday's tmux install, I've been thinking about figuring out how to play Last.FM remotely.

Now, I can't argue with the finesse of the Last.FM app for Android. Especially for tablets. It's one of my favorite apps and I use it often when I'm on the bus or riding my bike. (Wireless Headphones for the win!) Shell.FM is a good program for netbook users, even with the bug involving scrobbling, the process of which Last.FM finds new music that is of interest to the listener. It took me a while to get Shell-FM to be set up and I nearly gave up. But LinuxFromScratch.org helped finally make it happen.

While I installed the required and suggested software like libmad, libao, CMake, and TagLib for local directories, the thing that apparently tripped me up every time was that libmad didn't create a pkgconfig file in the /lib/pkgconfig directory.

So after all that hassle, here's the script to get all of that installed and working.

Download this file!

Run it as follows.

$ chmod u+x install_shellfm.sh
$ ./shellfm.sh			# See the caption below.
$ shell-fm			# See the note below this figure.
Don't forget to make changes to the script before running it!

You'll probably need to run shell-fm once then exit with CTRL+C before you really start using it so that the ~/.shell-fm directory is established so that you can write ~/.shell-fm/shell-fm.rc. An example of that file is listed below.

username = yourusername
password = yourpassword
default-radio = lastfm://user/yourusername
An example of ~/.shell-fm/shell-fm.rc

Here's also the script from a couple of weeks ago for using shell-fm called lastfm

Download this file!

And here's an alias shortcut to create to use the lastfm script

alias lastfm='~/lastfm'
Add this alias command to ~/.bash_profile, also.

Of course, don't forget to rename that file and change the permissions before you add the alias.

At this point, everything is all set. Let's light this rocket!

$ ./lastfm 
Shell.FM v0.8, (C) 2006-2010 by Jonas Kramer
Published under the terms of the GNU General Public License (GPL).

Press ? for help.

Receiving ______'s Library Radio.
Now playing "Nursehellamentary" by Nursehella.
Unable to find any usable output device!
Playback stopped with an error.
Try to press Q next time you want to quit.
Well, you can't win them all.

So I guess the SSH server does have any device to forward output audio to the computer locally. This is still and issue yet to resolve. But over all, everything works like it should. I'm glad it works. I just need to forward the output device to my computer, if that is possible. (It should be possible.)

Before I wrap things up, I want to mention a couple of important items that may be helpful in the future.

Firstly, when you use tmux, you can scroll back lines using CTRL+B PGUP and use the arrow keys and PGUP and PGDN to scroll back through past window history. To leave this "scroll mode", just press ESC. This is ideal if you have split screens, if you've installed something and want to see the entire log, or if you need to scroll back and see what went wrong with a program you compiled.

The other item is just to show the ideal method of installing things from source. Generally this is done on separate lines, but if you have wget, tar, gzip, bzip2 and make, in a perfect situation all you would have to do is

cd ~/temp
wget http://www.example.com/software-1.1.1.tar.gz && tar xvzf software-1.1.1.tar.gz
cd software-1.1.1
./configure && make && make install

However, as we have seen yesterday and in this post, it is not so simple especially if you need to set things up differently from the default method. The best software is designed the special cases. It's why there is a big trend in installing software on a remote location or device and being able to use it anywhere without any obstruction and without leaving a trace. I like to call this the "camping method" as when you go camping you should always leave you campsite as clean, if not cleaner, when you are done using it.

Tags

Under Construction