USB not detected in Ubuntu 18.04

Posted: January 22, 2019 in Uncategorized

After some updates after upgrading to Ubuntu 18.04 my Lenovo Thinkpad computer refused to detect USB drives. It first gave the impression that my USB stick was broken, but even all other sticks didn’t work. It even didn’t pop up in disks. When you run into this problem, you can do the following trick to mitigate this behaviour. I’ve got the idea from a post from 2004, but it works after a reboot:
 

echo -1 > cat /sys/module/usbcore/parameters/autosuspend

Ubuntu 17 uses resolved for DNS resolution. This does not always work very well with OpenVPN. When your DNS is not resolved correctly (always externally instead of internal addresses), try to use this fix here.

Update the line in /etc/nsswitch.conf:

`hosts: files mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns myhostname`

into

`hosts: files mdns4_minimal [NOTFOUND=return] dns resolve [!UNAVAIL=return] myhostname`

This changes the order in which the calls are resolved.

When Ubuntu refuses to mount an encrypted harddisk, try the following on the command-line:  (just in case: modprobe dm-mod)

sudo vgchange -ay
sudo lvscan

Then mount the disk to somewhere:

sudo mount /dev/computer-name-vg/root x

Ubuntu 16.04 ships an OpenSSH version which does no longer support DSA keys out of the box. If you want to use DSA keys, you can add the following line to the SSH config file:

echo "PubkeyAcceptedKeyTypes +ssh-dss" >> /etc/ssh/ssh_config

Since a couple of days, I was plagued by some DNS problems when using Docker 1.10+. Seems that the dnsmasq process is writing the address 127.0.1.1 into the resolv.conf. The purpose of the dnsmasq is to cache DNS queries. Unfortunately, it was no longer available in my Docker containers. The only solution for now (maybe it is a workaround) is to throw dnsmasq out. You can do this by editing the file:

/etc/NetworkManager/NetworkManager.conf

Open the file with an editor and comment out the line

dns=dnsmasq   ---> #dns=dnsmasq

After that, kill dnsmasq and restart the network-manager. You should see the changes in the resolv.conf after that:

sudo killall dnsmasq
sudo service network-manager
restart cat /etc/resolv.conf

Posting to a Slack channel

Posted: July 7, 2015 in Slack, Tools
Tags:

We’ve been trying out Slack for the last couple of weeks. A neat feature is the ability to make posts on behalf of external processes, like the build- and production-environment. You can create a incoming webhook for a channel. You then get an endpoint from Slack. Use this endpoint to make posts. That’s it.

curl -v -X POST 
   --data "{\"text\": \"This is a line of text in a channel.\"}"   
   https://hooks.slack.com/services/.....

When you checked out multiple git-repositories and you want to update them all at once, you can execute the following line:

$ ls -d */ | xargs -I{} git -C {} pull

When you’re running Ubuntu 15.04 with Docker, you must use systemctl to enable/disable your Docker service. Unfortunately, the old /etc/default/docker configuration file is not read. You must change the docker.service file and add these lines:

....

[Service]
EnvironmentFile=-/etc/default/docker
ExecStart=/usr/bin/docker -d -H fd:// $DOCKER_OPTS
MountFlags=slave
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity

....

(On my Ubuntu 15.04 system, the file resides at /etc/systemd/system/multi-user.target.wants/)

Restart Docker with:

$ sudo systemctl restart docker 

Reduce noise in an onejar FatJar

Posted: May 15, 2015 in Java
Tags: ,

When you’re using onejar 1.4.5 or above you want to turn off the noise the bootloader makes.

java -Done-jar.verbose=false -jar service.jar

Vertx3 is nearing its release date and we’re experimenting with the upcoming release to minimize future surprises. One of the major changes is the generation of fatjars. The Vertx2 fatJar plugin doesn’t exist anymore in the Vertx 3 world. Now Vertx 3 uses the maven-shade-plugin to generate the fat JAR. Unfortunately, the shader has its own problems. For example, it is very cumbersome to handle duplicate files especially in transitive dependencies which are something out of your control.

When you’re running into unsolvable errors with the maven-shade-plugin, you can easily switch to the onejar-maven-plugin. Configure your POM as follows:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-jar-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <archive>
            <manifestEntries>
                <Main-Class>io.vertx.core.Starter</Main-Class>
                <Main-Verticle>io.vertx.example.HelloWorldVerticle</Main-Verticle>
            </manifestEntries>
        </archive>
    </configuration>
</plugin>
<plugin>
    <groupId>org.dstovall</groupId>
    <artifactId>onejar-maven-plugin</artifactId>
    <version>1.4.5</version>
    <executions>
        <execution>
            <configuration>
                <attachToBuild>true</attachToBuild>
                <filename>service.jar</filename>
            </configuration>
            <goals>
                <goal>one-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This will create a new fat JAR with the project JARs as a complete file on the inside. They are not unpacked, so there are no issues with overwriting files in the META-INF. The downside is that they use an own boot-mechanism.

This again has some problems when for example certain JARs use the SPI mechanism or self-cooked mechanisms to load classes.