How to change SD on Mac?


12 posts
by destructor » Sat Jan 05, 2013 7:01 pm
Hi,
sorry, if this is a stupid question, but I cannot find a solution on my own: I got a Raspberry for Christmas and like the concept very much. However, I do not have a digital display and therefore would like to work via ssh. I found this nice thread http://raspberrypi.stackexchange.com/a/760, but cannot find boot_enable_ssh.rc or access /etc/network/interfaces.
I am using a MacBook and all I see on the SD is:
Code: Select all
$ ls /Volumes/Untitled/
bootcode.bin      fixup_cd.dat      kernel_emergency.img
cmdline.txt      issue.txt      start.elf
config.txt      kernel.img      start_cd.elf
fixup.dat      kernel_cutdown.img

I tried to find out more:
Code: Select all
$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            319.7 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *16.0 GB    disk1
   1:             Windows_FAT_32                         58.7 MB    disk1s1
   2:                      Linux                         1.9 GB     disk1s2

Mounting is impossible:
Code: Select all
$ sudo mount /dev/disk1s1 /Volumes/myMountPoint/
/dev/disk1s1 on /Volumes/myMountPoint: Incorrect super block.

Does any of you have an idea how to solve this?
Posts: 2
Joined: Sat Jan 05, 2013 6:51 pm
by Joe Schmoe » Sat Jan 05, 2013 7:08 pm
The short answer is that with current versions of the "recommended" image, you don't need to worry about this. ssh is enabled "out of the box".

The longer answer is that you should be able to mount the SD card's first partition on the Mac. It should "just work", since it is FAT and Mac understands FAT. I didn't follow your text of what you tried and what didn't work - but in any case, it should "just work".
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2621
Joined: Sun Jan 15, 2012 1:11 pm
by destructor » Sat Jan 05, 2013 10:23 pm
Hi Joe,
thanks for the fast reply, that is an easy solution! I tried it and cannot find out the IP (tried to ping the broadcast address and check
Code: Select all
arp -a
), although the PI should be on the network, judging from the LEDs. Well, I'll try again tomorrow...
Posts: 2
Joined: Sat Jan 05, 2013 6:51 pm
by terrycarlin » Mon Jan 07, 2013 5:36 pm
If you are a Mac person and want to play with the RPi, it is handy to have "Fuse for OS X" and "fuse-ext2", the ext2 plugin for Fuse. They are open source packages that will allow you to mount the ext2/3/4 filesystems on a Mac.
If it ain't broke, take it apart and see how it works.
User avatar
Posts: 70
Joined: Thu Jun 14, 2012 10:42 pm
by tvjon » Mon Jan 07, 2013 7:50 pm
Open "terminal" on your macbook & type

nmap -sP *.*.*.0/24

replacing the * characters with whatever your network is, e.g. here on this 10.7.5 macbook ,

nmap -sP 192.168.2.0/24

produces:

Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2013-01-07 19:36 GMT
Nmap scan report for 192.168.2.1
Host is up (0.0095s latency).
Nmap scan report for 192.168.2.2
Host is up (0.010s latency).
Nmap scan report for 192.168.2.4
Host is up (0.0040s latency).
Nmap scan report for 192.168.2.9
Host is up (0.00023s latency).
Nmap scan report for 192.168.2.13
Host is up (0.091s latency).
Nmap done: 256 IP addresses (5 hosts up) scanned in 3.11 seconds

Then you can try, e.g..,

nmap 192.168.2.2

which here produces:

