1

I'm following this answer to move my /usr directory to a different partition. When I try to delete the old /usr files using sudo rm -r /mnt/usr or sudo rm -rf /mnt/usr I get rm: cannot remove ‘/mnt/usr’: Device or resource busy. How do I resolve this?

I have an Ubuntu Live USB so I could try that, but I'm not sure how to delete the old /usr files from the live USB either.


Edit:

Here is /etc/fstab:

# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
UUID=ac528df3-12fc-4583-acda-4bb3fbb47fb8 /               ext4    errors=remount-ro 0       1
UUID=a13080c5-6dde-468d-b5a3-a60d78fe6db0 none            swap    sw              0       0
UUID=0f226bb1-8acb-4343-9db9-b3e27bcea2f1 /home ext4    defaults    0   2
UUID=e21ed5be-d896-4b03-979d-5102b3b039fc /usr               ext3    errors=remount-ro 0       1

/dev/sda1   /media/shirley/windows7 ntfs    uid=1000,gid=1000   0 0

My fstab entry for /usr is slightly different from the linked post (e.g. using ext3, and the options are different) because I was initially following this ubuntuforums post but the overall procedure is the same.

From sudo lsof | grep /mnt/usr I just get

lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs
  Output information may be incomplete.

... whether I'm mounted on /mnt or not.

Edit 2:

Here is /etc/mtab (after running sudo mount --bind / /mnt, which appends the last line):

/dev/sdb1 / ext4 rw,errors=remount-ro 0 0
proc /proc proc rw,nodev,noexec,nosuid 0 0
sysfs /sys sysfs rw,nodev,noexec,nosuid 0 0
none /sys/fs/cgroup tmpfs rw,uid=0,gid=0,mode=0755,size=1024 0 0
none /sys/fs/fuse/connections fusectl rw 0 0
none /sys/kernel/debug debugfs rw 0 0
none /sys/kernel/security securityfs rw 0 0
udev /dev devtmpfs rw,mode=0755 0 0
devpts /dev/pts devpts rw,noexec,nosuid,gid=5,mode=0620 0 0
tmpfs /run tmpfs rw,noexec,nosuid,size=10%,mode=0755 0 0
none /run/lock tmpfs rw,nodev,noexec,nosuid,size=5242880 0 0
none /run/shm tmpfs rw,nosuid,nodev 0 0
none /run/user tmpfs rw,nodev,noexec,nosuid,size=104857600,mode=0755 0 0
none /sys/fs/pstore pstore rw 0 0
/dev/sda1 /media/shirley/windows7 fuseblk rw,nosuid,nodev,allow_other,default_permissions,blksize=4096 0 0
/dev/sda3 /usr ext3 rw,errors=remount-ro 0 0
/dev/sda2 /home ext4 rw 0 0
binfmt_misc /proc/sys/fs/binfmt_misc binfmt_misc rw,nodev,noexec,nosuid 0 0
systemd /sys/fs/cgroup/systemd cgroup rw,nosuid,noexec,nodev,none,name=systemd 0 0
vmware-vmblock /run/vmblock-fuse fuse.vmware-vmblock rw,nosuid,nodev,default_permissions,allow_other 0 0
gvfsd-fuse /run/user/1000/gvfs fuse.gvfsd-fuse rw,nosuid,nodev,user=shirley 0 0
/ /mnt none rw,bind 0 0

Thanks again!

syin
  • 111
  • 3

2 Answers2

0

After reading the mentioned answer twice, there is written you should use the following commands

$ sudo mount --bind / /mnt
$ sudo rm -rf /mnt/usr
$ sudo umount /mnt

Therefore use

sudo rm -rf /mnt/usr

and not

sudo rm -r /mnt/usr

as you wrote in your question.

and you should read this ;)


My previous answer, maybe helpful for other readers:

You have mounted a partition at the mount point /mnt/usr. With the command sudo -rf /mnt/usr you try to delete this mount point and that's not possible. To delete the content of the folder use

sudo find /mnt/usr -delete

More about find with

man find
A.B.
  • 90,397
-1

run command :

fuser -vm /mnt/usr

or

lsof /mnt/usr

run this command as root and see which process and user using /mnt/usr and kill that process then try to delete /mnt/usr using command.

sudo rm -r /mnt/usr 

you will be able to delete /mnt/usr

pl_rock
  • 11,297