Cannot restore image: Device or resource busy [SOLVED]

Post here if you found a bug or something really not expected in the program
Post Reply
joebidalli
Posts: 3
Joined: Thu Jun 21, 2012 6:39 pm

Cannot restore image: Device or resource busy [SOLVED]

Post by joebidalli » Thu Jun 21, 2012 6:48 pm

I've been trying to build a Desktop image with fsarchiver savefs is successful, however i have not been successful in restoring an image.
I've tried everything i can think of but can't get around the error. Odd thing is I have 3 partitions, 2 give me this error and 1 does not.

I'm deploying from a Fedora 17 (i386) livecd storing the image on usb storage. I've upgraded fsarchiver to fsarchiver-0.6.15-1.el6.i386 makes no difference.

Debug log.

Creating logfile in /var/log/fsarchiver_2012-06-21_07-33-00_2049.log
Running fsarchiver version=[0.6.13], fileformat=[FsArCh_002]
============= extracting filesystem 0 =============
executing [mke2fs -V]...
command [mke2fs -V] returned 0
executing [mke2fs -V]...
command [mke2fs -V] returned 0
executing [mke2fs /dev/sda1 -q -r 1 -L '/boot' -b 1024 -I 128 -O has_journal,resize_inode,dir_index,filetype,^extent,^journal_dev,^flex_bg,^large_file,sparse_super,^uninit_bg ]...
command [mke2fs /dev/sda1 -q -r 1 -L '/boot' -b 1024 -I 128 -O has_journal,resize_inode,dir_index,filetype,^extent,^journal_dev,^flex_bg,^large_file,sparse_super,^uninit_bg ] returned 0
executing [tune2fs /dev/sda1 -U e2eceb1c-371e-4a02-b3be-7ad418a6ac01 -o user_xattr,acl -c 0 -i 0d ]...
command [tune2fs /dev/sda1 -U e2eceb1c-371e-4a02-b3be-7ad418a6ac01 -o user_xattr,acl -c 0 -i 0d ] returned 0
Mount information: []
-[00][ 0%][DIR ] /
...
-[00][ 99%][REGFILEM] /grub/vstafs_stage1_5
-[00][100%][REGFILEM] /.vmlinuz-2.6.18-194.17.1.el5.hmac
[errno=16, Device or resource busy]: oper_restore.c#1315,extractar_filesystem_extract(): cannot umount /tmp/fsa/20120621-073301-00

Dukers
Posts: 19
Joined: Fri Jul 09, 2010 1:31 pm

Re: Cannot recover ext3 image errno=16, Device or resource

Post by Dukers » Thu Jun 21, 2012 7:30 pm

Maybe SELinux is the culprit? Try boot Fedora Live CD with enforcing=0 boot option.

joebidalli
Posts: 3
Joined: Thu Jun 21, 2012 6:39 pm

Re: Cannot recover ext3 image errno=16, Device or resource

Post by joebidalli » Thu Jun 21, 2012 7:57 pm

Tried enforcing=0 at boot and setenforce 0 from the command line. same issue

joebidalli
Posts: 3
Joined: Thu Jun 21, 2012 6:39 pm

Re: Cannot recover ext3 image errno=16, Device or resource

Post by joebidalli » Fri Jun 22, 2012 5:57 pm

Turns out this is a timing issue.

I'm not a programmer but I added a 1sec delay before the unount call in filesys.c. This fixed the problem.

int generic_umount(char *mntbuf)
{
if (!mntbuf)
{ errprintf("invalid param: mntbuf is null\n");
return -1;
}
msgprintf(MSG_DEBUG1, "unmount_partition(%s)\n", mntbuf);
sleep(1);
return umount2(mntbuf, 0);
}

Dukers
Posts: 19
Joined: Fri Jul 09, 2010 1:31 pm

Re: Cannot recover ext3 image errno=16, Device or resource

Post by Dukers » Sat Jun 23, 2012 1:12 am

return umount2(mntbuf, MNT_DETACH);

perhaps?

r900
Posts: 2
Joined: Thu Feb 14, 2013 1:45 am

Re: Cannot recover ext3 image errno=16, Device or resource

Post by r900 » Thu Feb 14, 2013 1:51 am

Dukers wrote:return umount2(mntbuf, MNT_DETACH);

perhaps?
Yeah that seems to work. Could you explain why? For me this only happens on partitions with little data on them (e.g. the boot partition as mentioned before).

Susah
Posts: 4
Joined: Sun Jun 02, 2013 7:56 am

Re: Cannot recover ext3 image errno=16, Device or resource

Post by Susah » Sun Jun 02, 2013 11:59 am

Yikes..bumped into this issue while trying to restore boot partiiton

Code: Select all

[errno=16, Device or resource busy]: oper_restore.c#1315,extractar_filesystem_extract(): cannot umount /tmp/fsa/20130602-114334-00
$ fsarchiver -V
fsarchiver 0.6.16 (2013-02-07)

Admin, not keen on fixing this bug?

