IPFS datastore large for size of files on local node

I started running a new local ipfs node this weekend, and I noticed that the amount of content hosted on my machine was significantly greater than the amount of pinned files after manual garbage collection.

Screenshot from 2022-02-14 17-29-51

I am running ipfs with the command /usr/local/bin/ipfs daemon --enable-gc as a service on Ubuntu 20.0.4.

Garbage collection is scheduled to run every 5 minutes, and I should only be serving pinned content from my node.

What would be the cause of the large size of the stored blocks, and how would I be able to shrink the size of the datastore?

ipfs repo stat
NumObjects: 12
RepoSize:   281974542
StorageMax: 10000000000000
RepoPath:   /mnt/md0/.ipfs_node
Version:    fs-repo@11
sudo du -sh .ipfs_node
270M	.ipfs_node
sudo du -sh .ipfs_node/datastore
266M	.ipfs_node/datastore
sudo du -sh .ipfs_node/blocks
4.1M	.ipfs_node/blocks

Since I set Reproviding.Strategy to pinned and ran ipfs repo gc several times to manually remove the unpinned files, I would expect the size of the datastore to be around 20KB or even 1MB for leftover logging data/other information. Even if the datastore was storing peer data and logs, I would expect the size to be in the megabytes rather than the hundred of megabytes.

I have also provided the full config file for further details.

