Raspberry Pi tip: mount Raspbmc images

The problem

When you download a Raspmc (Raspberry Pi Media Center) image it’s a .zip file.
If you want to check the content of the file you must find a way to mount the image.

Prerequisites

  • a pc with GNU/Linux
  • a user with root permissions on the pc
  • the image you want to analyze (download from the site)

Procedure

  1. first of all unzip the archive$ unzip installer.zip
  2. you’ll notice one file: installer.img that’s an image of a block device:$ file installer.img
    installer.img: x86 boot sector; partition 1: ID=0xc, starthead 0, startsector 2048, 131072 sectors; partition 2: ID=0x83, starthead 3, startsector 133120, 251904 sectors, code offset 0xb8
  3. create a mount point$ mkdir /tmp/mnt-installer
  4. if your “file” output gives you less informations, you can examine the image structure (sizes in Sectors) with the following command$ sfdisk -uS -l installer.img
    Disk installer.img: cannot get geometry
    Disk installer.img: 24 cylinders, 255 heads, 63 sectors/track
    Warning: The partition table looks like it was made
    for C/H/S=*/4/32 (instead of 24/255/63).
    For this listing I'll assume that geometry.
    Units = sectors of 512 bytes, counting from 0
    Device Boot Start End #sectors Id System
    installer.img1 2048 133119 131072 c W95 FAT32 (LBA)
    installer.img2 133120 385023 251904 83 Linux
    installer.img3 0 - 0 0 Empty
    installer.img4 0 - 0 0 Empty
  5. take a note of what you want to mount, i.e. img2 (Linux filesystem) as I highlighted
  6. with root permissions, mount the desired partition on the previous created path (133120 is the Start sector taken from the last output)$ sudo mount -o loop,offset=$(( 512 * 133120)) installer.img /tmp/mnt-installer
  7. check the content$ ls -lAtr /tmp/mnt-installer
    total 96
    drwxr-xr-x 2 root root 4096 Jul 21 2010 selinux
    drwxr-xr-x 2 root root 4096 Mar 27 23:44 sys
    drwxr-xr-x 2 root root 4096 May 7 17:28 proc
    drwxr-xr-x 2 root root 4096 May 7 17:28 mnt
    drwxr-xr-x 2 root root 4096 May 7 17:28 home
    drwxr-xr-x 2 root root 4096 May 7 17:28 boot
    drwx------ 2 root root 16384 Jun 18 02:26 lost+found
    drwx------ 2 root root 4096 Jun 18 02:27 root
    drwxr-xr-x 2 root root 4096 Jun 18 02:27 srv
    drwxr-xr-x 2 root root 4096 Jun 18 02:27 opt
    drwxr-xr-x 2 root root 4096 Jun 18 02:27 media
    drwxr-xr-x 13 root root 4096 Jun 18 02:27 var
    drwxr-xr-x 10 root root 4096 Jun 18 02:27 usr
    drwxrwxrwt 2 root root 4096 Jun 18 02:27 tmp
    drwxr-xr-x 2 root root 4096 Jun 18 02:31 sbin
    drwxr-xr-x 9 root root 12288 Jun 18 02:31 lib
    drwxr-xr-x 43 root root 4096 Jun 18 02:31 etc
    drwxr-xr-x 2 root root 4096 Jun 18 02:31 bin
    drwxr-xr-x 4 root root 4096 Jun 18 02:31 dev
  8. when you have done, unmount the filesystem$ sudo umount /tmp/mnt-installer

Raspberry Pi tip: you can use your old CRT TV as a monitor

Maybe you don’t know, but you can use an old CRT TV as a monitor for the Raspberry Pi.
Find a SCART and some cables for audio and video and you are done.

You need:

  1. a cable for the video: it’s a cable with the same type of audio/video plug in each end. The standard color is yellow.
  2. a cable for the audio: in this case you must have an end with a 3.5mm stereo audio plug and the other one with 2 audio/video plugs. The standard colors are red and white.
  3. a SCART adapter suitable for input with audio/video

Than you have to connect the cables as you can easily imagine.
The only thing to keep in mind is to set the SCART adapter to “INPUT”:

The trick does not need any additional work if you use a NTSC TV.

If you are in Europe and you use PAL systems (like me), you must create a config file in the /boot/ path of the Raspberry Pi while it’s running and configure the appropriate parameter.
vi /boot/config.txt
# Set stdv mode to PAL (as used in Europe)
sdtv_mode=2
#
overscan_left=20
overscan_right=20
overscan_top=20
overscan_bottom=20

Overscan parameters allow you to set a proper margin if you see that the image is not centered.

The end.

Raspberry Pi Debian tip: enable ssh on boot

That’s an extremely easy tip.

I own a Raspberry Pi, but I haven’t a HDMI enabled TV, so I thought I couldn’t see any output from the system.

Stock Debian image doesn’t start ssh daemon on boot, but as you can see on the SD card, there’s a file named “boot_enable_ssh.rc”.

You should rename that file in “boot.rc”, and start everything. That’s all.

Now you must know that if you haven’t a HDMI enabled TV or monitor, you can still use Video OUT and an old CRT TV to see what’s going on. See my future tip.

Raspberry Pi tip: resize your sd card

When you download an image for Raspberry Pi from internet (Debian image for example), the size is quite often 2GB.

In my case I’ve always SD cards of 8GB of size. After writing the image to the SD, 6GB of space get lost.

Here’s what I did to resize my Raspberry Pi Debian system without loosing its functionality.

Prerequisites

  • a sd card with Debian for Raspberry Pi installed (or similar)
  • a pc powered by Ubuntu Linux
  • GParted installed

Identify SD card

Plug your card reader and take a look to system messages with “dmesg”:
$ dmesg
[22006.536054] usb 1-1: new high-speed USB device number 3 using ehci_hcd
[22006.736355] usb-storage 1-1:1.0: Quirks match for vid 090c pid 6000: 100000
[22006.738687] scsi15 : usb-storage 1-1:1.0
[22007.737879] scsi 15:0:0:0: Direct-Access Generic 6000 PQ: 0 ANSI: 0 CCS
[22007.739762] sd 15:0:0:0: Attached scsi generic sg3 type 0
[22007.744742] sd 15:0:0:0: [sdc] 16659456 512-byte logical blocks: (8.52 GB/7.94 GiB)
[22007.745494] sd 15:0:0:0: [sdc] Write Protect is off
[22007.745500] sd 15:0:0:0: [sdc] Mode Sense: 4b 00 00 08
[22007.746235] sd 15:0:0:0: [sdc] No Caching mode page present
[22007.746240] sd 15:0:0:0: [sdc] Assuming drive cache: write through
[22007.750365] sd 15:0:0:0: [sdc] No Caching mode page present
[22007.750372] sd 15:0:0:0: [sdc] Assuming drive cache: write through
[22007.757039] sdc: sdc1 sdc2
[22007.760977] sd 15:0:0:0: [sdc] No Caching mode page present
[22007.760984] sd 15:0:0:0: [sdc] Assuming drive cache: write through
[22007.760989] sd 15:0:0:0: [sdc] Attached SCSI removable disk

In my case the SD is /dev/sdc.

Start GParted

Choose the right device with the top right selector:

Proceed with these steps:

  1. right click on all the partitions and umount them all
  2. move the swap partition to the very end of the sd (right side of the bar)
  3. resize the ext4 partition (sdc2)
  4. commit the changes

On my pc it took 2 minutes.

You’re done.