1

I am very new in Ubuntu. I just plugged my mobile in Ubuntu and the two memory cards appears to me. But I was interested to find out the total free space and how much used for each folder. I guess that I have to use df + something.

Radu Rădeanu
  • 169,590
DemeCarv
  • 185
  • 1
  • 10

1 Answers1

0

No, you won't use df, you'll use du, which is a tool that displays disk usage.

You first need to find out where your mobile phone has been mounted. If you're using Ubuntu 12.10 or later, it'll most likely be mounted under /run/user/<login>/gvfs on a folder called mtp:host=<someNumbers>.

Here is how mine looks like right now:

aa@aa-ul:~$ ls /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/ -l
total 0
drwx------ 1 aa aa 0 Jan  1  1970 Internal storage
drwx------ 1 aa aa 0 Jan  1  1970 SD card

So if I wanted to find out the size of each of the folders under SD card, I would run this command:

du -h -d1 /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/SD\ card/

This means:

  • du is the command,
  • -h is to show sizes in human readable format, for example MB or GB,
  • -d1 means go down only one directory (or "folder"). This means "show me the sizes of all the directories inside SD card only, and not the directories inside those directories. If you want to see the sizes of all the subdirectories, remove -d1 from the command, but this will cause the command to take longer and display a lot of lines,
  • /run/user/1000/gvfs/mtp\:host\=%5Busb%3A002%2C005%5D/SD\ card/ is the path.

Here is how my output looks like:

0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/LOST.DIR
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/TWRP
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/.dataviz
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/Playlists
512     /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/Android
5.2G    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/clockworkmod
760M    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/DCIM
0       /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/data
455M    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/Music
481M    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/New folder
6.9G    /run/user/1000/gvfs/mtp:host=%5Busb%3A002%2C005%5D/SD card/

The total size of the SD card folder is 6.9GB.

I don't know how to show the total free disk space from the command line though. You can see it from the GUI: right click > Properties.

Alaa Ali
  • 31,535
  • Alaa, thanks, but I am sure that mine isn't only 23 Mega 23M /run/user/1000/gvfs/gphoto2:host=%5Busb%3A001%2C004%5D/store_00020002 or 24M /run/user/1000/gvfs/gphoto2:host=%5Busb%3A001%2C004%5D/store_00010001 after I typed: du -h -d1 /run/user/1000/gvfs/gphoto2:host=%5Busb%3A001%2C004%5D/store_00010001 – DemeCarv Jul 28 '14 at 03:44
  • Raj, thanks but I think it doesn't help me: deme@PC:~$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 465,8G 0 disk ├─sda1 8:1 0 461,8G 0 part / ├─sda2 8:2 0 1K 0 part └─sda5 8:5 0 4G 0 part [SWAP] sr0 11:0 1 1024M 0 rom – DemeCarv Jul 28 '14 at 03:47
  • Hi all, is there some tool that I could install and it works similar to windows explorer? I didn't find a easy way to see the space size. – DemeCarv Jul 28 '14 at 03:48
  • 1
    @user79885 your output shows gphoto, that means your phone is mounted as a "Camera (PTP)" device. This option only mounts the "camera" part of your phone, and only shows the folder containing pictures, that's why it's pretty small. On my phone (Galaxy Note 2), there are USB Connectivity Options that allow me to mount it as a "Media device (MTP)" or "Camera (PTP)". Check if your phone has the same options, and choose MTP instead. – Alaa Ali Jul 28 '14 at 04:48