{
	"API": {
		"HTTPHeaders": {
			"Access-Control-Allow-Methods": [
				"PUT",
				"POST"
			],
			"Access-Control-Allow-Origin": [
				"*"
			]
		}
	},
	"Addresses": {
		"API": "/ip4/127.0.0.1/tcp/5001",
		"Announce": [],
		"AppendAnnounce": [],
		"Gateway": "/ip4/127.0.0.1/tcp/8080",
		"NoAnnounce": [],
		"Swarm": [
			"/ip4/0.0.0.0/tcp/4001",
			"/ip6/::/tcp/4001",
			"/ip4/0.0.0.0/udp/4001/quic",
			"/ip6/::/udp/4001/quic"
		]
	},
	"AutoNAT": {},
	"Bootstrap": [
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmbLHAnMoJPWSCR5Zhtx6BHJX9KiKNN6tpvbUcqanj75Nb",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmcZf59bWwK5XFi76CZX8cbJ4BhTzzA3gU1ZjYZcYW3dwt",
		"/ip4/104.131.131.82/tcp/4001/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
		"/ip4/104.131.131.82/udp/4001/quic/p2p/QmaCpDMGvV2BGHeYERUEnRQAwe3N8SzbUtfsmvsqQLuvuJ",
		"/dnsaddr/bootstrap.libp2p.io/p2p/QmNnooDu7bfjPFoTZYxMNLWUQJyrVwtbZg5gBMjTezGAJN"
	],
	"DNS": {
		"Resolvers": {}
	},
	"Datastore": {
		"BloomFilterSize": 0,
		"GCPeriod": "5m",
		"HashOnRead": false,
		"Spec": {
			"mounts": [
				{
					"child": {
						"path": "blocks",
						"shardFunc": "/repo/flatfs/shard/v1/next-to-last/2",
						"sync": true,
						"type": "flatfs"
					},
					"mountpoint": "/blocks",
					"prefix": "flatfs.datastore",
					"type": "measure"
				},
				{
					"child": {
						"compression": "none",
						"path": "datastore",
						"type": "levelds"
					},
					"mountpoint": "/",
					"prefix": "leveldb.datastore",
					"type": "measure"
				}
			],
			"type": "mount"
		},
		"StorageGCWatermark": 95,
		"StorageMax": "10TB"
	},
	"Discovery": {
		"MDNS": {
			"Enabled": true,
			"Interval": 10
		}
	},
	"Experimental": {
		"AcceleratedDHTClient": false,
		"FilestoreEnabled": false,
		"GraphsyncEnabled": false,
		"Libp2pStreamMounting": false,
		"P2pHttpProxy": false,
		"StrategicProviding": false,
		"UrlstoreEnabled": false
	},
	"Gateway": {
		"APICommands": [],
		"HTTPHeaders": {
			"Access-Control-Allow-Headers": [
				"X-Requested-With",
				"Range",
				"User-Agent"
			],
			"Access-Control-Allow-Methods": [
				"GET"
			],
			"Access-Control-Allow-Origin": [
				"*"
			]
		},
		"NoDNSLink": false,
		"NoFetch": true,
		"PathPrefixes": [],
		"PublicGateways": null,
		"RootRedirect": "",
		"Writable": false
	},
	"Identity": {
		"PeerID": "12D3KooWG73vwFcmaNXdCEFfZSGVLvimRPE8kZHBYivwPLkC2zXg"
	},
	"Internal": {},
	"Ipns": {
		"RecordLifetime": "",
		"RepublishPeriod": "",
		"ResolveCacheSize": 128
	},
	"Migration": {
		"DownloadSources": [],
		"Keep": ""
	},
	"Mounts": {
		"FuseAllowOther": true,
		"IPFS": "/ipfs",
		"IPNS": "/ipns"
	},
	"Peering": {
		"Peers": [
			{
				"Addrs": [],
				"ID": "QmcfgsJsMtx6qJb74akCw1M24X1zFwgGo11h1cuhwQjtJP"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWEGeZ19Q79NdzS6CJBoCwFZwujqi5hoK8BtRcLa48fJdu"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWBnmsaeNRP6SCdNbhzaNHihQQBPDhmDvjVGsR1EbswncV"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWDLYiAdzUdM7iJHhWu5KjmCN62aWd7brQEQGRWbv8QcVb"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWFZmGztVoo2K1BcAoDEUmnp7zWFhaK5LcRHJ8R735T3eY"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWRJpsEsBtJ1TNik2zgdirqD4KFq5V4ar2vKCrEXUqFXPP"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWNxUGEN1SzRuwkJdbMDnHEVViXkRQEFCSuHRTdjFvD5uw"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWMZmMp9QwmfJdq3aXXstMbTCCB3FTWv9SNLdQGqyPMdUw"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWCpu8Nk4wmoXSsVeVSVzVHmrwBnEoC9jpcVpeWP7n67Bt"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWGx5pFFG7W2EG8N6FFwRLh34nHcCLMzoBSMSSpHcJYN7G"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWQsVxhA43ZjGNUDfF9EEiNYxb1PVEgCBMNj87E9cg92vT"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWMSrRXHgbBTsNGfxG1E44fLB6nJ5wpjavXj4VGwXKuz9X"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWE48wcXK7brQY1Hw7LhjF3xdiFegLnCAibqDtyrgdxNgn"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWSGCJYbM6uCvCF7cGWSitXSJTgEb7zjVCaxDyYNASTa8i"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWJbARcvvEEF4AAqvAEaVYRkEUNPC3Rv3joebqfPh4LaKq"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWNcshtC1XTbPxew2kq3utG2rRGLeMN8y5vSfAMTJMV7fE"
			},
			{
				"Addrs": [],
				"ID": "QmWaik1eJcGHq1ybTWe7sezRfqKNcDRNkeBaLnGwQJz1Cj"
			},
			{
				"Addrs": [],
				"ID": "QmNfpLrQQZr5Ns9FAJKpyzgnDL2GgC6xBug1yUZozKFgu4"
			},
			{
				"Addrs": [],
				"ID": "QmPo1ygpngghu5it8u4Mr3ym6SEU2Wp2wA66Z91Y1S1g29"
			},
			{
				"Addrs": [],
				"ID": "QmRjLSisUCHVpFa5ELVvX3qVPfdxajxWJEHs9kN3EcxAW6"
			},
			{
				"Addrs": [],
				"ID": "QmPySsdmbczdZYBpbi2oq2WMJ8ErbfxtkG8Mo192UHkfGP"
			},
			{
				"Addrs": [],
				"ID": "QmSarArpxemsPESa6FNkmuu9iSE1QWqPX2R3Aw6f5jq4D5"
			},
			{
				"Addrs": [],
				"ID": "QmUEMvxS2e7iDrereVYc5SWPauXPyNwxcy9BXZrC1QTcHE"
			},
			{
				"Addrs": [],
				"ID": "QmNSYxZAiJHeLdkBg38roksAR9So7Y5eojks1yjEcUtZ7i"
			},
			{
				"Addrs": [],
				"ID": "QmUd6zHcbkbcs7SMxwLs48qZVX3vpcM8errYS7xEczwRMA"
			},
			{
				"Addrs": [],
				"ID": "QmbVWZQhCGrS7DhgLqWbgvdmKN7JueKCREVanfnVpgyq8x"
			},
			{
				"Addrs": [],
				"ID": "QmdnXwLrC8p1ueiq2Qya8joNvk3TVVDAut7PrikmZwubtR"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWQtpvNvUYFzAo1cRYkydgk15JrMSHp6B6oujqgYSnvsVm"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWQcgCwNCTYkyLXXQSZuL5ry1TzpM8PRe9dKddfsk1BxXZ"
			},
			{
				"Addrs": [],
				"ID": "QmR69wtWUMm1TWnmuD4JqC1TWLZcc8iR2KrTenfZZbiztd"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWR19qPPiZH4khepNjS3CLXiB7AbrbAD4ZcDjN1UjGUNE1"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWEDMw7oRqQkdCJbyeqS5mUmWGwTp8JJ2tjCzTkHboF6wK"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWPySxxWQjBgX9Jp6uAHQfVmdq8HG1gVvS1fRawHNSrmqW"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWNuoVEfVLJvU3jWY2zLYjGUaathsecwT19jhByjnbQvkj"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWSnniGsyAF663gvHdqhyfJMCjWJv54cGSzcPiEMAfanvU"
			},
			{
				"Addrs": [],
				"ID": "12D3KooWKytRAd2ujxhGzaLHKJuje8sVrHXvjGNvHXovpar5KaKQ"
			}
		]
	},
	"Pinning": {
		"RemoteServices": {}
	},
	"Plugins": {
		"Plugins": null
	},
	"Provider": {
		"Strategy": ""
	},
	"Pubsub": {
		"DisableSigning": false,
		"Router": ""
	},
	"Reprovider": {
		"Interval": "12h",
		"Strategy": "pinned"
	},
	"Routing": {
		"Type": "dht"
	},
	"Swarm": {
		"AddrFilters": null,
		"ConnMgr": {
			"GracePeriod": "20s",
			"HighWater": 900,
			"LowWater": 600,
			"Type": "basic"
		},
		"DisableBandwidthMetrics": false,
		"DisableNatPortMap": false,
		"RelayClient": {},
		"RelayService": {},
		"Transports": {
			"Multiplexers": {},
			"Network": {},
			"Security": {}
		}
	}
}

