Raspbian hangs on upgrade

Problem

I tried to upgrade Raspbian using these commands:

$ sudo apt-get update
$ sudo apt-get upgrade

After the update, the upgrade downloaded and installed many packages, but hung with this last output:

Setting up xdg-utils (1.1.0~rc1+git20111210-6+deb7u3) ...
Setting up xserver-common (2:1.12.4-6+deb7u6) ...
Setting up xserver-xorg-core (2:1.12.4-6+deb7u6) ...
Setting up raspberrypi-bootloader (1.20150421-1) ...
Removing 'diversion of /boot/COPYING.linux to /usr/share/rpikernelhack/COPYING.linux by rpikernelhack'

Solution

On examining other processes running on this Raspberry Pi, I noticed Transmission. I tried to stop its daemon using:

$ sudo service transmission-daemon stop

It stopped, but its zombie process still hung around and could not be killed.

So, I tried to restart the Raspberry Pi using:

$ sudo shutdown -r now

It did not restart! Finally, I switched off the power and turned it back on.

As soon as I could SSH into it, I stopped Transmission, which worked this time.

I was able to finish the interrupted upgrade successfully, using this command:

$ sudo dpkg --configure -a

Tried with: Raspbian 7 (Wheezy) and Linux 3.12.35

How to setup Raspberry Pi as media server using ReadyMedia

Raspberry Pi can be setup as a media server to simultaneously stream videos, music and pictures to multiple devices on the home wireless network. ReadyMedia (formerly known as MiniDLNA) is a simple media server that can be used to achieve this.

  • Install Raspbian to the Pi, as described here.

  • Connect and mount the hard disk containing the content to the USB port of the Pi. Let us assume the partition with the content is mounted at /media/usb0.

  • SSH into the Pi and install the ReadyMedia server:

$ sudo apt-get install minidlna
  • Open the file /etc/minidlna.conf and edit the following entries.

  • Set the video, music and pictures directories. For example:

media_dir=V,/media/usb0/videos
media_dir=A,/media/usb0/music
media_dir=P,/media/usb0/pictures
  • If you want ReadyMedia to automatically index new media files as they are added to your media directories:
inotify=yes
  • Restart the ReadyMedia server. This will index media files in your media directories and build the media database of the server:
$ sudo service minidlna force-reload
  • Open a browser on any other device on the network and open http://192.168.0.99:8200. Assuming 192.168.0.99 is the IP address of the Pi. 8200 is the default port of the ReadyMedia server. The webpage should show the number of content files in the server database.

  • You are now ready to enjoy your content on any device on the network! On Android smartphone or tablet, I like to use MediaHouse UPnP/DLNA Browser. Once open, it shows my Pi and I can browse video, audio and image content.

  • Videos can be played using any video player on your Android device. I like to use MX Player for this. Audio is played by the browser itself.

Tried with: ReadyMedia 1.0.24 and Raspbian 7

How to set static IP address in Raspbian

I assume that Raspbian has been assigned an IP address automatically by your home wireless router using DHCP. To set a static IP address for it:

  • Run ifconfig. Note the interface (say eth0) and the values of the inet addr, Bcast and Mask entries.

  • Run netstat -nr. Note down the values of the Gateway and Destination entries.

  • Open the /etc/dhcpcd.conf file in an editor.

  • Find the commented lines starting with “Example static IP configuration”. Uncomment the lines concerned with interface, ip_address and router and fill in your details there. For example:

interface eth0
static ip_address=192.168.0.99/24
static routers=192.168.0.1
  • You will also need to set the DNS servers manually, as described here.

  • Reboot the system and it should have the static IP address you assigned.

Tried with: Raspbian 9

How to find version of Debian or Raspbian

Raspbian is based on Debian, so the distribution version information for both is stored in the same file: /etc/os-release.

Here is what I got on my Raspbian 9 (Stretch):

$ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

How to install Raspbian 7

20150123_raspbian

Raspbian is a Debian distribution for the Raspberry Pi. Installing it to the Pi is easy:

  • Download the latest Raspbian disk image from here. Unzip the .img file from the downloaded zip file.

  • Insert a SD card of at least 4GB capacity into your computer. Write the downloaded disk image to it, as described here.

  • Insert this SD card into the Pi board. Connect your Pi and your home wireless router with a Ethernet cable. Power on the Pi.

  • Go to the Admin webpage of your wireless router and figure out what IP address has been assigned to your Pi. Let us assume it is assigned 192.168.0.99.

  • SSH into your Pi using the command ssh pi@192.168.0.99. The default password is raspberry.

  • Run sudo raspi-config and choose to Expand filesystem. This expands Raspbian to make full use of the space on your SD card. Exit the config tool and choose to reboot when it requests so.

  • Once your Pi restarts back and is connected to the home network, SSH into it again. Update the packages to the latest versions:

$ sudo apt-get update
$ sudo apt-get upgrade
  • If you want Raspbian to auto-mount USB storage devices (thumbdrives and harddisks) and NTFS partitions, then install these tools:
$ sudo apt-get install usbmount
$ sudo apt-get install ntfs-3g
  • Restart Raspbian.

You now have a Raspbian system that is ready to roar! 🙂

Tried with: Raspbian 7