Lazy_Kent
Posts: 53
Joined: Sun Nov 15, 2009 1:08 pm
Location: Moscow, Russia

Re: Cannot recover ext3 image errno=16, Device or resource

Post by Lazy_Kent » Sun Jun 02, 2013 12:33 pm

Try the latest version 0.6.17.

Susah
Posts: 4
Joined: Sun Jun 02, 2013 7:56 am

Re: Cannot recover ext3 image errno=16, Device or resource

Post by Susah » Sun Jun 02, 2013 12:50 pm

Tried the latest static build from sourceforge, same issue :(

feffer777
Posts: 21
Joined: Sun May 23, 2010 5:11 am

Re: Cannot recover ext3 image errno=16, Device or resource

Post by feffer777 » Thu Jan 30, 2014 8:07 pm

Same issue restoring an image to an SD card -- the boot partition of a Debian OS. However, despite the error, the data was written. I ran rsync to the card from an existing good directory and nothing changed. Also the card boots my Plug server w/o problem.

Are any of you getting the same result? Namely, an error message but a proper filesystem restore anyway?

monkeybrain
Posts: 1
Joined: Tue Feb 04, 2014 12:13 am

Re: Cannot recover ext3 image errno=16, Device or resource

Post by monkeybrain » Tue Feb 04, 2014 12:24 am

Yeah I have gotten the same error when restoring a Fedora 20 image. Despite the error the restoration appeared to be successful. First time it was aborted at 91% but the second time completed 100% with errors. I rebooted into the restored system and everything works.

I made the .fsa (no error) and restored it from Ubuntu so I don't think the selinux theory applies here. I have imaged and restored many systems this way (by running fsarchiver in Ubuntu) : Ubuntu, Fedora, Debian, Manjaro.. and Fedora is the only OS where problems occur.

Lew_Rockwell_Fan
Posts: 2
Joined: Wed Jun 04, 2014 9:39 am

Re: Cannot recover ext3 image errno=16, Device or resource

Post by Lew_Rockwell_Fan » Wed Jun 04, 2014 10:17 am

Same error here attempting to restore a archived stripped down Ubuntu
to an ext3 filesystem. Running fsarchiver from another partition of the same drive with a similar super-light Ubuntu 14.04. By super-light I mean I started with the mini.iso and added a few things. Openbox for both window manager and DE. Fsarchiver version 0.6.19 (2014-03-01). Restore aborts and leaves the (partially restored? I can't easily tell because I'm restoring it over a similar system that is the borked descendent of the one I'm restoring.) mounted to a directory in /tmp.

There are 2 successful work-arounds mentioned above. But I haven't figured out how to apply either of them.

joebidalli's solution seems simple enough, but where is this "filesys.c" I need to edit? That "sleep(1);" doesn't look like bash, is it a script at all or some source code I'm supposed to edit and recompile?

Dukers' solution that r900 endorses looks simple too, but where is it supposed to go?

I've been counting on fsa to rescue me when I tweak something till it breaks. I'd hate to have to rebuild that system from scratch.

If somebody wouldn't mind explaining at least one of those solutions in sufficient detail for a dumbass country boy to understand I'd be most grateful.

Lew_Rockwell_Fan
Posts: 2
Joined: Wed Jun 04, 2014 9:39 am

Re: Cannot recover ext3 image errno=16, Device or resource

Post by Lew_Rockwell_Fan » Wed Jun 25, 2014 9:12 am

Not a very active forum I fear. For the potential benefit of people as clueless as myself, they are talking about the source code. I downloaded it from the Ubuntu repo, used a text editor and searched for the code quoted in joebidalli's post, added his sleep(1) in the same place, and followed some "how to compile" guide I found somewhere and it worked.

Thanks, Joe!

I neglected to keep notes which is why I'm kind of vague. I made one mistake though. I should have made and kept something like a .deb file. Now I'll have to do it again for my other systems. I'll try to keep notes and post them here, since it is likely people looking for this will find this page.

chabapok
Posts: 1
Joined: Mon Mar 30, 2015 3:28 pm

Re: Cannot recover ext3 image errno=16, Device or resource

Post by chabapok » Mon Mar 30, 2015 3:33 pm

sleep(1) is not 100% correct way. Use sync() with sleep()

Code: Select all

#include <unistd.h>
...

int generic_umount(char *mntbuf)
{
    if (!mntbuf)
    {   errprintf("invalid param: mntbuf is null\n");
        return -1;
    }
    msgprintf(MSG_VERB1, "invorking sync()\n");
    sync();
    sleep(1);
    msgprintf(MSG_DEBUG1, "unmount_partition(%s)\n", mntbuf);
    return umount2(mntbuf, MNT_DETACH);
}


it's works fine.

admin
Site Admin
Posts: 550
Joined: Sat Feb 21, 2004 12:12 pm

Re: Cannot recover ext3 image errno=16, Device or resource

Post by admin » Thu Jan 07, 2016 9:24 pm

This bug has been fixed in fsarchiver-0.6.21

Post Reply