Could not set the file size of ./ibtmp1. Probably out of disk space

While having my daily specialty coffee from Latin America I got this error for one of my docker containers running MySQL. ERROR: ‘Could not set the file size of ./ibtmp1’. Suddenly the container failed to start and I could not understand why!

I reviewed the logs for my container:

docker logs <my_container_name>
2020-07-31T15:45:10.209380Z 0 [ERROR] InnoDB: Could not set the file size of './ibtmp1'. Probably out of disk space
2020-07-31T15:45:10.209437Z 0 [ERROR] InnoDB: Unable to create the shared innodb_temporary
2020-07-31T15:45:10.209486Z 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2020-07-31T15:45:10.725388Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
2020-07-31T15:45:10.725530Z 0 [ERROR] Plugin 'InnoDB' init function returned error.
2020-07-31T15:45:10.725673Z 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2020-07-31T15:45:10.725770Z 0 [ERROR] Failed to initialize builtin plugins.
2020-07-31T15:45:10.725816Z 0 [ERROR] Aborting

2020-07-31T15:45:10.725871Z 0 [Note] Binlog end
2020-07-31T15:45:10.725996Z 0 [Note] Shutting down plugin 'CSV'
2020-07-31T15:45:10.727174Z 0 [Note] mysqld: Shutdown complete

Something strange ‘Could not set the file size of ‘./ibtmp1′. Probably out of disk space’

My computer disk space was fine with more than 20GB free space. But, then after a walk around my hood in NYC Moments I discovered this error was referring to my virtual space hard disk created by the docker engine which is used in the background. This was not my local computer’s hard disk space.

This solution worked for me:

docker-compose down

docker system prune

docker-compose up

I ran those three commands. This will prune all containers that not in used and might also reset your current containers. In my case I had to re-create MySQL database and tables. I need to make this better. Hope this solution for ‘Could not set the file size of ./ibtmp1’ error works for you. Remember to check out some cool coffee mugs and T-Shirt designs on my sister website

How to mount EXT Linux partition on MacOS

The other day while having a great cup of Latin America coffee from El Salvador I found a way to mount my EXT Linux partition I have on an external backup WD drive. I didn’t know that MacOS could not mount it natively even when both Linux and MacOS come from the same mother UNIX.

Homebrew came to the rescue! First, make sure you have it installed. Then run these couple of commands in order to install the package ext4fuse. Open your terminal and run these two commands:

brew cask install osxfuse
brew install ext4fuse

Plug in the hard disk drive or storage device whose partition you want to mount and in the terminal run:

diskutil list
diskutil list command results

This will give you a list of storage devices attached to your computer. Lets say your device is disk2S1. Then you run:

sudo ext4fuse /dev/disk2s1 ~/tmp/MY_EXT_PARTITION -o allow_other

MY_EXT_PARTITION is only a sample name. You can name it anything you want. You need sudo privileges to run this command.

Now, you can use Finder to navigate to your /tmp directory and find the mounted partition. Or in the terminal do:

open ~/tmp/

Remember, this methods will give you READ ONLY rights to the mounted ext partitions. You cannot make changes to it. Can you view the files and copy them to your MacOS and then make any changes. Homebrew is very handy and help me mount my EXT Linux partition I have laying around many external hard drives.

Hope this little tutorial was helpful. Contact me if you have any questions or need help.

grep Command in Linux Standard Examples

grep command is your friend for searching mainly text. It searches a given file for lines containing a given string or words. The grep command should be one of the most used commands and you should get familiar with it. I’m doing the same.

Below are some standard grep commands:

Search for any instance of the word ‘coffee’ in a file do:

grep 'coffee' filename

To perform a case sensitive search use the -i flag:

grep -i 'coffee' filename

The above command will give you any words matching ‘Coffee’, ‘coffee’, ‘cOffEe’. You get the idea. Latin America specialty coffee is fantastic!

To find all occurences of the word ‘new york city’ in a given directory and all its subdirectories:

grep -R 'new york city' .

Using the ‘.’ (dot or period) tells Linux to search in the current location.

I hope this little tutorial gives you some inspiration to learn more about the grep command. Check the man pages in your Linux distro:

man grep

Or install cheat in Ubuntu using apt or snap

apt install cheat or snap install cheat

Cheat works great for me. It gives me a brief summary of most Linux commands and its easy to use. Just run it your terminal for example:

cheat grep

How to display time in Python

I have been using Flask to teach myself some coding and develop a web application for people with high blood pressure to track their daily blood pressure readings.

I wanted to find a way to automatically display the time when a user takes a blood pressure reading. It was quite simple.

Use strftime() to display Time and Date

The strftime() method returns a string displaying date and time using date, time or datetime object.

In your .py file you have to import time. Below are some examples to print time in different formats:

print (time.strftime("%H:%M:%S")) - Displays time in 24hr format.
print (time.strftime("%I:%M:%S")) - Displays time in 12hr format.

See more examples in the Python official documentation. Enjoy!

Grab a coffee mug from my sister website

Setting Up Static IP on Ubuntu Server 20.04 LTS

Ubuntu Server 20.04 LTS uses the tricky Netplan for network configuration by default. Network configuration is a bit more tricky, but still good. The default Netplan network configuration file on Ubuntu 20.04 LTS server is /etc/netplan/00-installer-config.yaml.

