Issue with loopback devices in Docker
Clash Royale CLAN TAG#URR8PPP
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 $lodevp1
mkfs.ext3 -L rootfs $lodevp2
Any ideas why mkfs.fat
thinks the block device does not exist when it looks like it does?
docker loop-device
add a comment |
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 $lodevp1
mkfs.ext3 -L rootfs $lodevp2
Any ideas why mkfs.fat
thinks the block device does not exist when it looks like it does?
docker loop-device
You don't need --privileged you can use --device mapping. See docs.docker.com/storage/storagedriver/device-mapper-driver
– ctrl-alt-delor
Feb 28 at 16:42
This would require the devices to be created and setup before entering the container, which is half of what this script does when creating the virtual image.
– dangeroushobo
Feb 28 at 18:09
add a comment |
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 $lodevp1
mkfs.ext3 -L rootfs $lodevp2
Any ideas why mkfs.fat
thinks the block device does not exist when it looks like it does?
docker loop-device
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 $lodevp1
mkfs.ext3 -L rootfs $lodevp2
Any ideas why mkfs.fat
thinks the block device does not exist when it looks like it does?
docker loop-device
docker loop-device
asked Feb 28 at 15:56
dangeroushobodangeroushobo
151110
151110
You don't need --privileged you can use --device mapping. See docs.docker.com/storage/storagedriver/device-mapper-driver
– ctrl-alt-delor
Feb 28 at 16:42
This would require the devices to be created and setup before entering the container, which is half of what this script does when creating the virtual image.
– dangeroushobo
Feb 28 at 18:09
add a comment |
You don't need --privileged you can use --device mapping. See docs.docker.com/storage/storagedriver/device-mapper-driver
– ctrl-alt-delor
Feb 28 at 16:42
This would require the devices to be created and setup before entering the container, which is half of what this script does when creating the virtual image.
– dangeroushobo
Feb 28 at 18:09
You don't need --privileged you can use --device mapping. See docs.docker.com/storage/storagedriver/device-mapper-driver
– ctrl-alt-delor
Feb 28 at 16:42
You don't need --privileged you can use --device mapping. See docs.docker.com/storage/storagedriver/device-mapper-driver
– ctrl-alt-delor
Feb 28 at 16:42
This would require the devices to be created and setup before entering the container, which is half of what this script does when creating the virtual image.
– dangeroushobo
Feb 28 at 18:09
This would require the devices to be created and setup before entering the container, which is half of what this script does when creating the virtual image.
– dangeroushobo
Feb 28 at 18:09
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503578%2fissue-with-loopback-devices-in-docker%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f503578%2fissue-with-loopback-devices-in-docker%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You don't need --privileged you can use --device mapping. See docs.docker.com/storage/storagedriver/device-mapper-driver
– ctrl-alt-delor
Feb 28 at 16:42
This would require the devices to be created and setup before entering the container, which is half of what this script does when creating the virtual image.
– dangeroushobo
Feb 28 at 18:09