Category Archives: Non-Photo Posts

Mounting CIFS (formerly Samba) volumes via fstab on Alpine Linux

For my local development environment, I store all my code on my Windows 10 PC. The web servers and everything else then runs inside Linux Virtual Boxes. The Virtual Box shared folders feature has a lot of problems, so I mount the directories using CIFS, which as formerly called Samba.

Naturally, I wanted the same setup I had for my old Ubuntu boxes in Alpine. The setup was, as usual, not as straightforward as I had hoped. First, I installed the cifs-utils. This may or may not be necessary.

apk add cifs-utils

Then, I simply copied over the entry for /etc/fstab from the Ubuntu Box.

//    /mnt/www    cifs    uid=0,gid=0,user=janhapke,password=*****

In Ubuntu, this has been working fine for years and over several versions. On Alpine, I got an error message.

mount: can't find /mnt/www/ in /etc/fstab

Strangely enough, mounting directly from the command line worked, so CIFS was properly installed and the machines could talk to each other.

It turns out, Alpine parses the fstab a little more strictly than Ubuntu and absolutely needs 6 options per line whereas Ubuntu is OK with just 4. So to fix this, I just had to add the last 2 entries (for dump & pass, respectively).

//    /mnt/www    cifs    uid=0,gid=0,user=janhapke,password=***** 0 0

Great, now I could easily mount the directory on Alpine with a simple mount /mnt/www

Until I rebooted the machine. I always poweroff the VMs when I don’t use them because like shared folders, suspending them doesn’t really work so well in Virtual Box. The problem is, it now tried to mount the folders on boot, before the network was even available. This resulted in a lot of error messages during the boot process.

mount error(101): Network unreachable
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)
mount: mounting // on /mnt/www failed: Network unreachable
 * Some local filesystem failed to mount
 * ERROR: localmount failed to start

This was then followed by even more error messages about system services that cannot start because not everything could be mounted. It was possible to log in, but the system was not really properly configured (e.g. keymap ws incorrect).

The fix was again adding the right thing to /etc/fstab, namely appending the option _netdev to the mount options (which again was not necessary on Ubuntu).

//    /mnt/www    cifs    uid=0,gid=0,user=janhapke,password=*****,_netdev 0 0

This option tells Alpine Linux to only mount this directory after the network is available. With this entry, the VM can now finally mount files from the Windows Host machine.

Installing Docker (Daemon) on Alpine Linux

I’m thinking about overhauling the infrastructure behind this site (and others) a bit and want to place as many services as possible into Docker containers that can then run inside a small Virtual Machine on Amazon EC2. So I started playing around with some Virtual Machines locally and since Ubuntu would be too boring, I decided to give Alpine Linux a try. It promises to be really lightweight so that seams ideal as a container host running inside a VM.

After finally figuring out how to install Alpine (which is another story), installing Docker was relatively straightforward based on their Wiki:

  1. Add the Community Repository to the APK Repositories file:
    ~# vim /etc/apk/repositories

    Add the following line:

    Or, if you are using a mirror, use the URL of the mirror, in my case:
  2. Update the list of available software:
    ~# apk update
  3. Install Docker:
    ~# apk add docker
  4. Configure docker daemon to start automatically on boot:
    ~# rc-update add docker boot
  5. Start the docker daemon:
    ~# service docker start
  6. Verify it’s running:
    ~# docker ps

    Output should look like this:


Great, now I have a running Docker Daemon. Time to build a simple container. I quickly created a very short Dockerfile and ran docker build. After downloading some layers, it failed with a very cryptic error message:

failed to register layer: ApplyLayer exit status 1 stdout:  stderr: chmod /bin/mount: permission denied

Searching for this message on Google lead me down many rabbit holes, but ultimately it takes only a single command to make it go away:

sysctl -w kernel.grsecurity.chroot_deny_chmod=0

This disables a security feature inside the Kernel, so it might not be safe for a production environment that runs containers but I think it’s acceptable for the machine that merely builds them.

What language would/do you use to build a web application?

There was an interesting poll on Hacker News a couple of days ago that I decided to bookmark for later and check out again after the results had mostly stabilized. The question asked was “What Language would/do you use to build a web application?“. It’s been almost 2 weeks since that poll so I think it’s safe to assume the results won’t change much anymore. Here they are in a nice bar graph, courtesy of Google Docs:

Web Application Development Languages

To a regular reader of Hacker News, the results aren’t really surprising. Especially Python is very popular among users there. A little surprise at first sight may be that PHP came in so close to the top, at third place. When reading Hacker News, you could get the impression that everybody hates PHP. But I think that’s a very common misconception about PHP. Not many people hate the language, it’s just that the people who do tend to be very vocal about it.

Now, this is just the snapshot of an opinion and you cannot derive any trends whatsoever, but personally I guess that Java and C# are descending, slowly followed by PHP, Ruby and Python and that languages like JavaScript and Go are rising towards the top. It would be interesting to have a similar poll in a year or so.

Also, I have no idea who the one person is that would/does use Visual Basic to build a web application, but I salute that brave soul.