2

I'm trying to build a virtual disk image in Docker. I'm able to create my empty file with dd and create the partitions with parted but once I try to make my filesystem it fails saying the device could not be found. In the Docker container I'm running as root and I've passed --privileged=true to docker run.

This works outside of docker and works in Docker on my local machine. It's only failing on my build server (AWS elastic agent).

Here is a section of the output showing that the block device exist before the call to make the filesystem.

28-Feb-2019 10:39:33  +./scripts/make.sh:105> ls -l /dev/loop2 /dev/loop2p1 /dev/loop2p2
28-Feb-2019 10:39:33  brwxrwxrwx 1 root disk   7, 2 Feb 28 15:39 /dev/loop2
28-Feb-2019 10:39:33  brwxrwxrwx 1 root disk 259, 8 Feb 28 15:39 /dev/loop2p1
28-Feb-2019 10:39:33  brwxrwxrwx 1 root disk 259, 9 Feb 28 15:39 /dev/loop2p2
28-Feb-2019 10:39:33  +./scripts/make.sh:108> mkfs.vfat -n boot /dev/loop2p1
28-Feb-2019 10:39:33  mkfs.fat 3.0.28 (2015-05-16)
28-Feb-2019 10:39:33  /dev/loop2p1: No such device or address

And the section of the script:

## Create zero'd file
dd if=/dev/zero of=disk.img bs=1M count=400

## Find next available loop device
local lodev=$(losetup -f)

## Have flat file look like a block device
ls -l ${lodev}*
losetup ${lodev} disk.img

## Create partition table and partition
parted -s -a optimal ${lodev} mklabel msdos
parted -s -a optimal -- ${lodev} unit compact mkpart primary "10" "20"
parted -s -a optimal -- ${lodev} unit compact mkpart primary "21" "-1"
parted -s ${lodev} set 1 boot on
ls -l ${lodev}*

## Create filesystem
mkfs.vfat -n boot ${lodev}p1
mkfs.ext3 -L rootfs ${lodev}p2

Any ideas why mkfs.fat thinks the block device does not exist when it looks like it does?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.