Created
December 22, 2022 21:14
-
-
Save glowinthedark/621f588663021c96c4a5837091035e03 to your computer and use it in GitHub Desktop.
Mount Ext4/ext3/ext2 partitions on MacOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for device in $(diskutil list | awk '/Linux/ {print $NF}') ; do | |
read -p ">>> Found linux device: $device. Mount? y/n <<< " answer | |
if [[ "$answer" =~ [yY] ]]; then | |
mount_point="$HOME/mnt/$device" | |
mkdir -p $mount_point | |
echo "Mounting device $device at $mount_point..." | |
sudo ext4fuse -o allow_other,defer_permissions /dev/$device ${mount_point} | |
status=$? | |
if [[ $status -eq 0 ]]; then | |
echo "Mounted successfully at ${mount_point}" | |
read -p "Open in Finder? y/n <<< " show_in_finder | |
echo "***IMPORTANT: TO UNMOUNT USE***: diskutil umount ${mount_point}" | |
if [[ "$show_in_finder" =~ [yY] ]]; then | |
open "$mount_point" | |
fi | |
else | |
echo "\nERROR mounting device $device!" | |
echo "Is macFUSE installed? (brew install macfuse) https://macfuse.io" | |
echo "is ext4fuse installed? (brew install ext4fuse) https://github.com/gerard/ext4fuse" | |
echo "See also: https://github.com/gerard/ext4fuse/issues/66#issuecomment-819943409" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment