umount: foo : device is busy.
You can't unmount a busy filesystem. You might see something like this:
# umount foo umount: foo: device is busy. (In some cases useful info about processes that use the device is found by lsof(8) or fuser(1))
You are then frustrated by the fact that both fuser -m foo or lsof -n -N | grep foo give no results. This can happen with nested mounts. When checking mount it is easy to overlook additional mounts inside your mounted filesystem. For example, if you are building a root filesystem you might have /dev/sdb1 mounted on /tmp/5A3NOZRz0R then not notice that you have have additional proc and devpts filesystems mounted under /tmp/5A3NOZRz0R. You might unmount these filesystems before you can unmount /dev/sdb1.
/dev/sda1 on / type ext4 (rw,noatime,errors=remount-ro) proc on /proc type proc (rw,noexec,nosuid,nodev) sysfs on /sys type sysfs (rw,noexec,nosuid,nodev) udev on /dev type tmpfs (rw,mode=0755) tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev) devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=620) /dev/sdb1 on /tmp/5A3NOZRz0R type ext3 (rw) /proc on /tmp/5A3NOZRz0R/proc type none (rw,bind) devpts on /tmp/5A3NOZRz0R/dev/pts type devpts (rw)
This will list all the disks that Linux sees. This will not show loop devices. See `losetup` example for more information:
- Convert a VMWare flat split image disk set to a raw disk image
- cat linux-server-f001.vmdk linux-server-f002.vmdk linux-server-f003.vmdk > linux-server.img
- Find the start of partitions
- fdisk -l -u linux-server.img
- First partition usually starts at block 63. Each block is usually 512 bytes. Offset is therefore
- echo $((63*512))
- Find the start of each partition down to the exact offset byte (easier than `fdisk`)
- parted linux-server.img unit b print
- List the next available loopback device
- losetup -f
- Attach loopback to a partition offset inside of a disk image
- losetup -o $((63*512)) /dev/loop0 linux-server.img
- Create a mount point
- mkdir -p /media/adhoc
- Mount the partition
- mount /dev/loop0 /media/adhoc
- Unmount the partition before cleaning up loop device
- umount /media/adhoc
- Cleanup the loop device
- losetup -d /dev/loop0
losetup -- mount individual partitions in a whole disk image
If you have a while disk image and you want to mount partitions inside that image then use `losetup` to create a loopback device for the image. For example, say you copied an entire disk using `dd` like this:
dd if=/dev/sda of=disk.img
You can later create a loop device for it and see its partitions with `fdisk` and mount those partitions individually with `mount`. Note that `fdisk -l` does not normally show loop devices. You must add an explicit path to the loop device that you want to list.
losetup /dev/loop0 disk.img fdisk -l /dev/loop0
The previous example assumed that /dev/loop0 was free. You can you the '-f' option to automatically find a free loop device. In this example we first use the '-f' option to associate the image file with the next available loop device; then we use the '-j' option to see what loop device was associated with the file:
losetup -f disk.img losetup -j disk.img
mounting partitions inside a disk image without loop device
It is also possible to mount partitions inside a disk image file directly with `mount` using the 'offset' option, but I have not had luck with this.
mount -o loop,ro,offset=1025 disk.img /media/adhoc
Use `dd_rhelp`. This is a wrapper around `dd_rescue` that makes it easier to use.