Archive for July, 2009

fsck.ext3: Bad magic number in super-block

So, every so often after upgrading my Ubuntu server, I occasionally get an error during boot, saying the following:

fsck.ext3: Superblock invalid, trying backup blocks…

fsck.ext3: Bad magic number in super-block while trying to open /dev/sdc1

fsck died with exit code 8

After some rooting around, it turns out to be an error on my part. It is all down to my /etc/fstab file (a text file which tells Ubuntu how and where to mount all the hard drives in your system). A while ago, Ubuntu changed the way it records drives details, whereas it use to use /dev/sdX to refer to a drive (with X being a-z) it now uses UUIDs instead. These are unique ID numbers that the system gives to a drive. It changed from /dev/sdX to UUID since occasionally the sdX number would change upon a reboot.

This was exactly what was happening to me. In my fstab file I used /dev/sdc1 to refer to one USB hard drive, and a UUID to refer to another. fstab correctly mounted the UUID drive, but the /dev/sdc1 had changed from the original USB drive it referred to, to the same USB drive that I mounted via the UUID number, thus it failed to mount. When fsck (Ubuntu’s file checking program) runs, it uses fstab to find out info about the hard drives you have. If you have a situation like mine where two entries where referring to the same hard drive, fsck freaks out and dies, thus the error.

To fix this, you need to edit your fstab. Now, if you are lucky, you can simply type EXIT at the prompt you get when this error occurs and the system will boot up. If not, I’d recommend using an Ubuntu LiveCD to boot up the system and then edit your fstab file.

So, open /etc/fstab in a text editor, make sure you use a user with the correct privileges to do this. Then, open a command prompt and type

sudo fdisk -l

This will list all your hard drives, allowing you to identify them. Next, type:

sudo blkid

This will list all your hard drives and their UUID numbers.

Using the info from the first command, fdisk and the UUID number from the second command, blkid, you can work out which device has which UUID number. Then make sure in your /etc/fstab file, you refer to devices using UUID=XXXXXXXXXXXXXXX instead of /dev/sdXX.

This way, your disks will always mount correctly and you shouldn’t get anymore fsck errors on boot, well until your hard drive dies lol!

Wednesday, July 15th, 2009 Linux, Operating Systems 2 Comments

Bash and Windows batch script file name variable conversion

I’ve been getting into Bash and Windows Batch scripting recently (as part of my ongoing battle to get my HTPC working correctly with MediaPortal).

One problem I kept on coming across was how to pass different variations of the variable you pass to your script, sometimes I wanted the full path to the file, other times I just wanted the filename with the file extension, other times I wanted just the folder the file was located in.

It took a fair bit of googling and experimentation with terms to find the right information, so I have decided to amass it all here to help others (and me).

For Bash Scripting

(taken from linuxgazette)

    Given:

      foo=/tmp/my.dir/filename.tar.gz
    We can use these expressions:
    path = ${foo%/*}
    To get: /tmp/my.dir (like dirname)
    file = ${foo##*/}
    To get: filename.tar.gz (like basename)
    base = ${file%%.*}
    To get: filename
    ext = ${file#*.}
    To get: tar.gz

For Windows Batch Scripting

(taken from imagemagick)

%~1 expands %1 removing any surrounding quotes (“)
%~f1 expands %1 to a fully qualified path name
%~d1 expands %1 to a drive letter only
%~p1 expands %1 to a path only
%~n1 expands %1 to a file name only
%~x1 expands %1 to a file extension only

These two pieces of info can thus be used to pass any variable or variation of that variable to a command in your script.

Using these tools I have been able to get MediaPortal to automatically scan each new recording for adverts using comskip and then transfer the recording, alongside the necessary advert info files to my network hard drive on my server using a batch script. Then the server runs a bash script each morning to scan for new files on the new recordings file, convert them to MKV using Handbrake and add chapter markers and then move the MKV files to my networked videos file. Cool!

Wednesday, July 15th, 2009 Scripts 2 Comments

What Google Chrome OS Is and Isn’t

OK, first off, Google Chrome will not be a replacement for Windows, MacOS or any of the major Linux variants.

It will be one thing and one thing only, a beautifully quick and simple Web Browsing Platform. It will load in seconds and present you with the Chrome Browser, allowing you to access the web and all the Web Services that are out there in no time at all. Being installed on your own hardware means that you have the added bonus of local storage, allowing you to work offline when you have no internet access.

Google Chrome OS

Google Chrome OS

It will no doubt feature a version of Google Gears, so you will be able to run Gmail, Picasa, Google Docs, Google Spreadsheet and maybe even some variant of Google Maps offline. It will work in the same way that Chrome does, separating all running programs from the underlying Kernel, ensuring that viruses and malware simply can’t infect the base system. It will allow you to install Google Gadget-type applications only, it wont allow you to run many other apps, since that is not what it is designed for (unless those apps are modified to work as a Desktop Gadget) – we will no doubt see a massive fight to develop a Google Desktop Gadget Wrapper allowing you to run Windows, MacOS and Linux apps (these things will be like a Gadget version of Wine on Linux).

It will ofcourse intergrate with Google Search, allowing you to easily visualise all your locally stored content, to find anything quickly (as such you might not even need a file system as we know it with a folder heirachy, since every item will be pre-tagged and easily accessbile via a nice simple tag/timeline/type UI. It will also intergrate with on-line storage, allowing you to remotely store your settings and apps, so you can log into your Chrome OS account from any H/W that has Chrome OS installed on it. On-line storage of all your local content will be available in a professional version for a monthly fee, allowing you to access your locally stored content from any Chrome OS.

A lot of people will be disappointed that they can’t load the apps they are use to and they can’t get certain peripherals to work initially. But then these people are missing the point of Chrome OS. It is an alternative to Windows and the others, for those that live their life on-line, need quick access to Gmail, Twitter, Facebook and more and don’t use normal off-line applications.

Being Open Source, a million and one variants of the Chrome OS will begin in ernest, some trying to merge it with Ubuntu, others trying to add a Windows compatibility layer via Wine. Many of these will die within the first ten months, a few with some clever ideas will keep going.

Just expect there to be lots of moaning and whining from early adopters who don’t understand what it is all about, but expect Google to produce an amazingly stable, fast platform allowing you to browse the web and be very very impressed.

Tuesday, July 14th, 2009 Operating Systems 1 Comment

Search

 
If you like what you read, please donate via PayPal;)

Support Me

Get a free Giffgaff Sim

Sponsors

Sponsors