Friday, September 6, 2013

Partition, File System, Directory, etc

Partition and File System

Found the following link that has good explanations on partition, file system, etc. Though it is about UNIX, the concepts on LINUX should be similar.
http://www.freebsd.org/doc/handbook/disk-organization.html

The main points are the following.

  1. Directories and files are stored in a file system. Each file system contains exactly one directory at the very top level, called the root directory for that file system.
  2. One file system is designated the root file system or /. Every other file system is mounted under the root file system.
  3. No matter how many disks are on the FreeBSD system, every directory appears to be part of the same disk.
  4. File systems can be mounted on top of one another.
  5. File systems are contained in partitions.
  6. Each partition can contain only one file system.
  7. File systems are a fixed size.

You can use the command "df" to get the information of the file systems on a server. The following is an example on a LINUX server.

$ df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda3     ext3     3882516   2032072   1650036  56% /
/dev/mapper/vg00-optvol
              ext3     8125880   2049796   5656656  27% /opt
/dev/mapper/vg00-homevol
              ext3     1015704     34176    929100   4% /home
/dev/mapper/vg00-varvol
              ext3     8125880   1960524   5745928  26% /var
/dev/sda1     ext3      194410     17867    166506  10% /boot
tmpfs        tmpfs     1956764         0   1956764   0% /dev/shm
tmpfs        tmpfs     2097152      3716   2093436   1% /tmp
/dev/mapper/vg01-lvol1
              ext3     1032088     34936    944724   4% /opt/abc
/dev/mapper/vg01-lvol2
              ext3     1032088     34100    945560   4% /var/abc
/dev/mapper/vg00-UsrLclHmVol
              ext3     5160576   1566824   3331608  32% /usr/local/home
/dev/mapper/vg01-AppOptVol
              ext3    10321208    399984   9396936   5% /opt/abc/hzm
/dev/mapper/vg01-AppVarVol
              ext3    10321208   1388868   8408052  15% /var/abc/hzm
pghplnxl01:/export/kickstart
               nfs   131272224 120520768   4086592  97% /mnt/install

In the above example, the Type values are mostly "ext3". This does not have to be true. The following example is from Reference[3]
$ df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda1     ext4   132239776   6210892 119311496   5% /
tmpfs        tmpfs     4021876         0   4021876   0% /dev/shm
/dev/sdb2     ext2    30969600    117740  29278696   1% /home/oracle
/dev/sdc1     ext2   576310180     71232 546964104   1% /home/data

Swap Space

  1. Linux has two forms of swap space: the swap partition and the swap file.The swap partition is an independent section of the hard disk used solely for swapping; no other files can reside there. The swap file is a special file in the filesystem that resides amongst your system and data files.
  2. To see what swap space you have, use the command "swapon -s".

The following is an example to find the swap space. It is performed on the same machine as in the above section.

$ /sbin/swapon -s
Filename                                Type            Size    Used    Priority
/dev/sda2                               partition       457824  457820  -1

The output above shows a partition. It is not a swap file.
Note that the "df -T" command will not show the partition information.

Find Sizes of the Files

The command "du" can be used to find the estimated file space usage. The following command will write counts for all files and sub-directories under the current directory.
du -a

References

  1. http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-104-1/index.html
  2. http://www.linux.com/news/software/applications/8208-all-about-linux-swap-space
  3. http://www.thegeekstuff.com/2012/05/df-examples

No comments:

Post a Comment