ubuntu-device-flash can leak loopback devices if image is in a long path
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
goget-ubuntu-touch (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
Version: 0.29-0ubuntu3 (from ppa:snappy-
I noticed that in some automated tests I'm running, I kept running out of loopback devices, but if I ran ubuntu-device-flash by hand, they were cleaned up just fine. What I found was that this happens if the path where the image is being built is long (example: /tmp/run/
When I would build an image in a long path like that, then check /dev/mapper, I would see something like:
$ ls /dev/mapper/ -l
total 0
crw------- 1 root root 10, 236 Sep 10 17:21 control
brw-rw---- 1 root disk 252, 0 Sep 10 16:59 loop0p1
brw-rw---- 1 root disk 252, 1 Sep 10 16:59 loop0p2
brw-rw---- 1 root disk 252, 2 Sep 10 16:59 loop0p3
brw-rw---- 1 root disk 252, 3 Sep 10 16:59 loop0p4
brw-rw---- 1 root disk 252, 4 Sep 10 16:59 loop0p5
brw-rw---- 1 root disk 252, 5 Sep 10 16:59 loop1p1
brw-rw---- 1 root disk 252, 6 Sep 10 16:59 loop1p2
brw-rw---- 1 root disk 252, 7 Sep 10 16:59 loop1p3
brw-rw---- 1 root disk 252, 8 Sep 10 16:59 loop1p4
brw-rw---- 1 root disk 252, 9 Sep 10 16:59 loop1p5
I could remove them by doing:
sudo kpartx -d /dev/loop0
sudo kpartx -d /dev/loop1
sudo losetup -d /dev/loop0
sudo losetup -d /dev/loop1
So I'm not sure why ubuntu-device-flash was unable to remove them, but I found that if I run it with the image built in a shorter path, everything is cleaned up properly.