{"id":51,"date":"2013-05-05T20:22:42","date_gmt":"2013-05-06T00:22:42","guid":{"rendered":"http:\/\/jonesling.us\/blog\/?p=51"},"modified":"2015-02-02T13:20:45","modified_gmt":"2015-02-02T18:20:45","slug":"device-is-busy","status":"publish","type":"post","link":"https:\/\/blog.jonesling.us\/?p=51","title":{"rendered":"&#8220;device is busy&#8230;&#8221;"},"content":{"rendered":"<p>I&#8217;m working on a fun little project to set up a custom-made bootable usb key. But I ran into a little trouble after using a chroot, due to <code>\/dev<\/code> and <code>mount --rbind<\/code>.<\/p>\n<pre># mount -t proc none \/mnt\/gentoo\/proc\n# mount --rbind \/sys \/mnt\/gentoo\/sys\n# mount --rbind \/dev \/mnt\/gentoo\/dev\n# mount -t tmpfs tmpfs \/mnt\/gentoo\/tmp\n# mount -t tmpfs tmpfs \/mnt\/gentoo\/var\/tmp\n# mount -t tmpfs tmpfs \/mnt\/gentoo\/usr\/src\n# mount | grep gentoo\n\/dev\/sde1 on \/mnt\/gentoo type ext2 (rw)\nnone on \/mnt\/gentoo\/proc type proc (rw)\n\/sys on \/mnt\/gentoo\/sys type none (rw,bind,rbind)\n\/dev on \/mnt\/gentoo\/dev type none (rw,bind,rbind)\ntmpfs on \/mnt\/gentoo\/tmp type tmpfs (rw)\ntmpfs on \/mnt\/gentoo\/var\/tmp type tmpfs (rw)\ntmpfs on \/mnt\/gentoo\/usr\/src type tmpfs (rw)\n# chroot \/mnt\/gentoo<\/pre>\n<p>All&#8217;s well, until it&#8217;s time to exit the <code>chroot<\/code> and unmount everything..<\/p>\n<pre># umount \/mnt\/gentoo\/usr\/src \/mnt\/gentoo\/var\/tmp \\\n\/mnt\/gentoo\/tmp \/mnt\/gentoo\/sys \/mnt\/gentoo\/proc \\\n\/mnt\/gentoo\/dev \/mnt\/gentoo\numount: \/mnt\/gentoo\/dev: device is busy.\n       (In some cases useful info about processes that use\n        the device is found by lsof(8) or fuser(1))<\/pre>\n<p>I don&#8217;t see anything mounted under there.  Fuuuu&#8230;<\/p>\n<pre># mount | grep gentoo\n\/dev\/sde1 on \/mnt\/gentoo type ext2 (rw)\n# lsof|grep gentoo\n# fuser -m \/mnt\/gentoo\n\/mnt\/gentoo:\n#<\/pre>\n<p>Rebooting at this stage is inconvenient, but will certainly solve the problem. But what is left using <code>\/mnt\/gentoo\/dev<\/code>?<br \/>\nGoogling around, and seeing some people with similar problems, finally lit a light bulb above my head:<\/p>\n<pre># cat \/proc\/mounts | awk '{print $2}' | grep gentoo\n\/mnt\/gentoo\n\/mnt\/gentoo\/dev\n\/mnt\/gentoo\/dev\/pts\n\/mnt\/gentoo\/dev\/shm<\/pre>\n<p>So <code>mount --rbind<\/code> worked as advertised and recursively mounted \/dev and everything sub-mounted. And I didn&#8217;t realize that udev mounted other things under <code>\/dev<\/code> without updating <code>\/etc\/mtab<\/code>. Sigh.<\/p>\n<pre># umount \/mnt\/gentoo\/dev\/shm \/mnt\/gentoo\/dev\/pts \/mnt\/gentoo\/dev \/mnt\/gentoo\n#<\/pre>\n<p>And now I can get on with my life.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on a fun little project to set up a custom-made bootable usb key. But I ran into a little trouble after using a chroot, due to \/dev and mount &#8211;rbind. # mount -t proc none \/mnt\/gentoo\/proc # mount &#8211;rbind \/sys \/mnt\/gentoo\/sys # mount &#8211;rbind \/dev \/mnt\/gentoo\/dev # mount -t tmpfs tmpfs \/mnt\/gentoo\/tmp # &hellip; <a href=\"https:\/\/blog.jonesling.us\/?p=51\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;&#8220;device is busy&#8230;&#8221;&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","wprm-recipe-roundup-name":"","wprm-recipe-roundup-description":"","advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[9],"tags":[96],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-linux","tag-mount"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4o3FW-P","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=51"}],"version-history":[{"count":3,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":698,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=\/wp\/v2\/posts\/51\/revisions\/698"}],"wp:attachment":[{"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.jonesling.us\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}