Monday, September 23, 2019

How to Install MongoDB on Ubuntu 18.04

Software:

  • Ubuntu 18.04 (Remote Virtual Machine)
  • MongoDB 3.6.3

Goals:
  • Install and configure a MongoDB server.
  • Create a superuser with full access to the Admin database.
  • Create a new User and Database with regular permissions.
Info:
  • We will want to create separate users for each database to avoid vulnerabilities if any of the users gets compromised. We can have users with the same name in different databases, since MongoDB use the `database.username` as the ID of the users.
Install:
  • sudo apt update
  • sudo apt install mongodb-server mongodb mongo-tools mongodb-clients 
  • sudo systemctl status mongodb.service
  • Start MongoDB server:
    • How to start server in "do-not-ask-for-authorization" mode
      • mongod
    • How to start server in "authorization" mode
      • mongod --auth --port 27017
  • Configure a superuser using a new terminal:
    • mongo
      • use admin
        • switched to db admin
      • db.createUser({user: "admin", pwd: passwordPrompt(), roles: [ { role: "root", db: "admin" }]})
        • Successfully added user: {"user": "admin", roles: [ { role: "root", db: "admin" }]}
      • OR:
      • db.createUser({user: "admin", pwd: "PASSWORD", roles: [ { role: "userAdminAnyDatabase", db: "admin"}, { role: "dbAdminAnyDatabase", db: "admin"}]})
        • Successfully added user: {"user": "admin", roles: [ { role: "userAdminAnyDatabase", db: "admin"}  ...
  • Configure a new user and database:
    • mongo
      • show dbs
        • admin   0.000GB
        • config   0.000GB
        • local   0.000GB
      • use new_db
        • switched to db new_db
      • db.createUser({user: "app_user", pwd: "PASSWORD", roles: [{role: "dbOwner", db: "new_db"}]})
        • Successfully added user: {...}
      • show users
        • {"_id": "new_db.app_user", ... , "roles": [{"role": "dbOwner", "db":  "new_db"}]}
      • Note: If you use the command  show dbs  now you will not see the  new_db  listed. The database will be displayed only after the first document has been inserted.
      • Create a collection:
        • db.createCollection("test")
          • {"ok": 1}
      • Insert a document:
        • db.test.insert({name: "John Doe", complement: "the true name of this person is unknown or is being intentionally concealed"})
          • WriteResult({"nInserted": 1})
      • exit
        • bye
  • Configure Authentication:
    • Use SCRAM-SHA1 as Authentication Method in MongoDB. It is more secure than the previously-used MONGODB-CR. In MongoDB 3.x the default authorization mechanism is SCRAM-SHA-1, while in MongoDB 4.0 both SCRAM-SHA-1 and SCRAM-SHA-256 are enabled by default.
    • Enable authentication:
      • sudo nano /etc/mongodb.conf
        • bind_ip = 0.0.0.0
        • port = 27017
        • auth = true
      • sudo systemctl stop mongodb.service
      • sudo systemctl start mongodb.service
      • sudo systemctl status mongodb.service
Tests:
  • Connect to the MongoDB server using authentication
    • mongo --port 27017 -u "admin" -p "PASSWORD" --authenticationDatabase "admin"
      • MongoDB shell version v3.6.3
      • connecting to: mongodb://127.0.0.1:27017/
      • MongoDB server version: 3.6.3
    • OR
      • mongo
        • db.auth("admin", "PASSWORD")
          • MongoDB shell version  ...
More Information:
  • Rename Database:
    • mongo --port 27017 -u "<USER>" -p --authenticationDatabase "admin"
    • db.copyDatabase("old-db-name","new-db-name")
    • use old-db-name
    • db.dropDatabase()
  • Superuser Roles
    • The following roles provide the ability to assign any user any privilege on any database, which means that users with one of these roles can assign themselves any privilege on any database:
      • dbOwner role - when scoped to the admin database
      • userAdmin role - when scoped to the admin database
      • userAdminAnyDatabase role
    • The following role provides full privileges on all resources:
      • root role - provides access to the operations and all the resources of the readWriteAnyDatabase, dbAdminAnyDatabase, userAdminAnyDatabase, clusterAdmin, restore, and backup combined
References:
If you like this content, feel free to

Thursday, September 12, 2019

GitHub API Library for Python

Software:
  • MacOS 10.14.6
  • Python 3.7.4
Goals:
  • Use the GitHub Python API to interact with Repositories, Issues, and Pull Requests.
Install:
  • Using the Terminal:
    • pip3 install github3
  • Generate the Token:
    • Go to your GitHub Settings page
    • Uses the sidebar to access Personal access tokens
    • Click on the Generate new token button in the top right of the view
    • Give the token a name, then uncheck all scopes except for User
    • Click Generate token and GitHub will take you back to the list of tokens from before
    • Copy the code into your clipboard
  • Put the code in your environment:
    • Linux: Edit the `/etc/environment` file and add the following:
      • GITHUB_TOKEN=5c2...5ed
Tests:
  • Login:
    • Access using username and password:
      • from github3 import login
      • gh = login('username', 'password')
    • Access using Personal Access Tokens:
      • from github3 import login
      • gh = login(token='eb89...04e2')
  • List of Repositories:
    • from github3 import login
    • gh = login(token='token')
    • repos = gh.repositories()
    •  for repo in repos:
      • print(repo, repo.description)
  • List of Issues:
    • from github3 import login
    • gh = login(token='token')
    • issues = gh.issues()
    • for issue in issues:
      • print(issue, issue.body, issue.as_json())
  • List or Pull Requests:
    • from github3 import login
    • gh = login(token='token')
    • pr = gh.pull_requests()
    • ToDo: Find an alternative function to get PRs, cause this one raises an exception.

References:


If you like this content, feel free to

Tuesday, August 13, 2019

Docker Desktop for Mac, Docker Toolbox, Docker Machine and Docker Engine

MacOS Mojave  v10.14.6
Docker Engine  v19.03.1
Virtual Box  v6.0.10


Goals:  Understanding the scenario.


Additional Info:
  • Docker Toolbox is for older Mac and Windows systems that do not meet the requirements of Docker Desktop for Mac and Docker Desktop for Windows.
  • The applications dockerdocker-compose and docker-machine will be installed by Docker Toolbox and also by Docker Desktop. Yet, you can always install Docker Machine directly (e.g. when using Linux).
  • Use Docker Desktop for Mac to run Docker natively on your local system without using Docker Machine at all, because Docker Desktop comes with their own native lightweight virtualization solutions (HyperKit) rather than Oracle VirtualBox.
  • But, if you want to create multiple local machines, you still need Docker Machine to create and manage a Docker host inside of a virtual machine, for multi-node experimentation.
  • You can use Docker Desktop for Mac and Docker Toolbox together on the same machine. You can also run both HyperKit and Oracle VirtualBox on the same system.
  • Docker Machine is a tool that lets you provision and manage large numbers of Docker hosts. It automatically creates virtual hosts, installs Docker Engine on them, then configures the docker clients. Each managed host (“machine”) is the combination of a Docker host and a configured client. Look at your machine as a pool of resource to host your containers.
  • Use docker-machine commands to create, use and manage a Docker Host inside of a Virtual Machine (e.g. VirtualBox). Each Docker Host you create will be running inside a VM with the same name of the Docker Host (e.g. default) in the VirtualBox. 
  • Once you create a machine it maintains its configuration between uses, like any VirtualBox VM. However, the default machine is Boot2docker - a lightweight Linux distribution (~45MB) made specifically to run Docker containers - the docker-machine auto-creates a disk that will be automounted and used to persist your docker data in /var/lib/docker and /var/lib/boot2docker. Changes outside of these directories will be lost after powering down or restarting the VM.
  • Docker Desktop ships with hypervisors for the host OS.  The hypervisor is responsible for running a lightweight Linux kernel (LinuxKit), which is included as part of Docker Desktop.  This fast and lightweight container OS comes packaged with the QEMU emulator, and comes pre-configured with binfmt_misc to run binaries of any supported architecture.
  • Under Docker 19.03.0 Beta 3, there is a new experimental CLI plugin called “buildx”. Buildx allows you to build multi-arch images.
Docker Machine

Docker Engine

QEMU emulation for the arm/v6, arm/v7 and arm64 Docker images


Install:
  • Download and Install Docker Desktop for MacOS
  • Download and Install VirtualBox for MacOS:
  • How to run a Docker container in a Docker Host:
    • Start the Docker Machine
    • Create a new (or start an existing) Docker Virtual Machine (VM).
    • Switch your environment to the new Docker VM.
    • Use the docker client to create, load and manage Docker containers.
  • Start the Docker Machine
    • docker-machine start
  • Create a new Docker VM named "default":
    • docker-machine create --driver virtualbox default 
    • For more verbose info you can create with debug (-D) option:
      • sudo docker-machine -D create --virtualbox-no-vtx-check default
  • List available Machines:
    • docker-machine ls
  • In order to run docker commands on this host we need to tell Docker to talk to the new machine. Then, let's switch your Docker environment to your new VM (running on VirtualBox).
    • First, we need to get the environment variables from Docker Machine:
      • docker-machine env
    • And then we can use the output of the command above to set up the environment variables:
      • eval "$(docker-machine env default)"
  • You need to do this setup each time you open a new shell or restart your machine.
Tests:
  • Run containers and experiment with Machine commands:
    • docker run busybox echo hello world
  • SSH into VM:
    • docker-machine ssh default
    • Docker Machine auto logs in using the generated SSH key, but if you want to SSH into the machine manually (or you're not using a Docker Machine managed VM), the credentials are:
      • user: docker
      • pass: tcuser
  • Get the host IP address:
    • docker-machine ip default
      • 192.168.99.100
  • Start, stop and remove Machines:
    • docker-machine start default
    • docker-machine stop default
    • docker-machine kill default
    • docker-machine rm -y default
  • Unset environment variables in the current shell:
    • Check whether DOCKER environment variables are set:
      • env | grep DOCKER 

    • Run a shortcut command to show the command you need to run to unset all DOCKER variables:
      • docker-machine env -u
      • eval $(docker-machine env -u)
  • Virtual Box command line manager
    • vboxmanage list vms | runningvms | natnets | intnets
    • vboxmanage --version
    • vboxmanage dhcpservers
    • vboxmanage dhcpserver modify --netname HostInterfaceNetworking-vboxnet0 --ip 192.168.99.2 --lowerip 192.168.99.100 --upperip 192.168.99.254 --netmask 255.255.255.0
Troubleshooting Links:
References:
If you like this content, feel free to

Tuesday, August 6, 2019

Starting RabbitMQ, Redis and MondoDB Docker Containers

MacOS 10.14.6
Docker Engine 19.03.1


Goals:
  • Install and test these two Broker/Message Systems.

Install:
  • Create the RabbitMQ Container:
    • docker container create --hostname rabbitmq --name rabbitmq-3.6 -p 5672:5672 -p 15672:15672 -p 25672:25672 rabbitmq:3.6-management
  • Start the RabbitMQ Container:
    • docker start rabbitmq-3.6
  • Install MQTT Plugin for RabbitMQ:
    • docker exec -it rabbitmq-3.6 bash
      • rabbitmq-plugins enable rabbitmq_mqtt
  • Create the Redis Container:
    • docker container create --name=redis -p 6379:6379 redis:alpine
  • Start the Redis Container:
    • docker start redis
  • Create the MongoDB Container:
    • docker container create --name=mongodb-3.6 -p 27017:27017 mongo:3.6
    • OR, to start the container automatically when they exit, or when Docker restarts.
      • docker container create --name=mongodb-3.6 -p 27017:27017 --restart always mongo:3.6
  • Start the MongoDB Container:
    • docker start mongodb-3.6


Test:

  • Check if the containers are running:
    • docker ps
  • RabbitMQ:
    • Open the url http://localhost:15672 and enter `guest` as username and also as password.

More Information:
    • db.updateUser("user_to_update", { ...  })
    • use db_to_remove
    • db.dropDatabase()


  • Superuser Roles
      • The following roles provide the ability to assign any user any privilege on any database, which means that users with one of these roles can assign themselves any privilege on any database:
        • dbOwner role - when scoped to the admin database
        • userAdmin role - when scoped to the admin database
        • userAdminAnyDatabase role
      • The following role provides full privileges on all resources:
        • root role - provides access to the operations and all the resources of the readWriteAnyDatabase, dbAdminAnyDatabase, userAdminAnyDatabase, clusterAdmin, restore, and backup combined


  • Rename Database
      • mongo --port 27017 -u "<USER>" -p --authenticationDatabase "admin"
      • db.copyDatabase("old-db-name","new-db-name")
      • use old-db-name
      • db.dropDatabase()


    References:
    If you like this content, feel free to

    Tuesday, June 25, 2019

    Install Ubuntu Core 18 on Raspberry Pi3

    MacOS
    Ubuntu Core 18


    Goals:

    • Install Ubuntu Core 18 on Raspberry Pi3.
    Install:
    • We will be following these instructions.
    • Download Ubuntu Core 18 image file.
    • Create an Ubuntu SSO account and log in.
    • Generating RSA Keys.
    • Import an SSH Key into your Ubuntu SSO account.
    • Flash the microSD card:
      • xzcat ~/Downloads/ubuntu-core-18-armhf+raspi3.img.xz | sudo dd of=/dev/sdb bs=32M
      • sync
    • First Boot with SD Card:
    • Install Ubuntu Core:
      • Insert the microSD card and plug the power adaptor into the board.
      • The device will display the prompt “Press enter to configure”
      • Configure the Wi-Fi
      • Enter email from Ubuntu Core account
      • After the "Configuration Complete" message select the "Finish" option to reboot.
    • Login:
      • ssh -i /path/to/private_pikey user@x.x.x.x
    Info:
    • Ubuntu core use snap, not apt or apt-get anymore. To see all packages installed run `snap list --all`. See the Ubuntu Snap basic tutorial.
    Install Tools:
    • sudo snap install docker

    Additional Setup:
    • sudo timedatectl set-timezone America/Fortaleza

    References:
    If you like this content, feel free to

    Thursday, May 2, 2019

    Starting a MySQL Server and PhpMyAdmin Docker containers

    MacOS Mojave 10.14.4
    Docker Engine: 18.09.0


    Goal:
    • To have a docker container running a MySQL Server instance and another running the PhpMyAdmin.

    Install:
    • Download the MySQL Community Edition image:
      • docker pull mysql:5.7.26
    • Start a new Docker container for the MySQL Community Server:
      • docker run --name=mysql1 -p 3306:3306 -e MYSQL_RANDOM_ROOT_PASSWORD=yes -d mysql:5.7.26
    • Or create and start the container:
      • docker container create --name=mysql1 -p 3306:3306 -e MYSQL_RANDOM_ROOT_PASSWORD=yes mysql:5.7.26
      • docker container start mysql1
    • The container appears in the list of running containers when you run the docker ps command:
      • docker ps
      • ============================================
      • CONTAINER ID        IMAGE                COMMAND                  CREATED             STATUS                   PORTS                 NAMES
      • 188d9a1f7d0d        mysql:5.7.26            "docker-entrypoint.s…"   25 minutes ago      Up 25 minutes       0.0.0.0:3306->3306/tcp, 33060/tcp   mysql1
      • ============================================
    • The -d option used in the docker run command above makes the container run in detached mode. These are other options available:
      • -d, --detach - Detached mode: run command in the background
      • -i, --interactive - Keep STDIN open even if not attached
      • -t, --tty - Allocate a pseudo-TTY
      • -u, --user string  -  Username or UID (format: <name|uid>[:<group|gid>])
      • -w, --workdir string  -  Working directory inside the container
    • Use this command to monitor the output from the any container:
      • docker logs <Container-ID>
    • Once initialization is finished, the command's output is going to contain the random password generated for the root user; check the password with, for example, this command:
      • docker logs mysql1 2>&1 | grep GENERATED
      • GENERATED ROOT PASSWORD: aSS3sNArecAMEsH3w=Os.it0N.i
    • Once the server is ready, you can run the mysql client within the MySQL Server container you just started and connect it to the MySQL Server using the password generated:
      • docker exec -it mysql1 mysql -u root -p
    • You can access the server from a client running on another computer via network, or from the computer were docker is running, using the command:
      • mysql -u root -p -h <IP-OF-THE-COMPUTER-WHERE-DOCKER-IS-RUNNING>
    • Because we used MYSQL_RANDOM_ROOT_PASSWORD=yes, after you have connected a mysql client to the server you must reset the server root password by running these commands:
      • ALTER USER 'root'@'localhost' IDENTIFIED BY '<password>';
      • ALTER USER 'root'@'%' IDENTIFIED BY '<password>';
      • FLUSH PRIVILEGES;
    • To run MySql Server again, after close Docker, you need to start Docker and run:
      • docker container start mysql1

    Additional Info:
    • Docker requires your command (e.g. CMD) to keep running in the foreground. Otherwise, it thinks that your applications stops and shutdown the container. The problem is that some application does not run in the foreground. In this situation, you can add tail -f /dev/null to your command. Even if your main command runs in the background, your container doesn’t stop because tail is keep running in the foreground.
    • You can run the container that doesn't have a command running in foreground and open a terminal inside the container by using:
      • docker run --entrypoint "/bin/sh" -it alpine/git
      • docker run --entrypoint "/bin/bash" -it alpine/git
    • You can stop the container using the command:
      • docker stop mysql1
    • You can also remove the container using the command:
      • docker rm mysql1
    • To connect to MySQL server remotely using MySQL client, edit the /etc/mysql/mysql.conf.d/mysqld.cnf configuration file:
      • sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
    • And change the "bind-address" from  127.0.0.1  to:
      • bind-address = 0.0.0.0

    Install PhPMyAdmin:
    • Download and run PhpMyAdmin docker image:
      • docker run --name myadmin -d -e PMA_ARBITRARY=1 -p 8080:80 phpmyadmin/phpmyadmin
      • docker ps
      • ============================================
      • CONTAINER ID        IMAGE                   COMMAND                  CREATED             STATUS              PORTS                               NAMES
      • 188d9a1f7d0d        mysql:5.7.26            "docker-entrypoint.s…"   25 minutes ago      Up 25 minutes       0.0.0.0:3306->3306/tcp, 33060/tcp   mysql1
      • 56e041e28d47        phpmyadmin/phpmyadmin   "/run.sh supervisord…"   20 minutes ago         Up 20 minutes          9000/tcp, 0.0.0.0:8080->80/tcp      myadmin
      • ============================================
    • Access the address:
      • http://localhost:8080
        • Server: localhost
        • Username: root
        • Password: aSS3sNArecAMEsH3w=Os.it0N.i
    • To run PhpMyAdmin again, after close Docker, you need to start Docker and run:
      • docker container start myadmin

    Backup and Restore MySQL databases:

    • Backup with data:
      • mysqldump -u root -p iotdb > iotdb_bkp20190627.sql
    • Backup without data, only structure:
      • mysqldump -u root -p -d iotdb > iotdb_bkp20190627.sql
    • Backup compatible with: (ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, or no_field_options)
      • mysqldump --compatible=ansi -u root -p iotdb > iotdb_bkp20190627.sql
    • Restore:
      • mysqldump -u root -p iotdb < iotdb_bkp20190627.sql

    References:

    Wednesday, March 6, 2019

    Using AWS SDK for Python to store files on S3 (Simple Storage Service)

    MacOS 10.14.3
    Python 3.7.2
    Boto3 AWS SDK for Python


    Goal:
    • Create a Bucket in AWS S3, list the Buckets, upload, list and delete files stored in the Bucket.
    Info:
    • Amazon S3 buckets, which are similar to file folders, store objects, which consist of data and its descriptive metadata.
    • There is no limit to the amount of objects an IT professional can store in a bucket, though buckets cannot exist inside of other buckets.
    • The S3 API to list files in the bucket (ListObjects) is paginated, returning up to 1000 keys (filenames) at a time, it also includes information like size, modified date, and ETag (md5 hash).
    Install:
    • Using the Terminal:
      • pip3 install boto3
    • Create the credential file. By default, its location is at ~/.aws/credentials:
      • nano ~/.aws/credentials
        • [default]
        • aws_access_key_id = YOUR_ACCESS_KEY
        • aws_secret_access_key = YOUR_SECRET_KEY
    Tests (using python3):
    • List of Buckets:
      • import boto3
      • s3c = boto3.client('s3')
      • response = s3c.list_buckets()
      • buckets = [bucket['Name'] for bucket in response['Buckets']]
      • print(buckets)
    • Create a new Bucket:
      • import boto3
      • s3c = boto3.client('s3')
      • s3c.create_bucket(Bucket='my-bucket')
    • Check if a bucket exist:
      • import boto3
      • s3r = boto3.resource('s3')
      • try:
        • s3r.meta.client.head_bucket(Bucket='my-bucket')
      • except Exception as e:
        • print('Bucket does not exist')
        • print(str(e))
    • Delete a Bucket:
      • import boto3
      • s3r = boto3.resource('s3')
      • bucket = s3r.Bucket('my-bucket')
      • # To completely remove the bucket itself (must be empty?):
      • bucket.delete()
    • List files (keys) in the Bucket:
      • import boto3
      • s3c = boto3.client('s3')
      • resp = s3c.list_objects_v2(Bucket='my-bucket')
      • try:
        • for obj in resp['Contents']:
          • print(obj['Key'], obj['LastModified'], obj['Size'], obj['ETag'])
      • except:
        • print('no files in the bucket')
      • Note: If there aren’t any files (keys), the ListObjects API doesn’t include a “Contents” key in the response.
    • Upload a file to the Bucket:
      • import boto3
      • s3r = boto3.resource('s3')
      • s3r.meta.client.upload_file('/tmp/linux.jpg', 'my-bucket', 'linux.jpg')
    • Download a file from the Bucket:
      • import boto3
      • s3r = boto3.resource('s3')
      • try:
        • s3r.Bucket('my-bucket',).download_file('linux.jpg', 'my_local_linux.jpg')
      • except:
        • print('file does not exist')
    • Delete a file from the Bucket:
      • import boto3
      • s3r = boto3.resource('s3')
      • obj = s3r.Object('my-bucket', 'linux.jpg')
      • obj.delete()
    • Delete all files from the Bucket:
      • import boto3
      • s3r = boto3.resource('s3')
      • bucket = s3r.Bucket('my-bucket')
      • bucket.objects.all().delete()
    References:

    If you like this content, feel free to

    Sunday, January 13, 2019

    ESP32 and ESP8266 - Configuring Arduino IDE and Updating firmware

    MacOS 10.14.2
    Arduino IDE 1.8.7


    Goal:

    • Configure Arduino IDE to develop and compile code to the ESP32 boards. Also download and install tools and SDKs files to update the firmware on ESP32 devices.

    Install:
    • Installing Boards support on Arduino IDE:
      • Start Arduino IDE and open Preferences window (File -> Preferences);
      • Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json, https://dl.espressif.com/dl/package_esp32_index.json into Additional Board Manager URLs field;
      • Open Boards Manager from Tools -> Board menu and install esp8266 (zzz...);
      • Open Boards Manager from Tools -> Board menu and install esp32 by Espressif Systems (zzz...);
    • Installing Libraries on Arduino IDE:

    • Download Flash Tools (ESP8266 & ESP32):
      • Download the latest Flash Tools here.
    • Download firmware:
      • ESP32:
        • Download the latest SDK here.
      • ESP8266:
        • Download the latest SDK here or here.
    • Updating Firmware:
      • Connect ESP to a computer.
      • Windows:
        • run the ESPFlashDownloadTool_v3.6.5.exe
        • Choose the right board model (ESP8266,  ESP8265, ESP32)
        • Check, locate the binary files and address for bootloader, singleapp partition and user application:
          • ESP32:
            • 0x1000: bootloader.bin
            • 0x4000: partitions_singleapp.bin
            • 0x10000: helloworld-esp32.bin (the user main application code)
          • ESP8266:
            • 0x0: boot_v1.7.bin
            • 0x1000: user1.2048.new.5.bin
            • 0x3E000: blank.bin
            • 0x7C000: esp_init_data_default_v08.bin
            • 0x7E000: blank.bin
        • Choose a COM port
        • Choose Baud Rate 460800
        • Flash the *.bin files

    Tests:
    • Open Arduino IDE, compile and upload a simple example (e.g., Blink)


    Troubleshooting:
    • Fix for "sketch is too big" on ESP32 boards:
      • Links:
      • Files to change on Windows:
        • <?>\hardware\espressif\esp32\boards.txt
        • <?>\espressif\esp32\tools\partitions\default.csv
      • Files to change on MacOS:
        • /Users/marcus/Library/Arduino15/packages/esp32/hardware/esp32/1.0.1/boards.txt
        • /Users/marcus/Library/Arduino15/packages/esp32/hardware/esp32/1.0.1/tools/partitions/default.csv
      • boards.txt:
        • lolin32.upload.maximum_size=1638400
      • default.cvs:
        • # Name,   Type, SubType, Offset,  Size, Flags
        • nvs,      data, nvs,     0x9000,  0x5000,
        • otadata,  data, ota,     0xe000,  0x2000,
        • app0,     app,  ota_0,   0x10000, 0x190000,
        • app1,     app,  ota_1,   0x1A0000,0x190000,
        • eeprom,   data, 0x99,    0x330000,0x1000,
        • spiffs,   data, spiffs,  0x331000,0x0CF000,
      • Obs: The board restarts itself after this change, maybe it is related. Don't know for sure. 
    Info:
    • ESP8266 x ESP32 - Pros and Cons
    • ESP32 Specification:
      • Number of cores: 2
      • Architecture: 32 bit
      • Wi-Fi, Bluetooth
      • RAM: 512 KB
      • FLASH: 16 MB
      • GPIO Pins: 36
      • Communication Protocols: SPI, IIC, I2S, UART, CAN
      • ADC channels: 18 channels
      • ADC Resolution: 12-bit
      • DAC channels: 2
      • DAC Resolution: 8-bit

    Arduino Board Configurations:

    • ESP8266:
      • Wemos D1 mini (GPIO02 = LED):
        • Menu Tools -> Board -> LOLIN(WEMOS) D1 R2 & mini
    • ESP32:
      • ESP32 Mini Kit (GPIO02 = LED):
        • Menu Tools -> Board -> WEMOS D1 MINI ESP32
          • Port:  SLAB_USBtoUART
        • Menu Tools -> Board -> MH ET LIVE ESP32MiniKit
      • ESP32 Lolin 32 lite (GPIO22 = LED):
        • Menu Tools -> Board -> SparkfFun ESP32 Thing
          • Upload Speed: 115200
        • Menu Tools -> Board -> WEMOS LOLIN32
          • Upload Speed: 115200
      • ESP32-Camera:
        • Menu Tools -> Board -> ESP32 Dev Module
      • WEMOS D1 R32 (Uno) (GPIO02 = LED):
        • Menu Tools -> Board -> WEMOS D1 MINI ESP32
          • Upload Speed: 115200

    References:
    If you like this content, feel free to