Blog of Veikko M.O.T. Nyfors, Hybrid Quantum ICT consultant

Quantum Mechanics demystified, a try

Project maintained by veikkonyfors Hosted on GitHub Pages — Theme by mattgraham

Finding the disk space hog directories on googledrive


Even though disk space is pretty cheap at cloud services nowadays, some are interested to keep cloud storage clean of waste. Few are even trying to get along with the initial free chunk of storage as long as possible.
For people like that, I present a method to find out major disk space hogs in cloud. Handy for others as well, I would imagine.
Hogs tend to be directories which either contain a few large files or tons of smaller ones at base level (i.e. not including subdirectories). For me these mostly are directories containing e.g. pictures and short videos of summer holidays, which I am used to gather in their own folders.

Google Drive has currently initial 15GB of free storage, 100GB will be 1.99Eur/Month, 200GB 2.99Eur/Month and 2TB 9.99Eur/Month. OneDrive and iCloud have similar plans. Among others.
Initially I will cover Google Drive, but will be back with others as time permits.

Google itself provides a method to find largest individual files. At mydrive screen (

Unfortunately this does not reveal folders that have numerous not so big files. Like those folders of summer holiday photos.

To find those you first have to mount Google Drive on a system of yours.
Google Drive is a Fuse filesystem, one needs to install ‘Google Drive Ocamlfuse’ (google-drive-ocamlfuse) and related software to have it available.

Mounting Google Drive on Debian instance on Google Cloud Platform

I carried this out in my Debian instance at Google Cloud Platform by adhering to directions in these two links below

How to mount Google Drive on Linux •
How to Install Google Drive Ocamlfuse on Debian •

Had to compose a bit to have a perfect hit. But that’s what we most often have to do in the end.

Mounting Google Drive on Ubuntu 20.04 laptop

On Ubuntu installing google-drive-ocamlfuse is somewhat easier, using apt repository ppa:alessandro-strada/ppa.

pappa@pappa-ThinkPad-X270:~$ sudo add-apt-repository ppa:alessandro-strada/ppa
[sudo] password for pappa: 
 Mount Google Drive on Ubuntu (via FUSE)
 More info:
Press [ENTER] to continue or Ctrl-c to cancel adding it.

Hit:1 focal InRelease
Ign:2 stable InRelease                                                              
Get:3 stable InRelease [1 811 B]                                                                   
Get:4 focal InRelease [17,5 kB]                                                    
Get:5 stable Release [944 B]                     
Hit:6 stable InRelease                                                     
Get:7 stable Release.gpg [819 B]
Get:8 focal-security InRelease [114 kB]                 
Get:9 stable/main amd64 Packages [1 095 B]
Hit:10 focal InRelease            
Get:11 stable/main amd64 Packages [713 B]
Get:12 focal/main amd64 Packages [1 672 B]
Get:13 focal/main Translation-en [1 196 B]
Get:14 focal-security/main amd64 Packages [1 631 kB]    
Get:15 focal-security/main i386 Packages [471 kB]
Get:16 focal-security/main Translation-en [277 kB]
Get:17 focal-security/main amd64 DEP-11 Metadata [40,8 kB]
Get:18 focal-security/main amd64 c-n-f Metadata [10,8 kB]
Get:19 focal-security/universe amd64 Packages [711 kB]
Get:20 focal-security/universe i386 Packages [557 kB]
Get:21 focal-security/universe amd64 DEP-11 Metadata [66,6 kB]
Get:22 focal-security/universe amd64 c-n-f Metadata [14,6 kB]
Get:23 focal-security/multiverse amd64 DEP-11 Metadata [2 464 B]
Fetched 3 922 kB in 2s (1 595 kB/s)                                        
Reading package lists... Done
pappa@pappa-ThinkPad-X270:~$ sudo apt update
Hit:1 focal InRelease
Ign:2 stable InRelease                                        
Hit:3 stable InRelease                                                                             
Hit:4 focal InRelease                                                              
Hit:5 stable Release                                                                
Hit:6 stable InRelease                                                                                  
Hit:7 focal InRelease                         
Hit:8 focal-security InRelease                
Reading package lists... Done
Building dependency tree       
Reading state information... Done
6 packages can be upgraded. Run 'apt list --upgradable' to see them.
pappa@pappa-ThinkPad-X270:~$ sudo apt install google-drive-ocamlfuse
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libbs2b0 libfwupdplugin1 libllvm11 shim
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
0 upgraded, 1 newly installed, 0 to remove and 6 not upgraded.
Need to get 1 675 kB of archives.
After this operation, 8 442 kB of additional disk space will be used.
Get:1 focal/main amd64 google-drive-ocamlfuse amd64 0.7.30-0ubuntu1~ubuntu20.04.1 [1 675 kB]
Fetched 1 675 kB in 1s (1 259 kB/s)                     
Selecting previously unselected package google-drive-ocamlfuse.
(Reading database ... 297841 files and directories currently installed.)
Preparing to unpack .../google-drive-ocamlfuse_0.7.30-0ubuntu1~ubuntu20.04.1_amd64.deb ...
Unpacking google-drive-ocamlfuse (0.7.30-0ubuntu1~ubuntu20.04.1) ...
Setting up google-drive-ocamlfuse (0.7.30-0ubuntu1~ubuntu20.04.1) ...
Processing triggers for man-db (2.9.1-1) ...
pappa@pappa-ThinkPad-X270:~$ google-drive-ocamlfuse
[10133:10133:0100/] InitializeSandbox() called with multiple threads in process gpu-process.
Access token retrieved correctly.
pappa@pappa-ThinkPad-X270:~$ mkdir ~/googledrive
pappa@pappa-ThinkPad-X270:~$ google-drive-ocamlfuse ~/googledrive
pappa@pappa-ThinkPad-X270:~$ cd googledrive/

Finding the hog

After you have mounted Google Drive on your system, you just run the one-liner I have presented at Finding the disk space hog at the mountpoint where you mounted the drive. For most Unix boxes, including Linux, below works:

find . -type d -exec du -sS {} \; >/tmp/finddu.out 2>/dev/null && cat /tmp/finddu.out | sort -nr | head

Sample output below.

veikkonyfors@instance-1:~$ google-drive-ocamlfuse ~/googledrive/   # Mount the drive
veikkonyfors@instance-1:~$ cd googledrive/  # cd there
veikkonyfors@instance-1:~/googledrive$ find . -type d -exec du -sS {} \; >/tmp/finddu.out 2>/dev/null && cat /tmp/finddu.out | sort -nr | head -50
5040689	./Google Photos
2393937	./D610/pic/20110731_pätiälä
1492605	./Pic/201808_sligo
523633	./Pic/VeeraOTR022018
369502	./.shared
254384	./.shared/matkaaja
239999	./Pic/whatsapp
145551	./Pic/spania_teijo
138355	./Pic
107534	./Pic/Pappasusi_20082014
100640	.
95558	./Pic/Pappakatti
91086	./Snd
82478	./doc/qf
67686	./doc/wheels
61093	./D610/pic
60448	./Pic/2003-11-27
54435	./Pic/20140302_pappakalaksi
54425	./D610/nyfors/dat/mov
47527	./Pic/2003-09-06
44821	./weto/src/cmd/meri/meritext/obsolete
35757	./show
35586	./Snd/ringtones
34099	./D610/pic/20070614_kesalahti
31958	./weto/src/cmd/meri/meritext
25187	./doc
22713	./weto/wrk/hil_koe
21979	./huvi/paitsi/2019
21709	./.shared/Week 2 Study material
21434	./Pic/whatsapp/Sent
19814	./weto/lib
19128	./weto/src/cmd/hil_pp_new
18659	./D610/nyfors/dev/setec
18258	./weto/src/cmd/radar_server/save
14829	./weto/src/cmd/meritele
14512	./Pic/show
13641	./huvi/dublin_sligo
13506	./weto/src/cmd/gribsplit
13255	./weto/etc/ila
13113	./viware/wrk/EFM32_Zero_Gecko_ARM
12831	./weto/src/cmd/getaws
12124	./TIETO
11037	./D610/pic/papankapula_200711225
10856	./D610/nyfors/dev/iss/ekahau/.metadata/.plugins/org.eclipse.jdt.core
10736	./D610/nyfors/dev/iss/ekahau/lib
10718	./D610/pic/2004-02-16
10403	./weto/src/cmd/postproc
10387	./weto/src/cmd/ydinmasto
10357	./D610/nyfors/dev/iss/moxa/.metadata/.plugins/org.eclipse.cdt.core
10254	./D610/pic/20090717_pappa