How to calculate total disk size in Linux? [closed] - linux

Closed. This question is not about programming or software development. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last month.
Improve this question
LIke df -h gives following output:
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rootvg-root_lv 15G 9.9G 4.8G 68% /
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 12K 16G 1% /dev/shm
tmpfs 16G 1.2G 15G 8% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda1 488M 178M 275M 40% /boot
/dev/mapper/rootvg-tmp_lv 8.8G 52M 8.8G 1% /tmp
/dev/mapper/rootvg-opt_lv 18G 12G 6.1G 67% /opt/wildfly
/dev/mapper/rootvg-keycloak_lv 4.8G 1.1G 3.6G 23% /opt/keycloak
/dev/mapper/rootvg-var_lv 25G 23G 2.1G 92% /var
/dev/mapper/rootvg-data_lv 50G 970M 46G 3% /data
/dev/mapper/rootvg-home_lv 997M 475M 523M 48% /home
/dev/mapper/rootvg-doc_lv 20G 9.9G 9.7G 51% /var/lib/docker
146.213.179.242:/test01 228G 93G 136G 41% /shared
So Total disk size will be sum of second columns (Excluding last row)? i.e
Size
15G
16G
16G
16G
16G
488M
8.8G
18G
4.8G
25G
50G
997M
20G
Is there some other space which is hidden? No Command gives total size but bifurcate on filesystems? I want to write Java program based on same.

I would output block devices there are discs using lsblk and sum the size of them:
$ lsblk -rbo TYPE,SIZE | awk '$1=="disk"{sum+=$2} END{print sum}' | numfmt --to=si
1.2T
df prints you mount points not necessarily block devices, like tmpfs is temporary file system.

Related

/dev/mapper/RHELCSB-Home marked as full when it is not after verification

I was trying to copy a 1.5GiB file from a location to another and was warned that my disk space is full, so I proceeded to a verification using df -h, which gave the following output:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 114M 16G 1% /dev/shm
tmpfs 16G 2.0M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/mapper/RHELCSB-Root 50G 11G 40G 21% /
/dev/nvme0n1p2 3.0G 436M 2.6G 15% /boot
/dev/nvme0n1p1 200M 17M 184M 9% /boot/efi
/dev/mapper/RHELCSB-Home 100G 100G 438M 100% /home
tmpfs 3.1G 88K 3.1G 1% /run/user/4204967
where /dev/mapper/RHELCSB-Home seemed to cause the issue. But when running sudo du -xsh /dev/mapper/RHELCSB-Home, I got the following result:
0 /dev/mapper/RHELCSB-Home
and same thing for /dev/ and /dev/mapper/. After researching this issue, I figured out that this might have been caused by undeleted log files in /var/log/, but the total size of files there is far from approaching the 100GiB. What could cause my disk space to be full?
Additional context: I was running a local postgresql database when this happened, but I can't see how this can relate to my issue as postgres log files are not taking that much space either.
The issue was solved by deleting podman container volumes in ~/.local/share/containers/

