Device and Linux file system

Create partition and file system The mechanism to manage the data saved on the disk as a file and make it available is called *** file system ***. To use a hard disk or SSD, create a partition on the disk and file inside it. The flow is to create a system and mount it. > Hard disk

Summary of standards for connection

-[] SATA ... Serial ATA. It is installed as standard on most PCs. -[] SAS ... Faster and more reliable than SATA. -[] SCSI: A general project for connecting to peripheral devices. A SCSI host adapter (SCSI card) is required to use a SCSI device.

There is a *** device file *** as an interface for exchanging between devices and PCs. Devices handled by Linux are block devices (those that can access anywhere on the media such as hard disks and SSDs) and character devices (keyboards and devices. There are two types (those that read and write data in character units such as serial ports).

Partition type

You can logically split one disk drive to use different file systems. Below are the BIOS-based partition types.

-[] Basic partition ... You can create up to 4 partitions (/ dev / sda1 to sda4). -[] Extended partition ... This partition stores the logical partition, not the file system. -[] Logical partition: A partition created in an extended partition, which is created from / dev / sda5 regardless of the number of primary partitions.

Partition management command

Syntax: *** fdisk -l {device name (absolute path)} ***

Creating a file system

In the Linux file system, "file contents (data)" and "file attributes and management information" are stored separately. The latter is stored in a management area called an inode (Index node). It is reserved when the file system is created and is assigned one for each file or directory created.   Filesystem types include ext2 (Linux standard), ext3 (ext2 with journaling), and Btrfs (high functionality). Btrfs can be run with the *** mkfs.btrfs *** command.

*** mkfs -t File system type You can use {device name} *** to create a file system on a partition.

You can create swap space on the partition with *** mkswap {device name} ***.

File system management > Check disk usage

The reason why you cannot write to the file system is ・ Insufficient free space ・ Inode depletion Use the *** df *** command to check the free space, and *** df -i *** to check the usage status of the inode. The larger the capacity, the larger the value of the inode allocated. Use the **** du -a *** command to check the space occupied by files and directories.

File system check

The *** fsck -a *** command checks the disk and automatically attempts to repair it. For ext2, ext3 and ext4, the *** e2fsck *** command is available.

File system management

*** tune2fs -i (sec) {device name} *** can be used to specify the check interval.

Filesystem mount and unmount

The file system information is described in the / etc / fstab file. The UUID in the device file field is the ID for identifying the device, and you can check the correspondence between each device and ID with the *** blkid *** command. Masu. Use *** mount [option] *** and *** umount [option] *** as commands.

File placement and retrieval


Abbreviation for File Hierarchy Standard, which is a file system hierarchy standard.

-[] / bin… Commands that can be used by general users (cat, dd, mount, sh, etc.) are placed. -[] / sbin… Commands required for system administration (fdisc, fsck, reboot, etc.) that can be executed only by the root user are placed. -[] / etc… System and application setting information, script files, etc. are located. -[] / dev… Device files such as hard disk and DVD-ROM are located. -[] / lib… Shared libraries and kernel modules are located. -[] / media… The mount point of removable media is placed. -[] / opt… The directory where the program is installed. -[] / proc… A virtual file system for accessing the inside of the kernel. -[] / boot… The settings and kernel image (file compressed Linux kernel) required for booting are located. -[] / var… There are / cache, / log, run (file showing system status) under / var…. -[] / usr… Commands and utilities are located.

File search

Syntax: *** find {search directory} {search expression} *** Search formula list: -name {file name}… Search by file name. -atime {date and time}… Search by last access time. Syntax: *** which {command name} *** Shows the absolute path where the command is stored. Syntax: *** whereis {option} *** Find where the binary files, source code, and manual files are located. Syntax: *** type {command name} *** Returns whether the specified command is a regular executable, a shell built-in command, or an alias. Result list: Hashed ⇒ External command Shell built-in function ⇒ Built-in command Alias ⇒ Alias It is a reserved word of the shell ⇒ reserved word

Recommended Posts

Device and Linux file system
Ping-t (subject 104) device, Linux file system, FSH
Linux file and directory permissions
Device, Linux file system, FHS ① Memorandum Creation of partition and file system / maintenance of file system integrity
[Linux] File and directory operation commands
Efficient use of Linux file system
[Linux] File search
[Linux] Zip file compression and decompression commands [Vim]
[Samba] File sharing between Linux and Windows machines
Device, Linux file system, FHS ③ Memorandum (file permission and owner management, hard link and symbolic link creation, system file search, proper file placement)
OS and Linux distribution
[Linux] [Initial Settings] System Settings
Linux command [File operation]
Hack Linux file descriptors
Linux: files and directories
Linux system architecture [runlevel]
I tried adding system calls and scheduler to Linux
Linux Study Session 1st: Virtual Console and File Manipulation
Studying Linux commands and frustration
CLI and Linux basic terms
Linux (about files and directories)
Steps to change partition including Linux system area and boot area
About LINUX files and processes
Recording and playback on Linux
Read and write a file
Understand the Linux audit system Audit
Write and read a file
Linux main package management system
Hack Linux fork system calls
Beginners add disks and use them as a file system (´ ・ ω ・ `)
Linux study session 3rd: File deletion prohibition setting and search function
Differences between Windows and Linux directories
Linux study session 2nd: File operation
Are macOS and Linux completely different?
(Windows10) Install Linux environment and gnuplot.
[linux] Swap Caps Lock and Ctrl
Switch argparse file specification and pipeline
Permission and ownership change command [Linux]
Linux archiving and compression (tar and gzip)
[Linux] Frequently used Linux commands (file operation)
Python CSV file reading and writing
linux (kernel) source analysis: system call call
Python memo ① Folder and file operations
[NFS] File sharing between Linux hosts
Note: Linux concepts and minimum commands
Linux file server construction (Ubuntu & Samba)
Summary of restrictions by file system
Replace the directory name and the file name in the directory together with a Linux command.
Production of temperature control system with Raspberry Pi and ESP32 (2) Production of transmission device