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.

4
  • 2
    As much as ipfs is an important component of the decentralized web, I don't think this question is on-topic for this site. I'm not exactly sure where you can look for answers to this question. Maybe someone else can suggest somewhere. – Tjaden Hess Dec 12 '16 at 15:50
  • Based on guidance I have asked question on stack-overflow. If anyone interested could follow the problem. stackoverflow.com/q/41105951/2402577 – alper Dec 12 '16 at 17:29
  • 1
    I would actually ask on the Unix stack exchange, as well, I think it would fit better there. – Tjaden Hess Dec 12 '16 at 17:30
  • Same question is asked on Unix stack exchange: unix.stackexchange.com/q/329894/198423 – alper Dec 13 '16 at 5:54
2

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.

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