Understanding Disk Partitions on Linux


Disk partitions on Windows are very easy to visualize since they are labeled as drives. If you get an error complaining you're running out of disk space on D: drive, you know exactly where to add more disk.

Even though the concept of disk partition exists on Linux, it is not very easy to visualize. Complications arise from the fact that drive letters are missing in Linux. For example, if you add a new disk to your Linux machine, it does not magically add an F: drive to your machine. Instead, you have to mount this new disk to a regular folder, which could have a path like /home/john/mylargeDisk.


Assume you have three physical disks with the following mounting points

Physical DiskSizeMounted PathDescription
Disk 1 50GB / This is called the root partition and is usually where your OS is installed on
Disk 2 1TB /share/bigDisk2 Another physical disk attached to the machine
Disk 3 5TB /share/bigDisk3 Perhaps a USB drive attached to the machine

Considering the above example, following statements are true:

  • You will get an error if you create a 100GB file in /tmp/var/ folder. That is because this folder is stored on Disk1 and it does not have room to hold a 100GB file.
  • You will get an error if you create a 100GB file in /share/sub-folder. Again, this location is on Disk1
  • You will be able to create a 100GB file in /share/bigDisk2/sub-folder1/sub-folder2, because this location is on Disk2
  • You will NOT be able to create a 2TB file in /share/bigDisk2/sub-folder1, since Disk2 is only 1TB. This file must be created in /share/bigDisk3/sub-folder1/, which is on Disk3

Finding Available Disk Space

Use the following command to find available disk space:
df -h
Following is an example of sample result:
Filesystem                Size      Used Available Use% Mounted on
none                    250.0M    229.3M     20.7M  92% /
devtmpfs                937.7M      8.0K    937.7M   0% /dev
tmpfs                    64.0M   1008.0K     63.0M   2% /tmp
tmpfs                    16.0M         0     16.0M   0% /mnt/snapshot/export
/dev/md9                493.5M    133.7M    359.7M  27% /mnt/HDA_ROOT
cgroup_root             945.8M         0    945.8M   0% /sys/fs/cgroup
/dev/mapper/cdev1         4.5T      2.9T      1.5T  65% /share/CACHEDEV1_DATA
/dev/md13               417.0M    375.9M     41.0M  90% /mnt/ext
In the above example, there are 1.5TB available in /share/CACHEDEV1_DATA folder. Therefore, try using this location for all of your data files.

Navigation

Social Media

Powered by 10MinutesWeb.com