Access micro SD card files

Is there a way to access files on the root partition on a raspberry Pi micro SD on a desktop machine (Mac or PC). When you open the SD card on a Mac all you can access at the file level is the boot partition. However that doesn’t really tell you anything about the version of the SD card you are looking at. You can’t even tell the date that the SD card was made. I find the SD card is a closed book with no useful access to any information. Any suggestions on this ? TIA

Below is the result of Google Search:

AI Overview

To access a Linux-formatted microSD card root partition on a Mac, you’ll need to use a specialized tool or a method like a virtual machine. One option is Paragon EXTFS for Mac which provides read and write access to ext2, ext3, and ext4 file systems. Alternatively, you can use FUSE for macOS (read-only) or install a Linux virtual machine on your Mac to access the SD card.

Here’s a more detailed look at each option:

  1. Paragon EXTFS for Mac:
  • Description: A paid software solution that enables read and write access to Linux-formatted drives (ext2, ext3, ext4) on macOS.
  • Pros: Seamless integration, provides both read and write capabilities.
  • Cons: Requires a paid license.
  1. FUSE for macOS (read-only):
  • Description: A FUSE filesystem for macOS that allows mounting and accessing Linux partitions.
  • Pros: Relatively simple to use, allows reading of Linux files.
  • Cons: Provides read-only access only, not write access.
  • Steps:
    1. Download and install FUSE for macOS.
    2. Create a directory where you want to mount the partition.
    3. Navigate to the directory and use the command sudo ext4fuse "/dev/disk2s2" "/mnt/" -o allow_other (replace “/dev/disk2s2” with the actual partition identifier).
    4. You can then access the files in the /mnt/ directory.
  1. Linux Virtual Machine:
  • Description: Install a Linux virtual machine (e.g., using VirtualBox) on your Mac and access the SD card within the VM.
  • Pros: Full access to Linux filesystems, including read and write.
  • Cons: Requires setting up a VM, might be more complex to configure.

Thanks, it sounds like FUSE is the way to go since I only need read access to the files.

Well after several trial and errors, finally was able to access files on the SD card. Needed to do the following using a terminal on the Mac:
Using MacPorts, install macfuse and ext4fuse. Homebrew should also work.
Plug in SD card to Mac. Find the SD card using diskutil list. You need the Linux partition of the SD card. It will show up as diskxs2 in the IDENTIFIER column of the list, where x is a disk number.
Create a mount point on Mac so that the Linux partition can be read: sudo mkdir /Volumes/rpi.
Then mount the drive with: sudo ext4fuse /dev/diskxs2 /Volumes/rpi -o allow_other,defer_permissions

A disk labeled FUSE should show up on the Desktop. Open that disk and you can access the files from the SD card.

Most of these instructions are from a Jeff Geerling article: Mount a Raspberry Pi SD card on a Mac (read-only) with osxfuse and ext4fuse | Jeff Geerling however I needed to add the argument defer_permissions at the end of the ext4fuse command line to make it work.

Edit to add: One additional thing – I actually installed macfuse twice: once from the macfuse site and then again with Macports. However, the macfuse site installation seems to be the one needed as it adds the Kernel Extension. You can see if the Kernel Extension has been loaded by looking at the bottom of the System Settings page – you should see a macFUSE icon.

The macfuse installation site is: https://macfuse.github.io Download macFUSE 4.10.2 and restart the Mac.

3 Likes

If you have a PC you can create a live USB stick with a Linux distribution and boot from it.
Once booted, you can access the files on your SD card.
No need to install anything on your device which could cause trouble.

Not sure if there is a similar solution for Mac.

Google Seach gave following:

AI Overview

To boot Linux from a USB stick on a Mac, you’ll need to create a bootable USB drive and then select it in the boot menu. Here’s a general outline of the process:

1. Download a Linux distribution ISO image:

Choose a Linux distribution (like Ubuntu, Fedora, etc.) and download its ISO image file from the official website.

2. Create a bootable USB drive:

Use a tool like balenaEtcher to write the ISO image onto your USB stick.

3. Boot from the USB:

Restart your Mac, hold down the Option key, and select your USB drive from the boot menu.

4. Boot and Install:

After selecting the USB, you can either boot into the live environment of the Linux distribution or begin the installation process if you choose to do so.

Detailed Steps:

1. Download a Linux ISO:

Find a Linux distribution you’d like to try and download its ISO file.

2. Prepare the USB drive:

  • Insert your USB drive into a USB port on your Mac.
  • Use Disk Utility (Finder → Applications → Utilities → Disk Utility) to erase the USB drive. Select the USB drive, choose “Erase”, and select the file system (typically “MS-DOS (FAT32)” or “exFAT”).