Starting Nmap 5.61TEST4 ( http://nmap.org ) at 2013-01-07 19:38 GMT
Nmap scan report for 192.168.2.2
Host is up (0.016s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
80/tcp open http
445/tcp open microsoft-ds

Nmap done: 1 IP address (1 host up) scanned in 1.99 seconds


As you can see, a ssh service is available on that IP, & I can make a ssh connection to 192.168.2.2 which happens to be a RPi.

When you find out what IP your Pi is, you can ssh into yours.

I don't know what your OS or particular mac is, so you may need to install nmap on your mac.

HTH.
Posts: 300
Joined: Mon Jan 07, 2013 9:11 am
by gragib » Mon Jan 07, 2013 7:55 pm
Like someone said above, you do not need to enable SSH as it is enabled by default out of the box in the current version of Raspbian. Just follow the instructions to flash the img file to SD, insert the SD card into the Pi, connect Ethernet and power. Once the boot sequence is complete (takes a minute or 2), open Terminal.app and run
Code: Select all
ssh raspberrypi.local -l pi
Regarding what you see in the SD card when you read it on your Mac, it contains 2 partitions: a FAT32 partition (/boot) and a Linux ext3 partition (/). Mac can read the FAT32 partition and that is what you see. Mac (out-of-the-box, without using something like FUSE; and even Windows) cannot read Linux ext3 partition; hence you can't see it in Finder, but it is there.
Posts: 99
Joined: Sat Dec 22, 2012 8:09 pm
Location: Calgary, AB, Canada
by Joe Schmoe » Mon Jan 07, 2013 8:12 pm
Like someone said above, you do not need to enable SSH as it is enabled by default ...


That someone would be me.

A couple of nitpicks:

1) It is ext4 not ext3.

2) I don't think that you can find the Pi from outside (as "raspberrypi.local") as your post suggests. In any case, it doesn't (and has never) worked for me. FWIW, I think the theory is that *if* you set some weird hack in the dhcp config file, then it might (under certain weird conditions) send out a usable name that other computers can pick up. But, as you can see, I'm skeptical about this actually working.

If, as seems to be the case now, the actual thrust of this thread is "How do I setup my Pi completely headlessly - that is, with never having a mouse/keyboard/TV connected - then I'd suggest the following 3 hacks - try them in this order:

1) Look on your router's "DHCP client table".
2) Use "nmap" (as another poster suggested)
3) Hack the cmdline.txt file to set a fixed IP address (details elsewhere on the forum)
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2621
Joined: Sun Jan 15, 2012 1:11 pm
by gragib » Mon Jan 07, 2013 8:41 pm
I can't imagine why raspberrypi.local won't work on a LAN with Raspbian installed on the Pi. I do it all the time. If you need the IP address of the Pi, you can:
1. run nmap on a Unix box on the same LAN and guess which one is the Pi
2. find it in the router admin DHCP client table
3. log in to the Pi using serial console and run ifconfig
4. ping raspberrypi.local and the IP address of the Pi should be in the output :lol:
Posts: 99
Joined: Sat Dec 22, 2012 8:09 pm
Location: Calgary, AB, Canada
by Joe Schmoe » Mon Jan 07, 2013 9:14 pm
gragib wrote:I can't imagine why raspberrypi.local won't work on a LAN with Raspbian installed on the Pi. I do it all the time. If you need the IP address of the Pi, you can:
1. run nmap on a Unix box on the same LAN and guess which one is the Pi
2. find it in the router admin DHCP client table
3. log in to the Pi using serial console and run ifconfig
4. ping raspberrypi.local and the IP address of the Pi should be in the output :lol:


#1: Check - that was #2 on my list.
#2: Check - that was #1 on my list.
#3: Good idea - of course, most people won't have a serial hookup. Aside: If I was going to make a case for any additional piece of hardware becoming standard issue with the Pi, it would be a serial board (I.e., a TTY -> USB converter board).
#4: Doesn't work (for most of us). I still have no idea why you think it should work. And I don't mean that sarcastically; I'm seriously asking what piece of the software mix would deliver that piece of information to the outside world (I.e., your LAN).

My #3 idea is also good - You can include something like "IP=192.168.x.y" in cmdline.txt
Never answer the question you are asked. Rather, answer the question you wish you had been asked.

- Robert S. McNamara - quoted in "Fog of War" -
Posts: 2621
Joined: Sun Jan 15, 2012 1:11 pm
by cyrano » Mon Jan 07, 2013 10:04 pm
Joe Schmoe wrote:#4: Doesn't work (for most of us). I still have no idea why you think it should work. And I don't mean that sarcastically; I'm seriously asking what piece of the software mix would deliver that piece of information to the outside world (I.e., your LAN).


Do you really mean the standard RPi Raspbian has no zeroconfig support out-of-the-box yet? What could be a reason not to include it?

I'm not trying to be sarcastical either, I'm just baffled because I believed zeroconfig to be part of most modern OSes by now. After all, it's been around for more than ten years...
User avatar
Posts: 469
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium
by gragib » Tue Jan 08, 2013 8:03 am
Here's my experience with zero-conf and DNS.