First, find the network interface name which you want to configure a static IP address with the following command:

$ ip a
ip a command output
ip a command output

As you can see my network interface name is eth0@if8, it will be different for you.

Now, go brew a good cup of coffee you have to make sure that the network interface is not managed by CloudInit.

For that, open the configuration file with your favorite editor /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg with the following command:

$ sudo vim /etc/cloud/cloud.cfg.d/subiquity-disable-cloudinit-networking.cfg

Make sure the configuration file contains the following line:

network: {config: disabled}

Now, open the Netplan configuration file using your favorite editor (I like using vim) /etc/netplan/00-installer-config.yaml with the following command:

sudo vim /etc/netplan/00-installer-config.yaml

To assign a static IP address to the network interface (in my case, your network interface name will be different) eth0@if8, remove everything from the Netplan configuration file /etc/netplan/00-installer-config.yaml and type in the following lines.

  version: 2
      addresses: []
        addresses: [,]

Now, to make sure that the configuration file does not have any syntax errors, run the following command:

sudo netplan try

If everything is good you should see a message with something like “Warning: stopping systemd-networkd.service, but it can still be activated by:…..Press ENTER before the timeout to accept the new configuration”

The new network configuration should be accepted. To make changes permanent run the following command:

sudo netplan apply

Double check the IP address run again:

ip a

Enjoy! Contact me if you have questions or leave a comment on the comments section below.

If you like to learn more about Ubuntu Server you can get this book Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04 (13th Edition).

How to optimize images for the web using GIMP

Optimizing images for the Web means reducing its file size which in turn will make it load faster on websites. Grab some specialty coffee and follow these simple instructions.

Reducing the image size with GIMP

To reduce the image size:

  1. Open image in GIMP.
  2. Click on Image in the toolbar, then select Scale Image.
  3. In the image size, change the width to 1920px (or your own width)
  4. Select Scale
  5. Select File in the toolbar. Then select Export As.
  6. Name to your file ending with a “.jpg”
  7. Select Export
  8. In dialog box that opens, change Quality to 60.
  9. Click Advanced Options.
  10. Change Subsampling to 4:2:0 (chroma quartered)
  11. Click Export

Feel free to adjust settings to meet your image quality needs.

Contact me if you have any questions.

Linux command line history tips

Many times I found myself typing history into the terminal and then copy/paste the command I was looking for. But, then I found the below tricks to help repeat that command faster and more efficiently.

Use Control+R

I found this to be the most beneficial for me. It will do a reverse search really fast! Just press enter when you see the command you need to retype.

Repeat the previous command quickly

This is useful if you know you recently typed a command. You can use the following key combinations:

  • Use the up arrow to view the previous command and press enter to execute it.
  • Type !! and press enter from the command line
  • Type !-1 and press enter from the command line.
  • Press Control+P will display the previous command, press enter to execute it

Execute a specific command from history

For example, you can display history as usual:

history | more
1  service apache2 restart
2  ifconfig
3  ls
4  cat /etc/hosts

If you want to repeat command #2, you will type !2 as show below:

# !2
eth0      Link encap:Ethernet  HWaddr 12:38:33:b7:99:96  
          inet addr:  Bcast:  Mask:
          inet6 addr: fe80::1038:33ff:feb7:9996/64 Scope:Link
          RX packets:586486972 errors:0 dropped:0 overruns:0 frame:0
          TX packets:539727562 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:363967988525 (363.9 GB)  TX bytes:491630839370 (491.6 GB)

MySQL how to insert a row into a table

Inserting data into MySQL tables is easy, but I tend to forget little details once in a while. I was having the best espresso coffee and trying to remember this one. Below is how you insert a new row into a MySQL table.

Assume you created the following table:

    mytable_id INT AUTO_INCREMENT,
    title VARCHAR(255) NOT NULL,
    start_date DATE,
    due_date DATE,
    description TEXT,
    PRIMARY KEY (task_id)

And then you want to insert a new row into this MySQL table. Run the command below:

INSERT INTO tasks(title,priority)
VALUES('Learn MySQL INSERT Statement',1);

You should get the below from MySQL:

1 row(s) affected

That’s all! Contact me if you need help. Write in the comments section if you have questions.

How to restart a service running in docker compose

I’m playing with docker-compose for a test Flask app. My docker-compose.yml looks like this:

version: '2'

    build: www/.
      - "5000:5000"
      - ./www:/opt/www
      - db
      - db

    build: db/.
      - ./database:/var/lib/mysql
       MYSQL_ROOT_PASSWORD: supersecure

I noticed any change I made in my files within my templates folder did not take effect when I reloaded the browser locally at localhost:5000

So, I found that I can just restart the ‘www’ service defined on my docker-compose.yml file using this simple command:

docker-compose restart www

I’m not sure if this is the recommended way, but its working for now. If you have any suggestions please leave them on the comments area below.

Connect to a remote MySQL database using Linux terminal

This is simple. After you setup a user with proper access rights run the below commands.

# mysql -u yourUser -p -h <yourHostname or IP>

A little explanation:

-u tells mysql what your username

-p tells mysql you have a password and will prompt you to enter it after you press enter

-h tells mysql the hostname or IP address of your MySQL server

Good luck! Contact me if you have any questions.