3

Please note that this question is related to IPFS (https://ipfs.io).

Is it possible to mount ~/.ipfs folder to an external device (such as: hard-disk, network drive, WD My book etc.)? This will help to share ~/.ipfs folder between different nodes. I was not sure that IPFS is designed to have that file system shared between nodes (simultaneously?).

Please note that I am mounting into my WD My book External Hard Drive (https://www.wdc.com/products/wd-recertified/my-book.html , File system NTFS). Please see my mounting line of code:

    $ mkdir /mnt/cifs
    $ sudo mount -t cifs //server-name/share-name /mnt/cifs -o \
                                    username=admin,password=my_password,uid=1000    
    $ mount | grep 'cifs’
    //server-name/share-name on /mnt/cifs type cifs (rw)

After I have mount ~/.ipfs folder, when I try to run ipfs init or ipfs add <filename>, I have faced with the following error:

Error: fsync: invalid argument

When: ipfs add <filename> runs, it creates block files inside created folders as follows: ~/.ipfs/blocks/<created_folder_name>.

~/.ipfs/blocks$ ls
CIQA2  CIQBE  CIQCP  CIQDV  CIQF7  CIQGF  CIQHL  CIQIY  CIQK5  CIQLB  CIQMG  CIQNM  CIQOR
CIQA3  CIQBF  CIQCQ  CIQDW  CIQFA  CIQGG  CIQHM  CIQIZ  CIQK6  CIQLC  CIQMH  CIQNN  CIQOS
CIQA4  CIQBG  CIQCR  CIQDX  CIQFB  CIQGH  CIQHN  CIQJ2  CIQK7  CIQLD  CIQMI  CIQNO  CIQOU

Ex: After ipfs init is executed, only one file is created under each created folder.

$ ~/.ipfs/blocks$ ls */
/home/.ipfs/blocks/CIQMJ:
CIQMJCAMEI4UXBQ35CUDVVJOGU3DNWNHI7O7JCWHWNMUWPGKPOTLFYY.data //coming from mounted device.

/home/.ipfs/blocks/CIQMK:
CIQMKGZXBKZV262ZN6ABE4SUO5BNGKVSPTGAQXSOC35UUK7FUPIIAIY.data //coming from mounted device.

Further, after running ipfs add <filename> a new folder is created with a file inside. I have mounted that folder to my external device, it fixes the error I was facing with.

enter image description here

But if ipfs add <filename> adds a new block file into a already created folder under ~/.ipfs/blocks => it gives the same error: Error: fsync: invalid argument.

/home/.ipfs/blocks/CIQMI:
CIQMI5TLEXEWEYC3G3WELU6ONMKNLAF6CZUXU5BTWEU453LHPTUNNEI.data //coming from mounted device.
CIQMIRQGFPT23SZ6XYFFU45GLZENEWRYI7PR3YJ7EP7ZC6I4ME7GPFQ.data //newly added file

The script I have write to test:

After running ipfs init only one time following script is executed.

$ sudo mount -t cifs //server-name/share-name /mnt/cifs -o username=admin,password=my_password,uid=1000
$ ipfs init
$ cd ~/.ipfs/blocks/
for d in */ ; do
   if [ ! -d /mnt/cifs/$d ]; then
        mkdir /mnt/cifs/$d
        cp $d/* /mnt/cifs/$d/
   fi
done

To revert the files from external device before running: ipfs add <filename>: Now all the folders inside ~/.ipfs/blocks/ actually mounted to my external device.

sudo mount -t cifs //<ip_address>/mybloc/ ~/.ipfs/blocks/ -o username=admin,password=my_password,uid=1000

Thank you for your valuable help and time.

  • 1
    Please don't post images of text. Looks like that particular image is not critical to your question, however. – jayhendren Dec 12 '16 at 19:14
  • I am very sorry, I have removed the image. – alper Dec 13 '16 at 2:26
  • 1
    It'd be much, much better to just ask the IPFS folks directly whether it can be used this way. I'd guess no, but if the answer is yes, Error: fsync: invalid argument is probably a bug that you should report. – strugee Dec 13 '16 at 6:33
0

I guess I was able to solve the problem I was facing. After ipfs init is executed, 15 new files each inside unique folder name is created. Those files should not be deleted (I assume those files do contain root of the Merkle tree). I have used the following line sudo chattr +i */* to make them immutable.

~/.ipfs/blocks$ ls
CIQBE  CIQCC  CIQDT  CIQFF  CIQGC  CIQJ2  CIQJB  CIQJX  CIQKZ  CIQOA  CIQOL
CIQBG  CIQD4  CIQF2  CIQFT  CIQIF  CIQJA  CIQJF  CIQKK  CIQO2  CIQOH
~/.ipfs/blocks$ ls *
CIQBE:
CIQBED3K6YA5I3QQWLJOCHWXDRK5EXZQILBCKAPEDUJENZ5B5HJ5R3A.data

CIQBG:
CIQBGFIS77LXFM54VZKTDSZ3VKRE6ITTNAQEFHMC2H3ESKBPC3BVCYA.data
...

Further before running ipfs add <file_name> , sudo umount ~/.ipfs/blocks/ should be executed. This will make ipfs to believe that only the files and folders exists that are created right after ipfs init is executed. (Inside my ~/.ipfs/blocks folder should contain only the folders and files that are created right after ipfs init is executed. )

I have to double check but I believe each *.data file name is unique related to information it contains, hence same file name of each <file>.data won't be generated. So overwriting into same .dat file would be not a problem.

Later on new generated files and folders via ipfs add <filename> should be copy into the external drive and should deleted from ~/.ipfs folder.

Before doing any ipfs cat <hash-id> we should do:

sudo mount -t cifs //<ip_address>/mybloc/ ~/.ipfs/blocks/ -o username=admin,password=my_password,uid=1000 

Which would lead ipfs to have access to already created .data files that actually exist in the external drive.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.