Available space on usb hdd without mounting (just plugged in)

It is silly that until now, i still can’t confirm if there is way to know available hdd space for use without the hdd being mounted.

$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 1.8T 0 disk
|-sda1 8:1 0 931.3G 0 part /home
|-sda2 8:2 0 465.7G 0 part /
-sda3 8:3 0 466G 0 part /usr sdb 8:16 0 931.5G 0 disk |-sdb1 8:17 0 300M 0 part /boot/efi -sdb2 8:18 0 931.2G 0 part
sdc 8:32 0 298.1G 0 disk <—
`-sdc1 8:33 0 298.1G 0 part <----

I want to know is there way to know available usb external hdd space without having to mount it ? prefer cmdline.

Need to know the whole hdd total space, and available space left and total available space on each partition of the hdd.

I just plugged two portables - they are not mounted - just plugged

 $ lsblk
[...]
sdj           8:144  0   1,8T  0 disk 
└─sdj1        8:145  0   1,8T  0 part 
sdk           8:160  0   1,8T  0 disk 
├─sdk1        8:161  0   263G  0 part 
├─sdk2        8:162  0    32M  0 part 
└─sdk3        8:163  0   1,6T  0 part 
[...]

You can know how many partitions and their size but much space is free or used - will depend on the filesystem - and to query such info you need to mount it - usually.

Please see the nice find by @Denis_Pom :point_down:

parted, fdisk, lsblk and other commands will give you the total space used by partitions, and the total space on the disk. You will need to calculate what is available for new partitions.
To look into each partition, you will have to mount them.

But gparted, for example, will give you all what you need, but it’s in graphic. gparted does not mount the partitions for what I can see on my pc.

[Edit]
It seems parted can do part of the job :wink:

sudo parted /dev/sdc print free
Model: ATA ST2000VN004-2E41 (scsi)
Disk /dev/sdc: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name       Flags
        17,4kB  1049kB  1031kB  Free Space
 1      1049kB  315GB   315GB   ext4         D
 2      315GB   629GB   315GB   ext4         P
 3      629GB   944GB   315GB   ext4         P2
 4      944GB   1258GB  315GB   ext4         M
        1258GB  2000GB  742GB   Free Space

df -h can give you free space inside partitions, but only for the mounted ones.

df -h
Filesystem      Size  Used Avail Use% Mounted on
dev             3,4G     0  3,4G   0% /dev
run             3,4G  1,4M  3,4G   1% /run
efivarfs        128K  110K   14K  90% /sys/firmware/efi/efivars
/dev/sda2        20G   13G  5,4G  71% /
tmpfs           3,4G     0  3,4G   0% /dev/shm
/dev/sda1        50M  3,5M   46M   8% /boot/efi
/dev/sda3        91G   37G   49G  43% /home
tmpfs           3,4G  8,0K  3,4G   1% /tmp
tmpfs           689M  100K  689M   1% /run/user/1000

Same thing fo lsblk -f

lsblk -f /dev/sdc
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sdc
├─sdc1 ext4 1.0 D 0a9915cd-xxxx 115,1G 55% /media/D
├─sdc2 ext4 1.0 P b7ad1997-xxxxxx 193,4G 28% /media/P
├─sdc3 ext4 1.0 P2 ab3286cc-xxxx (unmounted partition)
└─sdc4 ext4 1.0 M 0b6aabf9-x 239,1G 12% /media/M

2 Likes

Thx… ya… as i have tried… must mount the partition in order to know how much left available within the partition.
without mounting the partition, all those tools can only see how big is the partition, NOT how MUCH space left in the partition.
That let me wonder, if the hdd has got error (which usually is fixable using those tools… like fsck…etc)… but i don’t have the time to fix … i just want to know how much space avail in the hdd to know if i can stuff something into the hdd or shld choose another hdd… … ithink hdd that has got error won’t be able to be mounted, right ? hence won’t be able to see the space available …

Thx.

What kind of error? If it is severe so mount is not possible there might be no proper distinction what bits would be considered free space or not. It’s all just bits, unless there is a proper filesystems that assigns them to a useful definition.

And of cuz you need to mount them to access the filesystem and ask what it makes of all those bits. Up until that point all you got is the partition table.
Don’t think of a drive with 50% data like a jar half full of marbles. It’s always a full jar of marbles, you just used a coloring system (fs) to mark some of them as meaningful.

1 Like

I experienced a few time i tried to find out space available for me to squeeze in some backup or file into storage device that has got data in it (be it some diff distro of live linux or diff format like those fr windows os)… i just want to know if there is enough space so that i can use it to transfer data fr a laptop to laptop, but i just cant… i dont know… just hav bad experiences that i cant know available space of storage devices when using linux, but never such experience whe i was using only windows… Dont know…just puzzled how come…

I guess that Windows auto-mounts whatever you attach? It’s been a long time since I used Windows (except for my “test” installs in VirtualBox which I only have to see what the latest M$ shenanigans are, and old versions for nostalgia reasons/demos etc.) but I think that may be how it works.

Impossible to know how much used/free space without mounting, as far as I know.

1 Like

If the hard drive has a fault, it is certainly not advisable to use it, no matter how much space there appears to be on it.
:man_shrugging:

2 Likes

This topic was automatically closed 36 hours after the last reply. New replies are no longer allowed.