The DNS servers for most ISPs suck. What I do is I set my router (run-of-the-mill Dlink box, stock firmware, but I've tried this with Linksys, Belkin and Buffalo routers as well) to use the OpenDNS or Google's DNS servers. If I make this change on my PC, zero-conf fails 99% of the time. My PCs are configured to use my router for DNS.

What I think the router does when it sees raspberrypi.local is it goes into the DHCP client list and does a reverse lookup with the hostname. [I don't have Bonjour installed on my Windows box.]

This whole scheme fails when there are multiple Raspberry Pis running on the same network all calling themselves raspberrypi.local. What I do before "commissioning" a new Raspberry Pi is a change the hostname (rPi-256-01.local, rPi-256-02.local, rPi-512-01.local, etc.).

Why do I insist on raspberrypi.local? Because it works under most circumstances on a LAN if you are using Raspbian or Occidentalis. It's even documented here on learn.adafruit.com and here on eLinux.org. See this blog post for more details.

The .local part means that this hostname likely won't resolve on a WAN, like the Internet, unless you've done something with your hosts file. If you need to reach your Raspberry Pi over the Internet (say, you are at school or work, and your Pi is at home or wherever) you need to look at other solutions.

Regarding nmap, turns out they make it Windows too. Open the GUI and run
Code: Select all
nmap -sP x.x.x.0/24
and you'll get a list of all machines it can see. Replace x.x.x with the DCHP range of your router. If your router issues IP address in the range 10.0.64.x, then use
Code: Select all
nmap -sP 10.0.64.0/24
If it's in the 192.168.0.x range, then use
Code: Select all
nmap -sP 192.168.0.0/24
Posts: 99
Joined: Sat Dec 22, 2012 8:09 pm
Location: Calgary, AB, Canada
by cyrano » Tue Jan 08, 2013 2:01 pm
gragib wrote:Here's my experience with zero-conf and DNS.

The DNS servers for most ISPs suck. What I do is I set my router (run-of-the-mill Dlink box, stock firmware, but I've tried this with Linksys, Belkin and Buffalo routers as well) to use the OpenDNS or Google's DNS servers. If I make this change on my PC, zero-conf fails 99% of the time. My PCs are configured to use my router for DNS.


I don't understand what DNS has to do with it. Zeroconfig is local only. It can't even be routed to protect the user. I agree that most providers' DNSes suck and everybody should use OpenDNS or Google DNS or whatever you prefer. But that has nothing to do with DNS.

What I think the router does when it sees raspberrypi.local is it goes into the DHCP client list and does a reverse lookup with the hostname. [I don't have Bonjour installed on my Windows box.]


That doesn't even go over the router. Every client can "see" other devices on the local network because they announce themselves on the local network. It's chatty, but on a typical home network it's fantastic for the average user. The printer shows up without knowing anything about ip's. And devices have a name, not some cryptical number. Although, I admit, Windows PC's are a PITA, cause they all show up as PC_xyz, where xyz is a long number. Not very user friendly.

This whole scheme fails when there are multiple Raspberry Pis running on the same network all calling themselves raspberrypi.local.


No, it doesn't. They get a number. They'll automagically show up as raspberrypi.local (1), raspberrypi.local (2)...

The disadvantage is that these names get cached and could even show up weeks after the device has been removed from the network. But that depends totally on the reporting OS. And in very bad cases, you still can delete all files in the cache manually.

What I do before "commissioning" a new Raspberry Pi is a change the hostname (rPi-256-01.local, rPi-256-02.local, rPi-512-01.local, etc.).


Why not use a "human readable" name?

Why do I insist on raspberrypi.local? Because it works under most circumstances on a LAN if you are using Raspbian or Occidentalis. It's even documented here on learn.adafruit.com and here on eLinux.org. See this blog post for more details.


That's what I seemed to remember reading. But I've read so much about the RPi and linux that I wasn't sure. Glad that Zeroconfig is a part of Raspbian.

The .local part means that this hostname likely won't resolve on a WAN, like the Internet, unless you've done something with your hosts file. If you need to reach your Raspberry Pi over the Internet (say, you are at school or work, and your Pi is at home or wherever) you need to look at other solutions.


Likely? No, certainly! You wouldn't want .local to leak out to the net, do you?
User avatar
Posts: 469
Joined: Wed Dec 05, 2012 11:48 pm
Location: Belgium