Skip to content

Kyle Barron

Self-hosted Static Vector Maps

1 min read

I put each map onto its own block disk, so that I can expand use as needed.

Go to Google Cloud Compute console, choose your VM instance, click "Edit", then under "Additional Disks", click "Add new disk".

The planet Mbtiles file for use by an open-data project is 51GB, so I'll make a new disk of ~55GB.

Give the disk a nice descriptive name like openmaptiles-planet-2017-07-03. I made the disk for 55GB. Click "Done", and the disk will be provisioned.

Now the disk is connected to the VM, but you still need to format and mount it. SSH into your server.

> sudo lsblk
loop0     7:0    0 91.2M  1 loop /snap/google-cloud-sdk/118
loop2     7:2    0 91.4M  1 loop /snap/core/8689
loop3     7:3    0 91.3M  1 loop /snap/core/8592
loop4     7:4    0 90.7M  1 loop /snap/google-cloud-sdk/117
sda       8:0    0   15G  0 disk
├─sda1    8:1    0 14.9G  0 part /
├─sda14   8:14   0    4M  0 part
└─sda15   8:15   0  106M  0 part /boot/efi
sdb       8:16   0  100G  0 disk /mnt/disks/mbtiles-disk
sdc       8:32   0   55G  0 disk

I can see that the new disk is at /dev/sdc (it's 55GB and currently unmounted).

Then format the disk. Note that this deletes all data on the disk, so make sure you have the right identifier! (I'm leaving DEVICE_ID here so that I don't accidentally copy-paste this in the future and forget to change the device id!)

sudo mkfs.ext4 -m 0 -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/[DEVICE_ID]

Then create a new directory for the mount point:

sudo mkdir -p /mnt/disks/openmaptiles-planet

Then mount the disk to that directory:

sudo mount -o discard,defaults /dev/sdc /mnt/disks/openmaptiles-planet

Then grant read/write permissions to all users:

sudo chmod a+w /mnt/disks/openmaptiles-planet

Now this disk is formatted and mounted, but every time you restart you'll have to redo this process. In order to have the disk be auto-mounted on every restart, you need to add an entry for the disk into /etc/fstab.

Find the UUID for the disk:

sudo blkid /dev/sdc

Then add an entry of the following to /etc/fstab/:

UUID=[UUID_VALUE] /mnt/disks/[MNT_DIR] ext4 discard,defaults,nofail 0 2

So in my case I'd add:

UUID=406c2dad-373e-41a8-97ab-4e11fc86fd46 /mnt/disks/openmaptiles-planet ext4 discard,defaults,nofail 0 2

Now download the planet.mbtiles to the disk! It's a big file, so it could take ~1 hour.