fdupoux / fsarchiver

file system archiver for linux
http://www.fsarchiver.org
GNU General Public License v2.0
263 stars 42 forks source link

cannot make filesystem ext4 on partition /dev/loop0 #91

Closed shumvgolove closed 4 years ago

shumvgolove commented 4 years ago

Downstream issue.

In order to obtain files from the .fsa archive I use this simple trick:

  1. Creating a dummy block:
    $ dd if=/dev/zero of=test.img count=1024 bs=1M
    1024+0 records in
    1024+0 records out
  2. Creating a loop device:
    $ losetup /dev/loop0 test.img
    $ losetup -a
    /dev/loop/0: []: (/home/my_user/test.img)
  3. Restoring .fsa:
    $ fsarchiver restfs backup_test.fsa id=0,dest=/dev/loop0

In the third step, fsarchiver throws this error:

fs_ext2.c#373,extfs_mkfs(): command [mke2fs /dev/loop0  -q  -F    -b 4096  -U 3671e993-ecaa-44a9-baca-89935e15ffa9  -I 256  -r 1  -O has_journal,ext_attr,resize_inode,dir_index,^sparse_super2,filetype,extent,^journal_dev,flex_bg,^meta_bg,^mmp,64bit,^inline_data,^ea_inode,^large_dir,large_file,huge_file,sparse_super,^uninit_bg,dir_nlink,extra_isize,^bigalloc,metadata_csum,^project ] failed with return status=1
oper_restore.c#1296,extractar_filesystem_extract(): cannot make filesystem ext4 on partition /dev/loop0

I am using Alpine Linux distribution, which in turn uses musl libc and busybox as user space toolset.

marcosfrm commented 4 years ago

Run mke2fs manually without -q option to see if it gives any clue.

shumvgolove commented 4 years ago

I've got this:

$ mke2fs /dev/loop0  -F    -b 4096  -U 3671e993-ecaa-44a9-baca-89935e15ffa9  -I 256  -r 1  -O has_journal,ext_attr,resize_inode,dir_index,^sparse_super2,filetype,extent,^journal_dev,flex_bg,^meta_bg,^mmp,64bit,^inline_data,^ea_inode,^large_dir,large_file,huge_file,sparse_super,^uninit_bg,dir_nlink,extra_isize,^bigalloc,metadata_csum,^project
mke2fs 1.45.6 (20-Mar-2020)
mke2fs: invalid blocks '-F' on device '/dev/loop0'
marcosfrm commented 4 years ago

Try to move /dev/loop0 to the end. It appears mke2fs get confused (not sure how) if the device is specified before -b option.

shumvgolove commented 4 years ago

Shouldn't /dev/loop0 be after the arguments? At least mke2fs man page suggest this.

Edit: sure, give me a moment.

shumvgolove commented 4 years ago

Yes, as you have suggested, bringing /dev/loop0 as the last argument correctly creates the filesystem, but I am not sure tho why it passes device as the first argument.

shumvgolove commented 4 years ago

I've tried running fsarchiver on the Arch Linux and there everything works fine.

Here is the Arch Linux fsarvhiver build package and here is the Alpine Linux build package. It seems there is no difference between them and their build dependencies.

marcosfrm commented 4 years ago

musl's getopt() implementation must diverge somehow.

Yes, we must follow each mkfs tool man page. I will prepare a PR.