Linux partition not showing full size [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed last year.
Improve this question
I have a Linux system where the disk space shows as only 29Gb, but when I look at the partition with the parted - print command it shows as a 64Gb partition. I'm not sure if the remaining disk space is unallocated, mounted in other folders, stuck in "tmpfs" or how to add it to the primary partition. This is in Ubuntu 18.04 OS. I would like for the full 64 GB to be available at root. I appreciate any help!
When I run df -h, here are the results:
Filesystem Size Used Avail Use% Mounted on
udev 16G 0 16G 0% /dev
tmpfs 3.2G 1.2M 3.2G 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 29G 25G 2.7G 91% /
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/sda2 976M 81M 829M 9% /boot
/dev/sda1 511M 4.4M 507M 1% /boot/efi
tmpfs 3.2G 0 3.2G 0% /run/user/1000
Results of parted print command shows a 64GB partition:
Model: ATA MSH-64 (scsi)
Disk /dev/sda: 63.4GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
1 1049kB 538MB 537MB fat32 boot, esp
2 538MB 1612MB 1074MB ext4
3 1612MB 63.3GB 61.7GB
Results of vgs command:
VG #PV #LV #SN Attr VSize VFree
ubuntu-vg 1 1 0 wz--n- <57.50g <28.75g
Results of the lvs command:
(talos-env) pradmin#pradmin:~$ sudo lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
ubuntu-lv ubuntu-vg -wi-ao---- 28.75g
Depending on the installation, the root partition might only use a part of the logical volume (LV).
Try the commands vgs and lvs to get information about your current setup. I assume that vgs shows about 30G free space. You can enlarge the root volume using lvresize. After this you need to adapt the file system. This depends on the file system type you are using. If you use extX then you might want to run resize2fs.
Edit based on the edited question:
Yes, everything can be done when the disk is mounted and in use.
BUT YOU NEED TO TAKE CARE ABOUT THE COMMANDS YOURSELF!!! A WRONG COMMAND MIGHT DESTROY YOUR SYSTEM.
PLEASE TAKE YOUR TIME TO MAKE YOURSELF COMFORTABLE WITH LVS BEFORE CHANGING THE SYSTEM.
There are many good tutorials which might help you, e.g.:
http://ryandoyle.net/posts/expanding-a-lvm-partition-to-fill-remaining-drive-space/
The guidance from Andreas proved helpful. I managed to resize the logical volume to the full size of the partition using the following commands and sequence.
Resources that I found helpful:
https://www.redhat.com/sysadmin/resize-lvm-simple
https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/storage_administration_guide/ext4grow
root:~# lvs
  LV        VG        Attr       LSize   Pool Origin
Data%  Meta%  Move Log Cpy%Sync Convert
  ubuntu-lv ubuntu-vg -wi-ao---- <57.50g
 
Here you can see that the logical volume doesn't fill the full partition size
root:~# vgs
  VG        #PV #LV #SN Attr   VSize   VFree
  ubuntu-vg   1   1   0 wz--n- <57.50g <28.75g
Extend the logical volume to 100% of the free space, /dev/{VG FROM lvs CMD}/{LV FROM lvs CMD}
root:~# lvextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
Size of logical volume ubuntu-vg/ubuntu-lv changed from 28.75 GiB (7360 extents) to <57.50 GiB (14719 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.
Checked disk space and saw that it hadn't changed yet
root:~# df
Filesystem 1K-blocks Used
Available Use% Mounted on
udev 16390292 0 16390292 0% /dev
tmpfs 3284628 1164 3283464 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 29542388 25311328 2707348 91% /
tmpfs 16423128 0 16423128 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 16423128 0 16423128 0% /sys/fs/cgroup
/dev/sda2 999320 82552 847956 9% /boot
/dev/sda1 523248 4492 518756 1% /boot/efi
tmpfs 3284624 0 3284624 0% /run/user/1000
Resize file system to full size of logical volume, use Filesystem name from df command above. Note this is an ext4 filesystem, you may have to use a different command for a different filesystem.
root:~# resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mapper/ubuntu--vg-ubuntu--lv is mounted on /; on-line
resizing required
old_desc_blocks = 4, new_desc_blocks = 8
The filesystem on /dev/mapper/ubuntu--vg-ubuntu--lv is now 15072256 (4k) blocks
long.
root:~# df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 16390292 0 16390292 0% /dev
tmpfs 3284628 1164 3283464 1% /run
/dev/mapper/ubuntu--vg-ubuntu--lv 59211724 25319316 31128948 45% /
tmpfs 16423128 0 16423128 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 16423128 0 16423128 0%
/sys/fs/cgroup
/dev/sda2 999320 82552 847956 9% /boot
/dev/sda1 523248 4492 518756 1% /boot/efi
tmpfs 3284624 0 3284624 0%
/run/user/1000

Docker (Linux) Error: no space left on device even if I have enough space [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I have built docker image and while that I got the Error: no space left on device. This comes in the step where docker copies the oracle databse files. In my docker file it is this step:
ADD resources/oracle/database /data/home/oracle/database/
RUN chown -R oracle:oracle /data/home/oracle/database
This step takes some time when I build the image after that it prints this error:
Step 10/32 : ADD resources/tomcat/apache-tomcat-8.0.29.tar.gz /opt/tomcat
---> 092e001b744e
Step 11/32 : ADD resources/oracle/database /data/home/oracle/database/
---> 69218d6278b0
Step 12/32 : RUN chown -R oracle:oracle /data/home/oracle/database
---> Running in 4ae797185eeb
Error processing tar file(exit status 1): write /data/home/oracle/database/javavm/jdk/jdk8/admin/classes.bin: no space left on device
Hmm it seems for me that I dont have enough space on linux server. I then tried to check my space in linux as I am sure that I have much space. I run df -h and it looks like this:
$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 59G 0 59G 0% /dev
tmpfs 59G 0 59G 0% /dev/shm
tmpfs 59G 418M 59G 1% /run
tmpfs 59G 0 59G 0% /sys/fs/cgroup
/dev/sda3 39G 30G 9.0G 77% /
/dev/sda1 200M 8.6M 192M 5% /boot/efi
tmpfs 12G 0 12G 0% /run/user/1000
/dev/sdc 1008G 176G 781G 19% /data
/dev/sdd 1008G 466G 492G 49% /oracle
tmpfs 12G 0 12G 0% /run/user/2003
Before I built the image it looked like this:
davinci#sii-dev-ora19:/opt/davinci]$ df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 59G 0 59G 0% /dev
tmpfs 59G 0 59G 0% /dev/shm
tmpfs 59G 418M 59G 1% /run
tmpfs 59G 0 59G 0% /sys/fs/cgroup
/dev/sda3 39G 16G 23G 42% /
/dev/sda1 200M 8.6M 192M 5% /boot/efi
tmpfs 12G 0 12G 0% /run/user/1000
/dev/sdc 1008G 176G 781G 19% /data
/dev/sdd 1008G 466G 492G 49% /oracle
tmpfs 12G 0 12G 0% /run/user/2003
Means That I had on /dev/sda3 23GB available before I built the image and only 9GB available after building the image.
Question1: why does it stop even when I still have 9GB avilable on that partition?
Question2: It seems that docker doesnt take space from the other partitions. On dev/sdc for example I have 718GB available. How to tell docker to take space from there?
Question3: It seems that docker write files into this folder /data/home/oracle/database/...
But I go to that folder with winscp I can find only the directory /data. Is the folder /data/home/oracle/database/ in container somehow or its really in linux file system?
Question1: why does it stop even when I still have 9GB avilable on that partition?
You didn't when the error occurred. The error resulted in docker deleting the partial filesystem layer it had created. Note with overlay filesystems, a recursive chmod will copy every file in that directory tree, doubling the used disk space.
Note that you should also be watching for inode exhaustion when you get this write (df -i).
Question2: It seems that docker doesnt take space from the other partitions. On dev/sdc for example I have 718GB available. How to tell docker to take space from there?
Docker stores data in /var/lib/docker. I'd recommend making that it's own partition, or relocating it using a symlink rather than trying to change the location docker looks. There are lots of tools out there that assume this directory name.
Question3: It seems that docker write files into this folder /data/home/oracle/database/... But I go to that folder with winscp I can find only the directory /data. Is the folder /data/home/oracle/database/ in container somehow or its really in linux file system?
Docker uses namespaces, and one of those namespaces in the filesystem. The root directory in a docker container is not the root directory on the host, otherwise you'd have no isolation. This is typically implemented as an overlay filesystem under the docker directory, and each step of the Dockerfile may create a new filesystem layer used by overlay.

CentOS no disk space left while copying a file to /home/ansible-user/ however admin-vol1 is of 100gb [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I am trying to copy a tarball to a server having CentOS 7 using winscp.
The copying after some time throws an error that no space left. However when I check from the monitoring GUI it shows that the server has a vol of 100gb. I am copying to the home/ansible-user user directory which has a space of only 2GB.
How can I increase the space allocated to the home/ansible-user folder?
Also Where is the 100gb space getting used up is not clear by the df or df -h how and where it is getting used up? Here is the output of the command
3.9G 1.3G 2.5G 34% /
485M 0 485M 0% /dev
496M 0 496M 0% /dev/shm
496M 51M 446M 11% /run
496M 0 496M 0% /sys/fs/cgroup
496M 4.0K 496M 1% /tmp
99G 61M 94G 1% /data
488M 140M 313M 31% /boot
33G 2.7G 29G 9% /var
2.0G 443M 1.5G 24% /home
5.9G 65M 5.6G 2% /var/log
2.0G 3.0M 1.9G 1% /var/tmp
492M 35M 432M 8% /var/log/audit
100M 0 100M 0% /run/user/1000
UPDATE :
df -i gives the following output :
262144 43638 218506 17% /
124118 378 123740 1% /dev
126926 1 126925 1% /dev/shm
126926 575 126351 1% /run
126926 16 126910 1% /sys/fs/cgroup
126926 9 126917 1% /tmp
6553600 11 6553589 1% /data
32768 344 32424 2% /boot
2162688 38203 2124485 2% /var
524288 869 523419 1% /home
393216 49 393167 1% /var/log
131072 13 131059 1% /var/tmp
131072 15 131057 1% /var/log/audit
126926 1 126925 1% /run/user/1000
Update :
Ok my mistake. I read the output wrong. The var folder has ~40G and data folder has 94G space.
Use (on your remote Linux server, perhaps thru  ssh) both df and df -i to check the available space (both for data and for inodes). You might have no more inodes available, even if a lot of data space remains free. See df(1). And there could be disk quotas. See quota(1) and ask your sysadmin.
error that no space left
That could be either data space, or inode space (or some disk quota exceeded). You should use both df and df -i to find out.
How can I increase the space allocated to the home/ansible folder?
That is a question for the sysadmin of your Linux server (who probably is also in charge of installing software). BTW, Linux has directories, not folders (folders are visible in some GUI, and might not be shown).
The amount of space dedicated for inodes and for data is fixed when creating the file system with mkfs(8) (actually with mke2fs(8) for ext4 file systems); usually that is happening when installing your Linux distribution. You could consider resizing it, but be sure to backup all the data (on some external storage) before attempting (on some unmounted partition) any resize2fs(8) (it is a risky operation, and you might lose all your disk partition if something goes wrong...)
At last, I recommend copying the *tar.gz archive to your remote Linux server, and use on that server some tar xvf command to extract it. Try tar tvf before. See tar(1).

ubuntu "No space left on device" but there is tons of space [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am getting the "No space left on device" error for pretty much anything i try to do. Even using tab to autocomplete a command!
but when i do df -h i get:
ubuntu#ip-10-0-2-108:~$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 99G 6.5G 88G 7% /
udev 3.7G 8.0K 3.7G 1% /dev
tmpfs 1.5G 184K 1.5G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.7G 0 3.7G 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvdb 414G 199M 393G 1% /mnt
overflow 1.0M 1.0M 0 100% /tmp
which to me looks like there is tons of space. df -i also looks similar:
ubuntu#ip-10-0-2-108:~$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 6553600 94227 6459373 2% /
udev 951353 393 950960 1% /dev
tmpfs 953649 274 953375 1% /run
none 953649 3 953646 1% /run/lock
none 953649 1 953648 1% /run/shm
none 953649 1 953648 1% /run/user
/dev/xvdb 27525120 11 27525109 1% /mnt
overflow 953649 12 953637 1% /tmp
I am on an Amazon EC2 ubuntu 12.04 instance.
Here are some examples of the error popping up:
ubuntu#ip-10-0-2-108:~$ sudo crontab -e
/tmp/crontab.RvYjrR/crontab: No space left on device
ubuntu#ip-10-0-2-108:~$ ls /va (hit tab for autocomplete)
-bash: cannot create temp file for here-document: No space left on device
-bash: cannot create temp file for here-document: No space left on device
however the server seems to be running and everything seems to be working.
what on earth is going on??
It's possible that you've run out of memory or some space elsewhere and it prompted the system to mount an overflow filesystem, and for whatever reason, it's not going away.
Try unmounting the overflow partition:
umount /tmp
or
umount overflow

Resources