3. Create the bootable USB:

  • Use balenaEtcher to burn the Linux ISO image to the USB drive.
  • Select the ISO file you downloaded, choose the USB drive, and click “Flash”.

4. Boot from the USB:

  • Restart your Mac.
  • Press and hold the Option key as soon as you hear the startup chime.
  • You should see a boot menu. Select the USB drive you just prepared.

5. Boot and Install:

  • After selecting the USB, your Mac will boot into the live environment of the Linux distribution.
  • You can then either test the Linux distribution or begin the installation process if you’re planning to install it.

This video demonstrates how to create a bootable Linux USB drive on a Mac:

 

As abcd567 said, yes you can create a Linux distribution on a Mac from a USB stick. I have done that with Ubuntu in the past. But you’re just making the Mac into a Linux machine!

I guess the only completely safe way to do it is with a virtual machine on the Mac. (The third method mentioned in the original abcd567 post above), A lot of work for a simple task.

@jimMerk2
@foxhunter

A Raspberry Pi running Raspberry Pi OS is a Linux machine.
Why not use it to read the contents of another microSD card by sliding the “card to be read” into a USB card reader, and plug the USB Card reader into USB slot of an operating RPi. Almost everyone has more than one RPi, and this can be done easily.

 

That’s a good point. I do have another RPi running pihole and it has an ethernet connect to the router. I inserted the USB adapter with the SD card into that RPi. The only problem I’m having is trying to mount the root portion of the SD card. I have:

Device         Boot   Start      End  Sectors  Size Id Type
Device     Boot   Start      End  Sectors  Size Id Type
/dev/mmcblk0p1         8192  1056767  1048576  512M  c W95 FAT32 (LBA)
/dev/mmcblk0p2      1056768 62333951 61277184 29.2G 83 Linux
/dev/sda1          8192  1056767  1048576  512M  c W95 FAT32 (LBA)
/dev/sda2       1056768 62333951 61277184 29.2G 83 Linux

Then did the following:

(Deleted)

The command lsblk has displayed following microSD cards

(1) The microSD card which is in the microSD card slot of RPI, and on which RPi’s OS is installed is displayed as follows:

/dev/mmcblk0p1         
├─/dev/mmcblk0p1         8192  1056767  1048576  512M  c W95 FAT32 (LBA)
└─/dev/mmcblk0p2      1056768 62333951 61277184 29.2G 83 Linux

(2) The microSD card which is in the card reader plugged into USB port of RPi, and is the card whose contents you want to access is displayed as follows:

/dev/sda 
├─/dev/sda1          8192  1056767  1048576  512M  c W95 FAT32 (LBA)
└─/dev/sda2       1056768 62333951 61277184 29.2G 83 Linux

 

To access files on boot partition /dev/sda1 and root partition /dev/sda2, you have to first create two folder as follows:
One say “sd-boot” to mount file in boot partition (/dev/sda1)
Other say “sd-root” to mount file in root partition (/dev/sda2)

sudo mkdir /home/pi/sd-boot  
sudo mkdir /home/pi/sd-root  

Next mount boot partion /dev/sda1 on folder /home/pi/sd-boot and root partition /dev/sda2 on folder /home/pi/sd-root.

sudo mount /dev/sda1 /home/pi/sd-boot  
sudo mount /dev/sda2 /home/pi/sd-root  

You can now see sd card files by entering these forders

cd /home/pi/sd-boot
ls
cd /home/pi/sd-root
ls 

When done, you need to un-mount the microSD card before pulling out Card Reader from USB port. Use following commands to un-mount:

sudo umount /dev/sda1
sudo umount /dev/sda2

 

CAUTION:
mmcblk0, mmcblk0p1, and mmcblk0p2 are partitions of that microSD card on which RPi’s OS is installed. Do NOT use these partitions.

sda1 and sda2 are partitions of microSD card which is in the card reader plugged to USB port of RPi.

 

1 Like

Thanks, that worked. Assume when done you need to do:
sudo umount /dev/sda1
sudo umount /dev/sda2

1 Like

Thanks. I haver missed this step. I will now add it to my post so that anyone using it in future does not miss it.

I changed the title of this thread to delete “Mac” since the better way is to not try to do it on a Mac.

2 Likes

Which isn’t a problem if he simply wants to access the files on a SD card.
He is not installing anything, it’s a live environment. The original installation will not be touched (as long as he doesn’t want to have it installed)