By fully participating in the IPFS network you become a DHT node and consequentially provide routing for content and peers in the network.

If you don’t want that you can probably switch to “Routing” → “dhtclient” (check docs).

I don’t think GC touches the datastore folder though, you may need to manually remove the datastore folder or re-initialize if the size does not go down after a day (when records expire).

According to the docs,

In client mode, your node will query the DHT as a client but will not respond
to requests from other peers. This mode is less resource intensive than server
mode.

The intended behavior that I want would be to serve content from my local node that is pinned and nothing else. Since I have Reprovider.Strategy: pinned and Gateway.NoFetch: true, I would expect to already get this intended behavior.

Would setting Routing.Type to dhtclient still allow other peers to request the pinned content on my local node and serve that to the network? Since I do not expect my pinned content to be accessed frequently, I would like to guarantee that it is available by at least having my local node serve it.

Reprovider strategy is just choosing which blocks are announced to the DHT (meaning, your node will be asking other nodes to advertise that your node has those blocks). In your case using pinned will make your node only announce the root CIDs of your pins and not the underlying blocks. I think you should leave that set to all.

Routing type dhtclient will make your node be a client to the DHT (i.e. ask other nodes to store routing information for your blocks but not have your node store routing information for other people’s blocks).

Your node will still always serve the blocks that it has, when they are requested.

I will monitor if the records expire after a day and shrink the size of the datastore.

That seems to have done the trick and resolved my issue!