0

It's my understanding that the /media/ folder is for mounted/External hard drives. I have hooked up an external hard drive for storage, and was writing to /media/pi/My Passport, no issues. However, I have removed the USB connection so my Pi isn't connected to anything.

However, I can still use a script to write to /media/pi/My Passport and can view the images in there.

What is the Pi doing? Is it possible I somehow messed up, and just created that folder on the SD Card that holds Raspbian?

enter image description here

2

/media/pi/My Passport is just a directory - like any other.

You can use /media/pi for any purpose (although generally not a good idea).

The automount utility creates these as needed, but does not necessarily remove them.

EDIT Whenever I use a script to write to an external device I include tests to ensure it is mounted, and in RW mode. One example below:-

#!/bin/bash
# script to synchronise Pi files to backup
# 2018-12-17
BACKUP_MOUNTED1=$(mount | awk '/PiData/ {print $6}' | grep "rw")
BACKUP_MOUNTED2=$(mount | awk '/PiHDD/ {print $6}' | grep "rw")
if [ $BACKUP_MOUNTED1 ]; then
    BACKUP_ROOT='/mnt/PiData/'
elif [ $BACKUP_MOUNTED2 ]; then
    BACKUP_ROOT='/mnt/PiHDD/'
fi

if [ $BACKUP_ROOT ]; then
    echo "Commencing Backup"
    if [ $(grep -ic "stretch" /etc/os-release) -gt 0 ]; then
        if [ ! -e /usr/bin/Mathematica ]; then
            BACKUP_DIR="StretchCompactBackup"
        else
            BACKUP_DIR="StretchBackup"
        fi
    elif  [ $(grep -ic "jessie" /etc/os-release) -gt 0 ]; then
        BACKUP_DIR="JessieBackup"
    fi
    BACKUP_ROOT+=$BACKUP_DIR
    echo $BACKUP_ROOT
# Check/create Mount Point
    if [ ! -e $BACKUP_ROOT ]; then
        sudo mkdir $BACKUP_ROOT
    fi
    if [ $BACKUP_ROOT ]; then
    sudo rsync -apH --delete-during --delete-excluded --exclude-from=/usr/bin/rsync-exclude.txt / $BACKUP_ROOT
    fi
else
    echo "Backup drive not available or not writable"
    echo "run sudo mount /mnt/PiData"

fi
  • Thanks for clarifying that :D ...now my ultimate question is what happened, I had my .../MyPassport being correctly written to the external drive. [Something happened], and suddenly that became MyPassport1 and then MyPassport was created and kept local. ...but that's a question for another day. This answers it for now, cheers! – BruceWayne Mar 25 at 2:23
  • The automount creates directories as needed, but if they exist creates new directories by appending a number. Frankly, I consider this "feature" more of a problem, and have it turned off and manually mount when (and where) I want it. – Milliways Mar 25 at 2:57
  • Thanks for your edit! Also, re: automounting - could that be what happened? Say my Drive is connected, but a power hiccup causes it to disconnect/reconnect. If I had Automounting enabled, could that explain why it renamed my external drive MyPassport1? Because I'm thinking that's what happened, and this could confirm it's technically possible. Thanks again!! – BruceWayne Mar 25 at 14:04

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.