The method uses a Linux computer for setting the Raspbian image on the SD card (Raspbian changes shown here could just be deferred on a headed Pi). You need the Pi, not yet powered-up, connected to your network plus an SD card + USB adapter; the latter just for interfacing the SD card to the Linux computer if it has no SD card slot.
Note: for this example method the network (192.168.0.0) has connected: a Windows computer (with PuTTY and Xming installed), raspberrypi (will be set to 192.168.0.6) and an internet gateway machine/firewall/router (192.168.0.5). A Linux computer is also needed, but it does not have to be on the 192.168.0.0 network. You will have to adapt things to suit your configuration.
Some of the window captures below may not exactly match what you now see with the latest Raspbian "wheezy" image.
Note: commands shown ($ 'command') in this section are for the Linux computer.
- Download Raspbian "wheezy" 2015-01-31-raspbian.zip to, for example, a Linux computer directory /scratch (the zip is a 976MB download and the extracted image, for the SD card, is 3.05GB). Note: the SD card needs to be 4GB or larger and not partitioned.
$ cd /scratch $ sha1sum 2015-01-31-raspbian.zip 0171e77f687c447dae32609fcc6aa700c750d6f5 2015-01-31-raspbian.zip $ unzip 2015-01-31-raspbian.zip Archive: 2015-01-31-raspbian.zip inflating: 2015-01-31-raspbian.img
- Plug your SD/adapter into the Linux computer (best to reformat the SD card first). Find the device that is your SD card
$ fdisk -l ... Device Boot Start End Blocks Id System /dev/sdc1 8192 7744511 3868160 b W95 FAT32shows a /dev/sdc1 partition, for me, and a 4GB SD card (but check really carefully you get the right device + the SD card is about to be imaged and all its original contents lost!)
$ umount /dev/sdc1 umount: /dev/sdc1: not mountedjust in case it is mounted and copy the image to the SD card (takes a while)
$ dd bs=4M if=2015-01-31-raspbian.img of=/dev/sdc 781+1 records in 781+1 records out 3276800000 bytes (3.3 GB) copied, 663.405 s, 4.9 MB/sNote: use of device: /dev/sdc, not the first partition on the device: /dev/sdc1.
$ syncto flush system buffers before removing the SD/adapter.
- You can see the Raspbian partitions on the SD card
$ parted -l ... Model: SanDisk SDDR-113 (scsi) Disk /dev/sdc: 3965MB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 4194kB 62.9MB 58.7MB primary fat16 lba 2 62.9MB 3277MB 3214MB primary ext4Note: you now have two partitions, the first '/boot' and the second '/', for the Raspbian file system.
- Unplug the SD/adapter and plug it back in again. The new partition will not mount if you don't do this.
- Mount partition /dev/sdc2 and go to the location of the first, of three, files to be changed
$ mkdir /media/external if the directory /media/external does not exist $ mount -t ext4 /dev/sdc2 /media/external $ cd /media/external/etc/networkI'm going to set the interface on the Pi to be static address: 192.168.0.6, and the internet gateway: 192.168.0.5. First edit file 'interfaces' (file changes are show in unified format: 'diff -u')
$ diff -u save_interfaces interfaces --- save_interfaces 2013-12-15 17:59:24.069999998 +0000 +++ interfaces 2013-12-17 14:52:30.831407245 +0000 @@ -1,7 +1,10 @@ auto lo iface lo inet loopback -iface eth0 inet dhcp +iface eth0 inet static +address 192.168.0.6 +netmask 255.255.255.0 +gateway 192.168.0.5 allow-hotplug wlan0 iface wlan0 inet manualAdd at least one nameserver to file /media/external/etc/resolv.conf (my gateway is also a DNS server). You can just add your ISP's DNS servers.
Change directory (i.e. up to /media/external/etc) and edit file 'resolv.conf'
$ cd .. $ diff -u save_resolv.conf resolv.conf --- save_resolv.conf 2013-12-15 17:40:46.659995278 +0000 +++ resolv.conf 2013-12-17 14:54:03.913156182 +0000 @@ -1 +1 @@ -nameserver 22.214.171.124 +nameserver 192.168.0.5Correct the host address in file 'hosts'
diff -u save_hosts hosts --- save_hosts 2013-02-09 01:24:59.380002225 +0000 +++ hosts 2013-02-12 22:38:28.731821935 +0000 @@ -5,4 +5,4 @@ ff02::1 ip6-allnodes ff02::2 ip6-allrouters -127.0.1.1 raspberrypi +192.168.0.6 raspberrypi
- Enable the ssh server (it's disabled by default). Still from directory /media/external/etc
$ for files in `find . -type l -name \*ssh`; do ls $files; done ./rc2.d/K01ssh ./rc4.d/K01ssh ./rc5.d/K01ssh ./rc3.d/K01sshthese symbolic links need to be changed. Use this as a script file
#!/bin/sh rm ./rc2.d/K01ssh rm ./rc4.d/K01ssh rm ./rc5.d/K01ssh rm ./rc3.d/K01ssh ln -s ../init.d/ssh ./rc2.d/S02ssh ln -s ../init.d/ssh ./rc4.d/S02ssh ln -s ../init.d/ssh ./rc5.d/S02ssh ln -s ../init.d/ssh ./rc3.d/S02sshGet out of the mounted partition and dismount it
$ cd $ umount /media/external
$ ping 192.168.0.6Ping should respond on the Pi itself and elsewhere on the network (and where named to: raspberrypi).
I clean SD cards with the official SD Association formatter, before reusing them, as it removes any partitions automatically.
Note: commands shown ($ 'command') in this section are for your Pi via PuTTY on Windows.
- Run PuTTY.exe on your Windows computer.
Enter the address of raspberrypi (192.168.0.6 in this case), set the remote character set to UTF-8 and click 'Open'.
Click 'Yes' to the PuTTY Security Alert...we do trust this host!
- At the PuTTY terminal prompt respond pi to 'login as:'
and raspberry to 'email@example.com's password:'
You should now have a command line terminal for pi@raspberrypi:~
Enter: sudo raspi-config
You need to 'Expand Filesystem' (if your SD card is bigger than 4GB), set 'Console Text console, requiring login (default)' for 'Enable Boot to Desktop/Scratch', check/set 'Internationalisation Options' and 'Select' 'Advanced Options/Update'. Note: that your ssh server should be left enabled, and the default locale is for the UK. Re-run raspi-config again anytime you want to change these options.
- You should be on the internet (via your gateway) so do a full upgrade
$ sudo apt-get update $ sudo apt-get upgradeGo make coffee...upgrade may take some time!
You don't want all that login spam again and a reboot is now needed
$ touch .hushlogin $ sudo shutdown -r nowYour PuTTY terminal will disconnect, so close it, wait a while and reconnect with PuTTY when the Pi has booted (use ping to check it's up).
- Log back in to the PuTTY terminal for user pi.
Give root a password and remember it (optional...it's your Pi...you can rebuild the image yourself if you destroy it...plus you don't want to keep typing sudo to do useful work!)
$ sudo passwd rootBut I suggest you add (or enable) some aliases in ~/.bashrc for both user pi and root to protect yourself a little.
--- save_.bashrc 2013-10-28 22:09:34.740000001 +0000 +++ .bashrc 2013-11-25 07:56:57.832897001 +0000 @@ -86,6 +86,10 @@ #alias la='ls -A' #alias l='ls -CF' +alias rm='rm -i' +alias cp='cp -i' +alias mv='mv -i' + # Alias definitions. # You may want to put all your additions into a separate file like # ~/.bash_aliases, instead of adding them here directly.Note: root has slightly different contents, in .bashrc, to that above.
- Become super user root
$ su -login and install package xdm
$ apt-get install xdmthis runs
dpkg-reconfigure xdmas part of the install and displays
choose xdm as the default display manager.
- In /etc/X11/xdm change two files to allow remote access (so please be careful who can 'sniff' traffic on your network)
--- save_xdm-config 2013-04-29 22:19:04.000000000 +0100 +++ xdm-config 2013-12-02 19:04:16.545476001 +0000 @@ -33,4 +33,4 @@ ! SECURITY: do not listen for XDMCP or Chooser requests ! Comment out this line if you want to manage X terminals with xdm -DisplayManager.requestPort: 0 +! DisplayManager.requestPort: 0and
--- save_Xaccess 2013-04-29 22:19:04.000000000 +0100 +++ Xaccess 2013-12-02 18:49:23.839205000 +0000 @@ -43,7 +43,7 @@ # right hand sides can match. # -#* #any host can get a login window +* #any host can get a login window # # To hardwire a specific terminal to a specific host, you can
- Start xdm and install packages x11-apps and midori (both installs optional)
$ service xdm start $ apt-get install x11-apps $ apt-get install midoriCreate a ~/.Xdefaults file for users pi and root, containing one line (to display x11-apps in colour)
*customization:-colorMake sure XDMCP is listening on port 177/udp
$ netstat -ulnp | grep 177 udp 0 0 0.0.0.0:177 0.0.0.0:* 2864/xdmi.e. if you see udp, 177 and xdm you're good.
- XDMCP mode
On your Windows computer run
Xming :1 -query 192.168.0.6or why not try out some of Xming's options?
Xming :1 -query raspberrypi -clipboard -wgl -once -resize -screen 0 1280x720+100+100@1Logging in via Debian wheezy's xdm greater
this 'Welcome to raspberrypi' login also appears when headed
The desktop displaying some of the X11-apps you installed earlier. Have fun .
Logout the LXDE (Lightweight X11 Desktop Environment) session properly from the Task Bar (LXPanel) when finished.
Start an Xming multiwindow mode server
Xming -multiwindow -clipboardYou have used PuTTY above: time to add settings for SSH X11 forwarding
Now click Open and login as pi/raspberry as before. At the PuTTY terminal type
$ midori or the command to run another graphical application
The Midori browser will display (if it is installed), and interact with the user, on the Windows desktop
- Finally: I recommend you don't use startlxde or lxsession via PuTTY as you can't Logout cleanly and the Pi's resources may be left in unknown states (e.g. processes and files not gracefully flushed, stopped or closed).
The Xming website, documentation and images are licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.0 UK: England & Wales License.
Copyright © 2005-2015 Colin Harrison All Rights Reserved