Sunday, 10 March 2019

Cosmos DB emulator returns wrong IP address

I configured the Cosmos DB emulator to listen across the network. It was running on a developer laptop that had Docker for Windows installed.

Connecting from a different Linux laptop using Gateway mode, I was getting long delays and then "a task was cancelled". This was coming from deep within the HTTP stack.

On closer inspection I could see that the client was trying to connect to https://10.0.75.1 - this is the Docker network.

In the GetDatabaseAccountAsync method the client connects to the gateway and enumerates the databases:

https://cosmosdb.test:8081/

The gateway returns a JSON response. This can be seen in Visual Studio Code with the following debug query:

System.Text.Encoding.ASCII.GetString(((System.IO.MemoryStream)documentServiceResponse.ResponseBody).ToArray())

The databaseAccountEndpoint property returns https://10.0.75.1:8081 and this is used to form subsequent responses.
{
    "_self": "",
    "id": "localhost",
    "_rid": "cosmosdb.test",
    "media": "//media/",
    "addresses": "//addresses/",
    "_dbs": "//dbs/",
    "writableLocations": [
        {
            "name": "South Central US",
            "databaseAccountEndpoint": "https://10.0.75.1:8081/"
        }
    ],
    "readableLocations": [
        {
            "name": "South Central US",
            "databaseAccountEndpoint": "https://10.0.75.1:8081/"
        }
    ],
    "enableMultipleWriteLocations": false,
    "userReplicationPolicy": {
        "asyncReplication": false,
        "minReplicaSetSize": 1,
        "maxReplicasetSize": 4
    },
    "userConsistencyPolicy": {
        "defaultConsistencyLevel": "Session"
    },
    "systemReplicationPolicy": {
        "minReplicaSetSize": 1,
        "maxReplicasetSize": 4
    },
    "readPolicy": {
        "primaryReadCoefficient": 1,
        "secondaryReadCoefficient": 1
    },
    "queryEngineConfiguration": "{\\"maxSqlQueryInputLength\\":262144,\\"maxJoinsPerSqlQuery\\":5,\\"maxLogicalAndPerSqlQuery\\":500,\\"maxLogicalOrPerSqlQuery\\":500,\\"maxUdfRefPerSqlQuery\\":10,\\"maxInExpressionItemsCount\\":16000,\\"queryMaxInMemorySortDocumentCount\\":500,\\"maxQueryRequestTimeoutFraction\\":0.9,\\"sqlAllowNonFiniteNumbers\\":false,\\"sqlAllowAggregateFunctions\\":true,\\"sqlAllowSubQuery\\":true,\\"sqlAllowScalarSubQuery\\":true,\\"allowNewKeywords\\":true,\\"sqlAllowLike\\":false,\\"sqlAllowGroupByClause\\":false,\\"maxSpatialQueryCells\\":12,\\"spatialMaxGeometryPointCount\\":256,\\"sqlAllowTop\\":true,\\"enableSpatialIndexing\\":true}"
}

TomTom 6100 has a 32GB SD card limit

The TomTom 6100 has a 32GB maximum SD card limit because it requires the FAT32 file system.

Friday, 8 March 2019

Clone multiple-partition SD card with dd

List the disks and partitions
fdisk -l

Assuming that the sdcard is /dev/sdb with partitions /dev/sdb1 and /dev/sdb2

Unmount the partitions
umount /dev/sdb1
umount /dev/sdb2

Backup the partition table & MBR
dd if=/dev/sdb of=partitiontable.img bs=512 count=1

Backup the partitions
dd if=/dev/sdb1 of=partition1.img
dd if=/dev/sdb2 of=partition2.img

Restore the partition & MBR

Restore the partitions
sudo dd if=partitiontable.img of=/dev/sdb
sudo dd if=partition1.img of=/dev/sdb1
sudo dd if=partition2.img of=/dev/sdb2

https://askubuntu.com/questions/491082/steps-to-create-dd-image-file-from-usb-and-restore-image-to-a-different-usb




Attempt 2
umount /dev/sdb1
umount /dev/sdb2
dd if=/dev/sdb of=sdb.img bs=4M conv=noerror,notrunc status=progress