Linux Disk Partitioning tool
A hard disk can be divided into partitions, and each partition can be treated as a separate disk. The partition scheme of the hard disk is recorded in the "Disk partition table", which is usually composed of 4 parts, each section defines a partition's information, so the original concept of a hard disk can only establish 4 partitions, known as the "primary partition." Since the hard disk is getting larger, 4 partitions are no longer able to meet the needs of users, introducing the concept of "extended partition". Extended partitions are maintained by extended disk partition tables, and a primary partition can be divided into smaller "logical partitions" as an extension division. Theoretically, any number of partitions can be established when there is sufficient hard disk space.
Linux recommended partitions are: Swap partition, that is, virtual memory, boot partition, the kernel of the operating system, root partition, the root of the entire operating system,/var partition, you can avoid the size of the log files out of control;/home partitions, controlling the amount of space the user occupies.
The disk partitioning tools are:
FDISK: A powerful disk partitioning tool that is not only suitable for Linux, but also widely used in Windows and MS-DOS. -l Displays the partition table for the current device. -S/DEV/SDA1 displays the size of the specified partition. -S/DEV/SDA Displays the sum of all partition sizes for the device. -V Displays the version number of Fdisk. FDISK/DEV/SDA can enter command interaction mode, internal commands include M: Display command help; p: Display current partition table; Q: Exit; and so on. )
Disk partitioning and partition adjustment tools under Parted:linux. PARTED/DEV/SDA can enter interactive mode.
SFDISK:-L displays the partition information. -S displays the size of the disk or partition.
Common Disk Management commands
Badblocks: Check the device for bad blocks. (-s displays the check progress.) )
Du: Counts the amount of disk space used by files and directories. (If you do not specify a file or directory name, the current directory is counted by default.) -S displays only the number of blocks occupied by the file or directory, and the default is equal to 1024 bytes. -B statistics in bytes,-K in 1024 bytes,-m in 1024K,-C displays totals, and-H displays K, M, or G on demand. -a displays the number of blocks of data that are occupied by all files and their subdirectories. Example: Du ~tommy, Statistics Tommy's home directory. )
DF: Displays the file system disk space usage. (If you do not specify a file system, the free space for all currently mounted file systems is displayed.) By default, space is displayed in 1KB, unless the environment variable posixly_correct is specified, at this time in 512 bytes. -I in Inode mode, listed as the number of inode;-h is readable and displays the K, m, or g;-t type on demand displays only information for the specified file system, such as Df-t ext3;-x type, which does not display disks of the specified disk type, as opposed to-T. )
Fdformat: Format the disk. (-n means no validation after formatting is complete.) )
Hdparam: Displays and sets the hard drive parameters. (-C displays power management,-D 1 opens DMA mode.) Example: HDPARM/DEV/SDA1. )
MKFS: Sets the file system for the disk. (Example: Mkfs-t ext4/dev/sda2. )
Mkswap: Set up the swap partition (swap area). (For example: MKSWAP/DEV/HDA4, designate hda4 as a new interchange partition.) -c check for bad blocks before creating swap partitions;-v0 set up an old Exchange zone and-v1 a new exchange zone. )
Mkisofs: Establish Iso9660/joliet/hts file system. (Example: Mkisofs-o myiso myfile to make myfile a mirrored file named Myiso.) )
MKINITRD: Creates a RAMDisk mirror file. (Example: MKINITRD myfile.img 2.2.5-15 to establish a mirrored file named Myfile.img, kernel number 2.2.5-15. Not supported on Ubuntu. )
MT: Tape-driven operations. (Syntax: MT operation device.) Operation has rewind, erase and so on. The RMT command is a remote tape Transfer Protocol module that allows you to remotely control the tape drive for backup and restore backup operations through interprocess communication. )
Mzip: Eject the disk in the Zip/jaz device. (-e eject disk;-F and-e use forced eject at the same time;-Q query state. )
Sync: Writes the data in the buffer to disk. (You can use sync to write memory data to disk before uninstalling the removable drive.) )
rsync: Remote sync. (For example: RSYNC-AV-E ssh/home/share/*.doc root@teacher.example.com:/usr/local/share backup all doc files under/home/share via SSH to the Teacher The/usr/local/share directory of the host. Only the files and directories that have been modified are synchronized. -A: archive mode;-V: Redundancy mode. )
Disk quota Management
/etc/fstab file: Defines how the partition is mounted. (file format: <file system> <mount point> <type> <options> <dump> <pass>. Example:/dev/sda1/ext4 errors=remount-ro,user_xattr 0 1. To enable disk quota management, you need to add the Usrquota and Grpquota options, for example:/dev/sda2/mnt/disk ext4 Defaults,usrquota,grpquota 0 1. After you change the file, you need to reboot or reload it to make the configuration file effective: Mount-o remount/dev/sda2. Note that when a new partition is established, you need to use MKFS to specify the file type of the partition, otherwise a file system error cannot be found when you mount it. )
Quotacheck: Check disk usage space and limitations. (After you modify the/etc/fstab file and add the Usrquota and Grpquota options, you can use the command Quotacheck- AVUGC to create the two files Aquota.user and Aquota.group, where-c means recreating the quota file,-a scans all mounted non-NFS file systems in the/etc/mtab file, and-U calculates the number of directories and files occupied by each user, and create a aquota.user file;-G calculates the number of directories and files occupied by each user group, creates a Aquota.group file, and-v displays the command execution process. /etc/mtab is similar to/etc/fstab content,/etc/fstab represents the partition that is loaded by default when the system is powered on, and/etc/mtab represents the partition currently in the system load. The Aquota.user and Aquota.group files that are created are located where the partition that enables the Usrquota and Grpquota options is mounted, such as/mnt/disk. )
Edquota: Set disk quotas for users or groups of users. (Aquota.user and Aquota.group files are too complex to edit directly and can only be edited with the Edquotaa command.) -u username set disk quotas for users,-g groupname set disk quotas for user groups. -U is in use by default. The file format is: FileSystem blocks soft hard inodes soft, where hard is the space used by the user, in blocks, 1024 bytes, and bolocks as the number of I nodes used. Soft is a soft limit, when the user reaches this limit, the system emits a warning message, but the user can still continue to use it, hard is a hard limit and the user cannot write to it when the limit is reached. The front of the soft, hard corresponding block of the soft and hard restrictions, and the back of the soft, hard corresponding to the inode soft and hard restrictions. -p replicates quota settings, such as Edquota-p usr1-u USR2 usr3;-t set soft time limits. )
Quota: Displays the space and quota limit used by the disk. (-u view users, default option; G to view user groups.) )
Quotaoff: Turn off disk space limits. (-a closes all disk quotas listed in/etc/fstab;-g user group quota;-u user quota;-p lists the status.) )
Quotaon: Start disk space quota limit. (grammar is the same as Quotaoff.) )
Quotastats: Displays the disk space limit.
Repquota: Statistics on disk quotas for the file system.
Logical Volume Management (LVM)
The relevant definitions in LVM are:
A physical volume (physical VOLUME,PV) is equivalent to a standard primary or logical partition of a hard disk drive;
The Physical disk area (physical extent,pe) is a piece of disk space. The physical volume is divided into several equally sized PE;
A logical volume (Logical volume,lv) is a set of Le;
The Logical Disk area (Logical extent,pe) and a PE correspond to the same size;
The volume group (volumn GROUP,VG) is a collection of LV.
Pvdisplay: View the physical volume that makes up the LVM volume.
Pvcreate: Create a physical volume. (Can be created on a hard disk or on one of the partitions.) )
Vgcreate: Create Volume group. (Example: Vgcreate myvolumn/dev/sdd1/dev/sdc2. Where SDD1 and SDC2 are physical volumes. )
Vgextend: Adds a new physical volume to the volume group. (Example: Vgextend myvolumn/dev/sdd3. )
Lvdisplay: View logical volumes.
Lvcreate: Create a logical volume. (Example: Lvcreate-l myvolumn-n mylogical creates a new/dev/myvolumn/mylogical device that can be used for mounting: mkfs-j/dev/myvolume/mylogical,mount-t Ext3/dev/myvolumn/mylogical/mnt/mynewdisk. -L 50 indicates a size of 50 PE, each PE size may be 4.0M, and-l specifies the size of the LV. -n Specifies the name of the LV. )
Lvextend: Extended Logical volume. (If you have extra PE, you can extend the size of the logical volume.) Example: Lvextend-l 800m/dev/myvolumn/mylogical. )