0

Yesterday I got a raspberry pi4 together with a micro SD Card which is preloaded with Raspberry PI OS (32-bit).

I don't have a separate keyboard or mouse but I do have a laptop (a Mac) and so I decided to go for a headless connection.

As per the instruction "If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory" I issued the commands "cd /Volumes/boot" and "touch shh" in Terminal which gave me to which I got the response "ssh: Read-only file system".

And ever since I've been trying to figure out how to get the micro SD card writable. Changing the lever on the SD card holder does not help nor does recreating the image using the Raspberry PI Imager.

Any idea what I need to do to get the micro SD card writable (or any other way to allow me to access the raspberry from my Mac ?

Update 08 Jan-21

Thanks for all these suggestions. See below the output.

  1. Micro SD card is brand new (purchased at the rapsberry online webshop)
  2. Micro SD card is inserted in SD card 'holder'
  3. Switch on SD card holder is set to unlocked
  4. SD card holder is inserted in stick that connects to Mac with a USB-C adapter
  5. Ran "diskutil list" command:
% diskutil list
/dev/disk2 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *63.9 GB    disk2
   1:             Windows_FAT_32 ⁨boot⁩                    268.4 MB   disk2s1
   2:                      Linux ⁨⁩                        3.7 GB     disk2s2
                    (free space)                         59.9 GB    -
  1. Ran "ls -l | grep boot" command
% ls -l | grep boot
drwxrwxrwx@ 1 be022692  staff  3584 Dec  2 13:02 boot  
  1. Ran Disk Utility[ enter image description here enter image description here

To make sure I can write on the card I subsequently used Raspberry PI Imager app to put another OS on the card (LibreElec). See below output

  1. Ran "diskutil list" command /dev/disk2 (external, physical): #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *63.9 GB disk2 1: Windows_FAT_32 ⁨LIBREELEC⁩ 536.9 MB disk2s1 2: Linux ⁨⁩ 33.6 MB disk2s2 (free space) 63.3 GB -
  2. Ran "ls -l | grep LIBREELEC command" drwxrwxrwx@ 1 be022692 staff 16384 Oct 24 18:05 LIBREELEC
  3. Ran Disk Utility enter image description here enter image description here

In both instances the FAT folders "boot" and "LIBREELEC" are read-only so impossible to add files.

What would you suggest as best way forward ?

2
  • 1
    Are you sure that /Volumes/boot is the RasPiOS boot section and not your MacOS boot partition? Please list the entries under /Volumes before and after connecting your SD to the Mac.
    – FelixJN
    Jan 7, 2021 at 16:55
  • I think LIBREELEC proves the SD card is write-able, but beyond that it doesn't help much - we need to see boot. Also, please learn the MD formatting as it makes things so much easier to read - review the change I made in your Q for an example. I'm running some experiments on my RPi SD card on my Mac now. P.S. You never told us which version of macOS you're using - please do that.
    – Seamus
    Jan 8, 2021 at 17:01

4 Answers 4

2

As per the instruction "If you want to enable SSH, all you need to do is to put a file called ssh in the /boot/ directory"

I'm hoping that's not literally what it says in the Foundation docs, because it is misleading if you are new to the whole deal. But if you aren't, it's understandable why someone would refer to it this way.

Filesystem partitions in linux (*nix generally, I'd think this includes MacOS) are "mounted" in a directory tree rooted at the "root" fs. There are two partitions on the card, the 2nd is the root fs, and when the system is running, the 1st partition is normally mounted at /boot.

However, if you stick the card in another computer you just see the two partitions and referring to "the /boot directory" doesn't make sense. I think on a Mac you can only read the first one anyway, but it should contain a few dozen files including kernel.img. That's where you want to put the ssh file.

6
  • It's an interesting point, this /boot thing. Once "inside" the RPi, ls -l / shows /boot as just another directory; lsblk --fs reveals it to be a vfat partition with a mountpoint of /boot. When you insert the SD card in a Mac, it shows up as boot - an apparently stand-alone drive with only a single partition. I don't know of another OS that does anything like this.
    – Seamus
    Jan 7, 2021 at 19:07
  • I am sure any OS will work like this. They all ignore any unknown partitions (ext4 in this case) and show any known ones (FAT in this case, which is boot). I think it has a volume label of "boot" so it shows up with that label in the file manager. Linux shows all of them because it knows all of them. If there were only boot and, say, RISC OS partition unknown to Linux, it only showed "boot" one, like your macOS does. Jan 7, 2021 at 19:35
  • Hello - I updated the problem description to reflect your suggestions, can you have a look ? Jan 8, 2021 at 7:40
  • It's very, very, very simple: The boot partition has two characteristics that should make it easy to identify on any contemporary system, by any literate person. 1) It is the FIRST partition on the card. It is not possible for it to be anything else, because to serve its purpose it must be the first partition on the card. 2) That first partition will be formatted FAT32 (it can also be FAT16). It is this way because it CANNOT be anything else, again, because this is a carved in hardware requirement for it to work.
    – goldilocks
    Jan 8, 2021 at 15:18
  • So, if you can identify that based on that description, problem solved. If you honestly cannot, you are most likely in for a lot of grief from here on in with the Pi.... Might be useful to add a third characteristic (already mentioned in the answer): it will contain a kernel.img (and probably a kernel7.img and a kernel8.img. These are in the top level directory; the entire partition is very simple and probably only contains one subdirectory (overlays). If those are there, the ssh file should be put in with them.
    – goldilocks
    Jan 8, 2021 at 15:18
1

I think there are two possibilities:

Case 1. Assuming your SD card is a relatively new one, I think you've done something wrong, somehow. Does your SD card have a wee switch on it to make the entire card RO? - or, maybe your Mac user doesn't have any privileges, - or, something else... On my Macs (Catalina, Mojave and High Sierra), I have no problem at all doing what you just said you weren't able to do.

Case 2. If the SD card has been around for a while - perhaps served as a storage device for another computer, camera, etc: It may be "worn out". It seems that a symptom of SD cards approaching end-of-life is that they go into read-only mode.

If your SD card is covered under case 2 above, you should make a backup, and retire the card ASAP. If your card is covered under case 1, please read on - here's some things to try:

How have you connected to the SD card? Have you removed it from the RPi & connected to your Mac via a USB "adapter"? What do you see in Disk Utility? Is it like this:

enter image description here

Please show us what you see in your Mac Terminal app when you enter:

% ls -l /Volumes | grep boot

It should be something like this:

drwxrwxrwx@ 1 seamus staff 3584 Jan 7 12:26 boot


EDIT - Additions:

1. diskutil list
seamus@Dung-Pro % diskutil list

... 

/dev/disk3 (external, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *31.9 GB    disk3
   1:             Windows_FAT_32 boot                    268.4 MB   disk3s1
   2:                      Linux                         31.6 GB    disk3s2

CONCLUSION: disk3s1 is a FAT32 partition

2. check permissions via ls -l in /Volumes/boot
seamus@Dung-Pro % cd /Volumes/boot
seamus@Dung-Pro boot % ls -l
total 91359
-rwxrwxrwx  1 seamus  staff    18693 Jan  8 00:45 COPYING.linux
-rwxrwxrwx  1 seamus  staff     1594 Jan  8 00:48 LICENCE.broadcom

...

-rwxrwxrwx  1 seamus  staff  3698056 Jan  8 00:47 start_x.elf

CONCLUSION: /Volumes/boot is 777 (see above), AND all files in /Volumes/boot are 777 (rwx for all)

3. create / touch the ssh file
seamus@Dung-Pro boot % touch ssh
seamus@Dung-Pro boot % ls -l | grep ssh
-rwxrwxrwx  1 seamus  staff        0 Jan  8 11:14 ssh

CONCLUSION: /Volumes/boot is writeable on my macOS Catalina 10.15.7 without privilege elevation (aka sudo). Ergo, your issue is either macOS-related, or your SD card is somehow faulty. I would suggest: 1. Try another SD card, 2. present your question to the Apple SE.

And by all means, do not hesitate to elaborate here (in further comments) on anything else you feel may be relevant.

1
  • Hello - I updated the problem description to reflect your suggestions, can you have a look ? Jan 8, 2021 at 7:40
0

I found the solution to my problem.

I was using a company-provided laptop and due to a change in policy in the first week of this year it's no longer possible/allowed to write data to direct-attached device.
That's why I was unable to get the "ssh" and "spa_supplicant.conf" files.
So I got myself a second-hand laptop with a standard set-up and in no time I got the SD card fully ready.

I owe you guys a big apology for wasting your time and goodwill :-(.

-1

Your SD card has several partition on it. One is FAT partition, others might be ext4 which could be / (the root) which contains /boot, or /home parition, I don't know how they partitioned a card when it was "preloaded".

The FAT partition is mounted to /boot at runtime. You must put a file there. For reference, there is a config.txt file there, a bunch of *.dtb files, also files named kernel6, kernel7, kernel8 and so on - variants of linux kernel for different revisions of Raspberry Pi board. Put a file next to config.txt. macOS must be able to write to FAT.

I am surprised to read you had seen to see a a /boot folder which normally resided on an ext4 / (root) partition. I didn't knew macOS supports a Linux file system. Even it that, it is possible it supports it in read-only mode.

5
  • macOS doesn't support any Linux (ext*) file system. macOS has supported FAT for a long time.
    – Seamus
    Jan 7, 2021 at 19:10
  • This doesn't change matters. BTW, there certainly must be a driver for macOS (kext) which enables it to work with ext4, like ext2ifs in Windows. Jan 7, 2021 at 19:38
  • I will bow to your superior knowledge then.
    – Seamus
    Jan 7, 2021 at 19:47
  • Hello - I updated the problem description to reflect your suggestions, can you have a look ? Jan 8, 2021 at 7:40
  • Does this happen with all SD cards on your Mac? How exactly did you connected a card to a computer, via some external card reader, or there is a built in? Did you try to connect this card to another machine? Jan 8, 2021 at 9:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.