Table of contents
1. Overview of Linux partitions
1.du View the disk space occupied by files and directories
3. lsblk checks the device mounting status
1. Overview of Linux partitions
1. Principle introduction
(1) No matter how many partitions there are in Linux and which directory is allocated to it, it ultimately has only one root directory , an independent and unique file structure. Each partition in Linux is used to form part of the entire file system.
(2) Linux uses a processing method called " mount" . Its entire file system contains a complete set of files and directories, and associates a partition with a directory. A partition to be loaded at this time will have its storage space obtained in a directory.
2. Hard drive description
Linux hard disks are divided into IDE hard disks and SCSI hard disks . Currently, they are basically SCSI hard disks.
(1) For IDE hard disks, the drive identifier is "hdx~" , where "hd" indicates the type of device where the partition is located, here it refers to the IDE hard disk. "x" is the disk number (a is the basic disk, b is the basic slave disk, c is the auxiliary master disk, d is the auxiliary slave disk), "~" represents the partition, and the first four partitions are represented by numbers 1 to 4. They are Primary partitions or extended partitions are logical partitions starting from 5. For example, "hda3" represents the third primary partition or extended partition on the first IDE hard disk, and "hdb2" represents the second primary partition or extended partition on the second IDE hard disk.
(2) For SCSI hard disks, they are marked as "sdx~" . SCSI hard disks use "sd" to indicate the type of device where the partition is located, and the rest are the same as the IDE hard disks. For example, "sdb1" represents the first primary partition of the second SCSI hard disk.
2. View disks and partitions
1.du View the disk space occupied by files and directories
du [option] Directory/file // Display the disk usage of each subdirectory under the directory
Option description
Options | Function |
-h | Displays itself in GBytes, MBytes, KBytes, etc. formats that are easier for people to read |
-a | Not only look at subdirectory sizes, but also include files |
-c | After displaying the sizes of all files and subdirectories, display the total |
-s | Show only the sum |
--max-depth=n | Specify the depth of the statistics subdirectory to be the nth level |
2.df Check disk space usage
df [options] // List the overall disk usage of the file system and check the disk space usage of the file system
Option description
Options | Function |
-h | Displays itself in GBytes, MBytes, KBytes, etc. formats that are easier for people to read |
3. lsblk checks the device mounting status
lsblk [options] // View detailed device mounting status
Option description
Options | Function |
-f | View detailed device mounting status and display file system information |
4.mount/unmount mount/unmount
mount [-t vfstype] [-o options] device dir // Mount device
unmount device file name or mount point // Unmount device
Parameter Description
parameter | Function |
-t vfstype | Specifies the type of file system. Normally this does not need to be specified. mount will automatically select the correct type. Common types are: Disc or disc image: iso9660 DOS fat16 file system: msdos Windows 9x fat32 file system: vfat Windows NT ntfs file system: ntfs Mount Windows file network share: smbfs UNIX (LINUX) file network sharing: nfs |
-o options | Mainly used to describe the mounting method of devices or files. Commonly used parameters are: loop: used to mount a file on the system as a hard disk partition ro: Mount the device in read-only mode rw: Mount the device in read-write mode iocharset: Specifies the character set used to access the file system |
device | device to mount |
dir | The device’s mount point on the system |
Set up automatic mounting at startup
we /etc/fstab
Then add an automount device to the file
5.fdisk partition
fdisk [options] // View disk partition details
fdisk hard disk device name // partition the new hard disk
Option description
Options | Function |
-l | Display partition list of all hard disks |
Function Description
Linux partition | Device: partition sequence Boot: boot Start: Start from X magnetic column End: end at Y magnetic column Blocks: Capacity Id: partition type ID System: partition type |
Partition operation button description | m: display command list p: Display the current disk partition n: New partition w: Write partition information and exit q: Exit directly without saving partition information |