Home >Operation and Maintenance >Linux Operation and Maintenance >How to perform file system management and disk management in Linux systems
File system management and disk management of Linux systems are one of the basic skills that Linux system administrators must master. In a Linux system, to manage file systems and disks, you can use some basic commands and tools, such as fdisk, parted, mkfs, mount, df, etc.
Before using the Linux system to manage file systems and disks, you must first check the file system and disk information in the system. You can use the following commands to view disk and file system information in the system:
# 查看硬盘信息 sudo fdisk -l # 查看文件系统信息 sudo df -h
In a Linux system, to use a disk, you need to It partitions and formats the partition. Disks can be partitioned using the fdisk or parted tools.
# 使用fdisk对磁盘进行分区 sudo fdisk /dev/sdb # 使用parted对磁盘进行分区 以MB为单位 sudo parted /dev/sdb (parted) (parted) print (parted) unit MB (parted) mklabel gpt (parted) mkpart primary 0 1000 (parted) print (parted) quit
After the partitioning is completed, each partition needs to be formatted. Commonly used formatting commands include mkfs.ext4, mkfs.ntfs, mkfs.fat32, etc.
# 格式化分区 sudo mkfs.ext4 /dev/sdb1
In the Linux system, the file system needs to be mounted to the specified path, which can be set in the /etc/fstab file Set the option to automatically mount at startup. The following demonstrates how to manually mount and unmount the file system.
# 挂载文件系统 sudo mount /dev/sdb1 /mnt # 卸载文件系统 sudo umount /mnt
During use, you may need to expand or shrink the file system, you can use the resize2fs command.
# 扩展当前文件系统 sudo resize2fs /dev/sdb1
The above are basic operation guides and command examples for file system management and disk management in Linux systems, which we need to master and apply flexibly. Of course, if you need to perform more complex operations, such as RAID, you also need to strengthen your learning and practice.
The above is the detailed content of How to perform file system management and disk management in Linux systems. For more information, please follow other related articles on the PHP Chinese website!