Tag Archive | Ubuntu

Testing SD Cards with Linux

While on holiday recently, my wife bought a 32GB micro-SD card, which she intended to use in her tablet.  Since then, it has been giving various errors, so I thought I should take it and verify its quality.

In order to test the card, we’re going to run three tests:

  1. Access Speed, to assess the card Speed Class.
  2. Drive Size, to assess if the reported size matches the actual size.
  3. Data durability. to assess that data written can be read back reliably.

Read More…

Store Files on your Android Phone with Linux

Take your files on the go with Android and Linux.  In this howto, I’ll show you how to easily attach your phone or tablet to your Linux PC and transfer files.

Read More…

Home Theater Raspberry Pi

Enclosure - Raspberry Pi by SparkFunElectronics

Enclosure – Raspberry Pi by SparkFunElectronics

So in Part One, we took an old external had drive, and added it as storage to a Raspberry Pi.  In Part Two, we took that Raspberry Pi and shared the new folders on the local network.  In this final tutorial, I’ll show what all of this has been for, and show you how to create your own Home Theater Raspberry Pi.

Read More…

How to Share a Folder on Raspberry Pi

File Folders by One Way Stock

File Folders by One Way Stock

In part one of our tutorial, we discussed how to mount an external hard drive or USB drive on to our Raspberry Pi (or any other Linux based) computer. In this tutorial we will discuss how to share folders from that computer to your local network. I am doing this so I can share the media files I have on my external hard drive, and access them from many places on my network, such as my laptop, my android phone, and my Raspberry Pi running XBMC. You can use this tutorial to share files in a similar way.

Read More…

How to Mount USB Disks on Raspberry Pi

Hard disk dissection by Roberto F.

Hard disk dissection by Roberto F.

I’ve got a Raspberry Pi, and I’ve got an old external hard drive. So what can I do with them? I decided I was going to create a networked shared drive from them, so in this first tutorial, I will show you how to mount the drive on a Linux operating system.  Doing this is easy, but can get a little tricky when you attach and remove drives on the fly.

Read More…

Handling Shell Script Interrupts

A Real Screen Shot

A Real Screen Shot

If you do much shell scripting, then handling shell interrupts is something you should consider.  As a user is interacting with your script, they may decide to interrupt it by typing Ctrl-C, for example.  Typically this will interrupt your shell script execution, forcing it to exit.

Depending on what your shell script is doing, this could leave behind temporary files, or leave other files in a broken state.  It would be useful if you could trap the interrupt, and handle it safely, before exiting the script.
This can be achieved on most shells using the ‘trap’ command.  The trap command takes the following syntax:

trap [OPTIONS] [[ARG] SIGSPEC ... ]

The ARG is the command to be executed on signal delivery, while SIGSPEC is the name of the signal(s) to trap.  Options include -h for help, -l to list signal names, or -p to print all defined signal handlers.

For example, to always return a ‘user aborted’ error code, the following line in your script could be used.  Whatever value given to $exit_user_abort would be returned.

trap 'echo "`basename $0`: Ouch! User Aborted." 1>&2; exit $exit_user_abort' 1 2 15

The numbers 1, 2 and 15 at the end of this example define which interrupts we’re interested in trapping.  These numbers correspond to different kinds of interrupts.  A short list is given here, but you can use ‘trap -l’ for a complete list.

Signal Number Signal Name Explanation
0 EXIT exit command. Script has executed successfully.
1 HUP Hang Up. The user session has disconnected.
2 INT Interrupt.  Ctrl-C (or other shell interrupt signal) has been given.
3 QUIT Quit.  Ctrl-\ (or other shell quit signal) has been given.
6 ABRT Abort signal.
15 TERM Terminate.  Kill command has been issued against your script.

If your trap runs several commands, it’s possibly neater to call a shell function than list the commands in-line, as above.  For example:

trap funcname 1 2 15

# Function to handle interrupts
echo "`basename $0`: Ouch! User Aborted." 1>&2
exit $exit_user_abort

Automatically Unmount Network Shares on Ubuntu

Hard disk dissection

Hard disk dissection

I’ve mentioned before, how I mount shared drives in Ubuntu both at home and at work.  While this is quite useful, it seems the default setup for Ubuntu stops the network interface before disconnecting these drives.  This results in Ubuntu hanging for a while on shutdown while these drives time out.  After the jump we describe how to solve this problem.

Read More…


Get every new post delivered to your Inbox.

Join 369 other followers

%d bloggers like this: