Linux Mint – Slow Boot Up

Problem

I noticed that my machine would take abit of time to boot. On bootup I pressed ESC to see what was happening, and noticed one of my partitions would take a couple of seconds to be scanned and would then throw a Connection Refused message.

I initially thought that my hard disk what dying but turns out there was a non existent volume in my /etc/fstab file that was trying to be loaded.

Solution

When I checked the systemd-journal logs, I saw the error below:

disk device has failed
disk device has failed

When I searced, I got a clue from this post that this was due to a mis-configured /etc/fstab.

The above swap volume with the UUID starting with “5f1d11af” was trying to be mounted but it doesn’t exist.

check /etc/fstab if volumes listed are correct
The pointer shows the incorrect volume

Confirm the correct existing volumes, using blkid:

check correct volumes using blkid
check correct volumes

Open the /etc/fstab file and comment out this volume (the one on the last line) as shown:

Comment out the wrong volume in /etc/fstab
Comment out the wrong volume in /etc/fstab

After commenting the above, then restart your machine.

References

dev-disk-by\x2duuid.device/start timed out.

GRUB2: Timed out waiting for device (was anciently a swap partition)

Manage Log Messages Under Systemd Using Journalctl

Copy Multiple lines from a logfile

Problem

I needed to capture an error / stack trace (list of the method calls that the application was in the middle of when an Exception was thrown – explanation from stackoverflow) from a log file to another file for attaching to a bug tracker

Solution

Used this answer from unix.stackexchange that proposed using a shell function that used sed that you could enter the from,to line numbers, log file and output file as shown

In the user’s .bashrc file add:

$ tail .bashrc 
#Printing section of a Line From A logFile
printLine () 
{ 
 sed -n -e "$1p" "$2"
}

Useage:

$ printLine 2000,2250 /var/log/tomcat/catalina.out > java_error.txt

Sources

Easy way to copy lines from one file to another

What is a stack trace, and how can I use it to debug my application errors?

Merge Video and Audio into One File

Problem

I downloaded a presentation where the video file and audio files were separate and I needed to merge the video and audio into one file.

Solution

Used the solution posted on super user on this link:

Merging video and audio, with audio re-encoding:

@whiscardz ~ $ ffmpeg -i video.mp4 -i audio.wav -c:v copy -c:a aac -strict experimental output.mp4

Copying the audio without re-encoding:

@whiscardz ~ $ ffmpeg -i video.mp4 -i audio.wav -c copy output.mkv

Sources

How to merge audio and video file in ffmpeg

Install Multiple Java versions and Setup Maven to Use one – Java 1.7

Problem

I was running Java 1.8 by default but I needed to build some modules that require Java 1.7

Solution

Check the default version of Java installed as well as the version of Java that maven is using:


implementer@whiscardz ~ $ java -version
java version "1.8.0_131"
Java(TM) SE Runtime Environment (build 1.8.0_131-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

implementer@whiscardz ~ $ mvn -v
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=512m; support was removed in 8.0
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.8.0_131, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-8-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-78-generic", arch: "amd64", family: "unix" 
  • Install Java 1.7 as instructed in this link.
  • Create a .mavenrc file in your home directory and then add the JAVA_HOME of Java 1.7 In my case this would be JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
implementer@whiscardz ~ $ vim .mavenrc

JAVA_HOME=/usr/lib/jvm/java-7-oracle/jre
  • Optional, Run the maven file to assign the JAVA variable on the current terminal
implementer@whiscardz ~ $ source .mavenrc
  • Check version of Java Maven is now using:
implementer@whiscardz ~ $ mvn -version
Apache Maven 3.3.9
Maven home: /usr/share/maven
Java version: 1.7.0_80, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.4.0-78-generic", arch: "amd64", family: "unix"

References

Create .mavenrc file

How to change maven java home

Deleting a Partition on USB Flash Disk – Linux

Problem

I would always get the error below when trying to delete a partition on a USB flash disk:

Error deleting partition /dev/sdb2: Command-line `parted --script "/dev/sdb" "rm 2"' exited with non-zero exit status 1: Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.
(udisks-error-quark, 0) 

Solution

According this answer on askubuntu, the above “was caused by a low-level device tool (like dd) writing blocks at the wrong size directly onto the device.

There are a number of solutions offered, like using dd. The safest, maybe using fdisk as described:

user@whiscardz ~ $ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.27.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sdb: 14.9 GiB, 15955132416 bytes, 31162368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x60dfafa1

Device Boot Start End Sectors Size Id Type
/dev/sdb1 * 0 2156351 2156352 1G 7 HPFS/NTFS/exFAT
/dev/sdb2 2135488 2140031 4544 2.2M ef EFI (FAT-12/16/32)

Command (m for help): d
Partition number (1,2, default 2): 1

Partition 1 has been deleted.

Command (m for help): d
Selected partition 2
Partition 2 has been deleted.

Command (m for help): p
Disk /dev/sdb: 14.9 GiB, 15955132416 bytes, 31162368 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x60dfafa1

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

References

Unable to delete USB Drive partitions (Block size error)

Change MySQL root password on Windows

Problem

Needed to reset the MySQL root password on a windows machine.

Solution

Got this solution from this stack overflow answer: Resetting ROOT password in MySQL 5.6

0) shut down service mysql56

1) go to C:\ProgramData\MySQL\MySQL Server 5.6, note that ProgramData is a hidden folder (confirm this is the directory MySQL is installed on Windows by go to the Services Window and check the properties of the mysql service)

2) looking for file my.ini, open it and add one line skip-grant-tables below [mysqld],save

[mysqld]

skip-grant-tables 

3) start service mysql56

4) by right, you can access the database, run mysql

5) and use the query below to update the password

update mysql.user set password=PASSWORD('NEW PASSWORD') where user='root';

6) shut down the service again, remove the line skip-grant-tables save it, and start the service again. try to use the password you set to login.

References

Resetting ROOT password in MySQL 5.6

Ubuntu Hash-Mismatch Error

Problem

On ubuntu 16.04 I was getting the following error when I do apt-get update:

whiscard@whiscardz ~ $ sudo apt-get update
Hit:1 http://archive.canonical.com/ubuntu xenial InRelease
Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Get:4 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Err:13 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
Hash Sum mismatch
Get:14 http://archive.ubuntu.com/ubuntu xenial-updates/main i386 Packages [456 kB]
Fetched 821 kB in 4s (171 kB/s)
Reading package lists... Done
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/main/binary-amd64/by-hash/SHA256/1e7c9b3642cbcdd21de161a4b13b6af5342441439eea597dd8d4246c8d72db07 Hash Sum mismatch
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/universe/binary-amd64/by-hash/SHA256/8660f9a78841c033023106f0d388dbd7864007d132455a788b458c6c2e62a8d0
E: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/xenial-updates/universe/binary-i386/by-hash/SHA256/89ea489c0112ad76835e8856c598ca9024bee50497b7f2ae6b982effef27e545
E: Some index files failed to download. They have been ignored, or old ones used instead.

Solution

The solution was to first clear out the local repository and then delete the contents of /var/lib/apt/lists/ and then resynchronize the package index files from their sources so:

whiscard@whiscardz ~ $ sudo apt-get clean
whiscard@whiscardz ~ $ sudo rm -rf /var/lib/apt/lists/*
whiscard@whiscardz ~ $ sudo apt-get update

Resources

How do you fix apt-get update “Hash Sum mismatch”

How do I fix APT errors “W: Failed to fetch […] Hash Sum mismatch”?

“Hash Sum mismatch” errors from apt-get when using apt-cacher-ng

Windows Server Task Scheduler Error: 2147943726

Problem

A database backup using the Task Scheduler Stopped running and it was throwing this error:

Task Scheduler failed to start “\Fence Check Rota” task for user “xxx-xxx\xxx”. Additional Data: Error Value: 2147943726.

Solution

According to this answer in the Microsoft blog, the issue could have been caused by a change in password for the user meant to run the scheduled task. Solution explained is as follows:

  • in task scheduler, click on the scheduled job properties >>> then settings
  • iin the last listed option:
    “if the task is already running, the following rule appplies:”
    select “stop the existing instance” from the drop down list.
  • when you click save you will be prompted for a password. Enter it and then exit.
  • Run the scheduled task and see if it works.

Sources

Task Scheduler failed to start. Additional Data: Error Value: 2147943726. What does this mean?

 

Add MySQL.cnf file to Mac OS Homebrew MySQL Install

Problem

Installed MySQL using homebrew but this did not create a my.cnf file by default.

Solution

Copied the example of my.cnf file in the cellular mysql path (/usr/local/Cellar/mysql/5.x.xx/support-files) to (/etc) having added the sql_mode explained in the MySQL 5.7 customizations

 $ cp /usr/local/Cellar/mysql/5.7.17/support-files/my-default.cnf /etc/my.cnf 

Open the my.cnf and add the sql_code variable as explained in the MySQL 5.7 customizations post.

Sources

MySQL my.cnf location on OS X?

How do I find where MySQL is loading its config from?