Raspberry Pi_Eng_15.2 Structure of File System


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


15.2   Structure of File System

 

Here, we will take a look at the basic structure of file system in the Raspberry Pi system. The Raspberry Pi system has a built-in file system that is created by default when the system is installed, and users manage their own data within these file systems.

 

 

   / (root directory)

 

Linux has an integrated hierarchical file system. Thisdirectory is the top level directory in the system hierarchy. It is called "root" directory in the sense that all data is stored under this. This is different from the "/root" directory used by the user account "root" as the home directory.

 

 

   /root 

 

This is the home directory used by the user account "root". The home directory for normal user accounts are created with the same name as the user account under the "/home" directory. For example, the user account "pi" uses "/home/pi" as the home directory. However, the user account "root" does not use these type of directory, but exceptionally use "/root" as the home directory.

 

 

   /boot

 

It contains the main files needed to boot the system. The files for boot loader or Linux kernel are typical files.

 

 

   /bin and /sbin

 

This is where commands or programs that can be executed in the system are stored. Normally, when you execute a command in Shell, it finds and executes the program stored in it. For example, running "chgrp" in Shell will actually work "chgrp" executable file stored in "/bin". These files are also classified according to their purpose of use. Normally, those used by ordinary users are stored in "/bin", and those used mainly by system administrators are usually stored in "/sbin". For example, "cp" command used to copy files is stored in "/bin", and "fdisk" command used to manage the system's disk partitions is stored in "/sbin".

 

 

   /dev

 

In Linux, all hardware devices are managed as files. This directory contains information about the hardware devices the system has. Information about all devices installed in the system, such as sound cards, virtual terminals, graphics cards, USB devices as well as disk devices is managed here.

 

 

   /etc

 

This directory is where the configuration files for various programs installed on the system are kept. It also manages configuration information for programs installed by users for personal purpose as well as programs installed by the system. For example, if the host name of the Raspberry Pi system is defined as "raspberrypi", the information is stored in a file called "/etc/hostname", and if the user group "ggroup01" is defined, the information is stored in a file called "/etc/group".

 

 

   /home

 

This is the place which the normal user account uses as the home directory and is where the data used by normal user is stored. Under this directory, you will store the data of user account in a directory created with the same name as the user account. For example, the user account "pi" will store data under "/home/pi". Please refer that normally, in Linux or Unix, it is common to manage user data in this directory, but some distributions or providers may use somewhere else.

 

By managing the data of normal users separately from the data used by the system, this management method is aimed to make various managements more convenient when managing the system.

 

 

   /lib

 

This is where the library file is kept. The library is a program provided in package format, which is a collection of programs to perform various common functions that control various devices in the system or that users need. This is where library files that are used commonly by many application programs, such as system programs and general user programs are stored.

 

 

   /lost+found

 

This is where the system temporarily manages the data that is difficult to determine where the data belongs because data is not managed adequately in the system for some reason. For example, there is a case that if the disk is damaged due to physical reasons or the file information is damaged due to a virus invasion or the like, the information about the specific files is missing and can not be correctly known, so the information can not be recovered with revovery task. In this case, the data that the system can not process will be stored here

 

 

   /media

 

This is normally used to mount removable media. It is used when SD card, USB device, camera, media player, etc. are installed. The SD card used by Raspberry Pi is also mounted here and works. This is usually different from "/mnt", which is used to mount external file system devices.

 

 

   /mnt

 

This is the place that the system uses to mount additional file systems. Normally, you create a directory here and mount it when you connect a network share or an external hard disk, and you also mount here when you want to use floppy disk or CD-ROM.

 

 

   /opt

 

This is an optional directory. In other words, this is where application programs can use selectively freely, if necessary. So there are some applications that use here, and some that do not use here. In general, there is no particular reason why ordinary users will use here.

 

 

   /proc

 

This is where the various informations about system process that the system kernel has are provided so that external program or users can access and use them. If you need information about memory usage or currently running processes, etc., you can refer to the information here. For example, memory status can be found in "/proc/meminfo", and CPU configuration information is provided in "/proc/cpuinfo".

 

This directory is not a real existing disk, but a virtual file system created to provide information. The information here is usually only for viewing, but some files can affect both directions, so you should be careful.

 

A lot of information is provided, but here are some of the important things:

    /proc/cpuinfo          -- Display CPU information.

    /proc/devices          -- Shows device information used by the system.

    /proc/filesystems      -- Shows the file system information supported by the kernel.

    /proc/meminfo         -- Displays system memory information.  

    /proc/uptime                     -- Shows the system uptime.  

    /proc/version          -- Display kernel version information.  

 

 

   /run

 

This is a newly introduced directory in the Debian distribution. It allows you to easily retrieve the contents of transient state files that have various system informations from booting to the present time in a different way than the way of the previous standard. The "/run" directory allows you to use various system information in a read-only manner without affecting the system in a normal way that is different from the previous one.

 

"/run" replaces many existing locations described in the Filesystem Hierarchy Standard:

    /var/run                           /run

    /var/lock                          /run/lock

    /dev/shm                          /run/shm   

    /tmp                               /run/tmp  

 

"/run" also replaces the following some locations used for transient files:

    /lib/init/rw                        /run

    /dev/.*                             /run/*

    /dev/shm/*                       /run/*

    writable files under /etc        /run/*

 

 

   /srv

 

This directory is where the service processing the file temporarily stores the data. It is used in a similar way to "/var", and there are some cases it may not be particularly distinguished, so please refer to "/var" together.

 

 

   /sys

 

It is used to store information about the system in a file. The information about the system is also stored in "/proc", but it can be said different each other in the sense that the information in "/sys" is stored in the actual file and the information in "/proc" is not stored in the actual file, but simply in memory.

 

 

   /tmp

 

This is used when it is necessary to temporarily save a file. Whatever application can use this to store data temporarily if necessary and a specific user alos can use this if necessary.

 

Normally, files stored here are stored as temporary files and are treated as if they do not need to be kept for a long time, so when the system is restarted, it is common that all the previously stored data is cleaned.

 

 

   /usr

 

It is where the most of software are stored on the computer and occupies the largest part of the system. It is the place where general business application program is installed.

 

 

   /var

 

This is where to store files that system or applications usually need or files that is created for saving during program execution. The lists as follows are typical examples:

    /var/log/     -- log information about the process of running programs is recorded

    /var/lock     -- Lock information used in various applications is recorded.

    /var/www/   -- Raspbian's Apache web server stores various files here.