3

After running following command, related: How do I unpin and remove all IPFS content from my machine?:

# unpin and remove all IPFS content from my machine
ipfs pin ls --type recursive | cut -d' ' -f1 | ifne xargs -n1 ipfs pin rm
ipfs repo gc

Size of the .ipfs repo still remains as it is:

$ du -sh ~/.ipfs
1.4G    .ipfs

I can do rm -rf ~/.ipfs && ipfs init but my IPFS id is re-initialized where I want to keep my original peer identity without removing it.

I want to completely clean content of the IPFS repo. How can I achieve it? I observe that after removing pinned objects still size of the ~/.ipfs is not changed.

alper
  • 2,919
  • 9
  • 53
  • 102

2 Answers2

1

The ipfs garbage collector isn’t enabled by default and caches can grow unrestrained unless garbage collection is run manually or enabled to run on a schedule.

Try running Garbage Collection via the command

ipfs repo gc

Note: pinned resources are never deleted by the garbage collector.

Read more over here: https://docs.ipfs.io/concepts/persistence/#garbage-collection.

Jordan
  • 1,879
  • 3
  • 19
  • 25
  • even I unpinned all the files and run : `ipfs rep gc` the rep does not completely cleaned – alper Jun 05 '22 at 20:32
0

removing pinned objects do not change repo size. Blocks will be deleted during GC later if they are not used by anything else like MFS.

If you are using flatfs datastore, then storage space will be freed. In badgerds they will be overwritten by newer content but usually not freed.

Radim Kolář
  • 433
  • 1
  • 4
  • 9