Recently I ran into an issue with my Raspberry Pi. It was not accessible over the network and the HDMI output showed no signal, too. The power LED on the RPi was lit, however the green LED showing SD card activity was not blinking when power was attached.
On my RPi I was running the Debian varian Raspian however it failed to boot. So I fired up a Debian PC and looked into the SD card. On the SD card there are two partitions as shown by
Disk /dev/sdg: 15.8 GB, 15811476992 bytes
64 heads, 32 sectors/track, 15078 cylinders, total 30881791 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: 0x000c7b31
Device Boot Start End Blocks Id System
/dev/sdg1 8192 122879 57344 c W95 FAT32 (LBA)
/dev/sdg2 122880 30881791 15379456 83 Linux
First, a small 8 MB FAT32 partition which stores the bootloader and the kernel image and then a larger ext4 partition which is expanded on installation to fill up the remaining space on the SD card (mine was 16 GB large).
Fine, so let us try to mount the second partition to recover some data:
mount -t ext4 -o ro /dev/sdg2 /media/sd but without luck, this was the output:
mount: wrong fs type, bad option, bad superblock on /dev/sdg2,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
I did was I was told to do and checked the kernel logs using
dmesg | tail. The last entry showed something interesting:
[ 707.493811] EXT4-fs (sdg2): bad geometry: block count 3844864 exceeds size of device (3844863 blocks)
Hmm, something is wrong with the partition, so let us run good old
fsck /dev/sdg2 but this rose an error, too:
fsck from util-linux 2.20.1
e2fsck 1.42.5 (29-Jul-2012)
/dev/sdg2: recovering journal
The filesystem size (according to the superblock) is 3844864 blocks
The physical size of the device is 3844863 blocks
Either the superblock or the partition table is likely to be corrupt!
So the partition is corrupt, or at least the super block as it reports the wrong size. So maybe we can resize the partition instead using
resize2fs /dev/sdg2 which gave the promising output:
resize2fs 1.42.5 (29-Jul-2012)
Resizing the filesystem on /dev/sdg2 to 3844863 (4k) blocks.
The filesystem on /dev/sdg2 is now 3844863 blocks long.
After this I was able to mount the partition using
mount -o ro /dev/sdg2 /media/sd. I unmounted it and reran
fsck /dev/sdg2 on it which found some orphaned nodes and repaired it. I could then reinsert the card into my RPi and it booted and worked!
Please note: Your milage may vary as it cannot be made sure that data integrity is still OK. This would be possible with checksummed file systems like ZFS or buttrfs. It is always a good idea to have a backup.
The Aim After using my computing equipment for some time my desk got filled with 3 external hard drives containing backups and archived data such as videos, photos. Even worse these drives spin down after a while resulting in a 6 second lag when opening a file open or save panel. Furthermore the use of […]
The Aim Sometimes it is necessary to share files from a POSIX operating system (Linux, FreeBSD, etc.) with Windows computers via the network. For this task Samba is the powerful interoperability suite which can handle this task. To distinguish between these two systems I will differentiate between POSIX (that is the samba server) and Windows […]
When interacting with different services or program there often comes the point where some sort of file has to be parsed into a data structure, which can be processed later. For standard file formats like XML or JSON parsers are available for almost any language out there. (BTW I love the graphical representation of the […]
After a hardware failure of a Linux computer I took the chance to set up a Debian installation from scratch. So I saved the data that was important to a server, burned the Debian DVD and installed it on the computer. When it came to networking it got a little more complicated: as the server […]
The rise of mobile electronic devices, which need internet access has changed the demand we have on our home networks. The days are over where one had a single computer connected with a wire to the broad-band internet modem. WLANs became very popular because network client became more mobile. It started with the notebooks with […]
Seit gestern ist es draussen, das neue Mac OS 10.7 Lion. Das erste Release, dass nur noch online zu beziehen ist. Auf der einen Seite ist das sicherlich positiv, allerdings wenn man eine nicht sooo breitbandige Internetverbindung hat, kann der Download zur Geduldsprobe werden. Ich werde in einer kleinen Serie von Beiträgen berichten, wie die […]
Am zweiten Tag der Google I/O 2011 wurden in der Keynote einige Neuerungen in Googles Chrome Browser und in Chrome OS vorgestellt. Der Unterschied zwischen diesen beiden besteht darin, daß es sich bei Chrome OS um ein komplettes Betriebssystem handelt, in nur eine Applikation läuft: ein Chrome Browser. Um noch einen weiteren ähnlichen Namen hinzuzufügen […]
Colors schemes for text editors is just like the favorite editor itself a controversially discussed and often very personal matter. Speaking about colors often the personal taste is the main reason for a custom color scheme or why a special scheme was chosen. However the relation between different colors has been studied by artists for […]
Motivation When deploying a server on the internet you always have to deal with security issues. You harden your server by setting up encrypted connections, configuring a tight firewall and putting critical services in a chroot jail. However what happens if an intruder hacks into your server and deletes your content? Or if you make […]