1

(Note: though I'm asking a different question here, this is essentially to diagnose the same problem I reported in this question on StackOverflow).

I have a Google Cloud Compute Engine virtual machine. The image uses Google Container-Optimized OS (if that gets in the way of debugging I'm thinking of switching to Ubuntu instead). I followed the instructions in their documentation to format a newly mounted volume on the machine. Specifically, I ran:

sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/[DEVICE_ID]
sudo mkdir -p /mnt/disks/[MNT_DIR]
sudo mount -o discard,defaults /dev/[DEVICE_ID] /mnt/disks/[MNT_DIR]
sudo chmod a+w /mnt/disks/[MNT_DIR]

Where MNT_DIR is the directory I was mounting on the device, and DEVICE_ID is the name of the device, as per sudo lsblk (automatically sdb, it seems, not that it matters).

A quick ls -l /mnt/ shows that the volume seems to have mounted correctly, and that there are world read-write-modify permissions to the directory:

drwxrwxrwx 3 root root 4096 Mar  8 00:00 subway-explorer-datastore

OK, now I'd like to transfer some data over to this machine. GCE includes a google compute scp command (documented here), which seems like just a thin wrapper on the UNIX scp command. So I can use that to write some data off of my local dev machine and onto this cloud disk, right?

So I run:

gcloud compute scp ~/Desktop/subway-explorer-api/logbooks.sqlite gke-webapp-default-pool-49338587-d78l:/mnt/subway-explorer-datastore --zone us-central1-a

And I get fiddly squat out of it.

scp: /mnt/subway-explorer-datastore: Read-only file system
ERROR: (gcloud.compute.scp) [/usr/bin/scp] exited with return code [1].

The rest of the file system is fine. For example, the following succeeeds:

gcloud compute scp ~/Desktop/subway-explorer-api/logbooks.sqlite gke-subway-explorer-default-pool-2bef4d1d-f7dn:/dev/null

This is an error raised by scp, not by the thin gcloud wrapper. To my inexperienced eyes, the permissions on the root folder seem fine. So what are some reasons why scp might be throwing this error? How do I debug it?

closed as off-topic by Jeff Schaller, Shadur, thrig, G-Man, Satō Katsura Mar 26 '18 at 6:28

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions describing a problem that can't be reproduced and seemingly went away on its own (or went away when a typo was fixed) are off-topic as they are unlikely to help future readers." – Jeff Schaller, Shadur, thrig, G-Man, Satō Katsura
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is for a Kubernetes-based application. For context, here are the deploy files. – Aleksey Bilogur Mar 8 '18 at 3:45
  • 1
    what does mount | grep /mnt/disks/[MNT_DIR] say? (please add output to your question, and not in a comment). Also, is the mounted dir under /mnt/ or /mnt/disks/? You seem to be using both in different places - e.g. you're scp-ing the file to /mnt/subway-explorer-datastore – cas Mar 8 '18 at 3:56
  • Herein lies the answer: I was trying to write to a folder that didn't exist, and misdiagnosing the problem because of the misleading error message. Answer below. Thanks for spotting this (rather dumb) mistake on my part. – Aleksey Bilogur Mar 8 '18 at 16:31
1

As surmised by @cas in the comments, I'm writing it to a folder that doesn't exist. Once I changed the path to /mnt/subway-explorer-datastore, it worked correctly.

Recall the error message:

scp: /mnt/subway-explorer-datastore: Read-only file system

This is misleading! Reading this response I assumed (since scp can't create folders) that the folder existed, and the problem was that I was missing the right permissions.

I'd like to think that I'd catch this error myself on a fresh cup of coffee.

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