Loop Device in Linux

Overview

If you have ever downloaded a new Linux distribution ISO image, you may have wondered how to access the contents inside the image prior to repartitioning your disk and installing the operating system onto your local disk. This can be done via a loop mount in Linux.

In Linux and other UNIX-like systems, it is possible to use a regular file as a block device. A loop device is a virtual or pseudo-device which enables a regular file to be accessed as a block device. Say you want to create a Linux file system but do not have a free disk partition available. In such a case, you can create a regular file on the disk and create a loop device using this file. The device node listing for the new pseudo-device can be seen under/dev. This loop device can then be used to create a new file system. The file system can be mounted, and its contents can be accessed using normal file system APIs.

Batch Processing in Go

Batching is a common scenario developers come across to basically split a large amount of work into smaller chunks for optimal processing. Seems pretty simple, and it really is. Say we have a long list of items we want to process in some way. A pre-defined number of them can be processed concurrently. I can see two different ways to do it in Go.

The first way is by using plain old slices. This is something most developers have probably done at some point in their careers. Let's take this simple example: