In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
In this article, the editor introduces in detail "what are the methods of Linux disk management", the content is detailed, the steps are clear, and the details are handled properly. I hope this article "what are the methods of Linux disk management" can help you solve your doubts? let's follow the editor's ideas to learn new knowledge.
1. Mounting and unmounting of storage devices commonly used operation commands: fdisk-l, df, du, mount, umount. Fdisk-l command
1. Function
Check the partition information of all hard drives, including unmounted partitions and USB devices. Use this command to view the names of partitions or USB devices when mounting, such as when mounting a USB drive.
Note: since the hardware exists as a file in Linux, you can also view the partition information of the first hard disk by ls-l / dev/sda*.
Df command
1. Function
Statistics of disk space or file system usage, showing the available disk space on the disk partition. The default display unit is KB.
2. Format
Df [option] 3, [option] main parameters
-an or-all: show all file systems-h or-- human-readable: display information in a readable manner-T or-- print-type: show the type of file system 4, application examples
View all file systems:
# df-adu command
1. Function
There are some differences between viewing the space used by the disk of a file or directory and the df command. Note: if the directory name or file name is not added after ① du, it only shows the directory size of the subdirectories under the current directory and the total size of the current directory. ② can view multiple files or directories separated by spaces.
2. Format
Du [option] directory name or file name 3, [option] main parameters
-an or-all: displays the size of individual files in the directory-h or-- human-readable: displays the readability of the information-S or-- separate-dirs in the unit of KMagazine G: omits the subdirectories under the specified directory and displays only the sum of that directory (Note: this command is uppercase S) 4. Application example
View the size of the ahao directory in an easy-to-read form and ignore the subdirectories:
# du-h-S ahao to view the size of 1 and 2 files in an easy-to-read format:
# du-h 1 2mount command
1. Function
① this command is followed by no arguments to view all mounted file systems
② plus parameters means that the storage device is mounted to a directory in Linux, thus associating the partition with that directory, so as long as we access this directory, we are equivalent to accessing the storage device.
Note: when there are files before a directory, after the device is mounted to this directory, the directory does not display the previous files.
2. Format
Mount [option] device name mount point (must already exist) 3, [option] main parameters
-t: the file system type vfat indicates that FAT32,iso9660 represents an optical disc or optical disc image, and auto indicates that the system automatically recognizes it (generally choose this convenient) 4. Application examples
Mount the partition / dev/sda5 of the FAT32 file system to the / ahao directory:
# mount-t auto / dev/sda5 / ahao Mount U disk / dev/sdb1 to / ahao directory:
# mount-t auto / dev/sdb1 / ahao attach the CD image file xxx.iso to the / peter directory:
# mount-t iso9660 xxx.iso / peter-o loopumount command
1. Function
Unmount a file system that is already loaded. You can umount the file system using either the device name or the mount point, but it is best to unmount it through the mount point, which is easy to cause confusion when a device has more than one mount point.
2. Format
① umount mount point (recommended) ② umount device name 3, application example
When unmounting a file system using the umount command, you must ensure that the file system cannot be in the busy state. There are situations in which the file system is in busy state: there are open files in the file system, the working directory of a process is in this system, and the cache files of the file system are being used. The most common error is to uninstall under the mount point directory.
Unmount the mount corresponding to the ahao mount point:
# umount / ahao2. The principle of auto-mount and auto-mount can be realized by modifying / etc/fstab configuration file, which can be modified by vi editor or by gedit command under the graphical interface / etc/fstab configuration file interpretation.
Open / etc/fstab configuration file
⑴ first column: ① device name / dev/sda1 or ② volume label label or ③ device UUID (Red Hat 6) (view the device's UUID blkid/dev/sda1)
The second column of ⑵: Mount point
Third column of ⑶: file system type
The fourth column of ⑷: mounting options, usually using defaults
The fifth column of ⑸: whether to back up, 1 means backup, 0 means no backup
The sixth column of ⑹: whether to check the file system. 1 means check, 0 means no check.
Application example
To automatically mount the USB disk to the / usb directory without backing up or checking the file system:
/ dev/sdb1 / usb auto defaults 0 add the above command to the / etc/fstab configuration file to complete the automatic mount of the USB disk. In order to avoid possible errors, use the mount-a command to verify whether the edited content is wrong.
3. When the disk partition is partitioned with fdisk in Linux, the most commonly used parameters are d, l, m, n, p, Q, t, w and so on.
Note:
The disk number of ① primary partition and extended partition is 1-4, that is, there are up to 4 primary or extended partitions, and the logical partition starts with a disk number of 5.
② if there are extended partitions on the hard disk, you can only add logical partitions, not extended partitions.
Fdisk command
1. Function
Partition the hard disk and use the traditional question-and-answer interface
2. Format
1) fidsk disk name 2) [option] first step: fidsk / dev/sdb: select the disk to be operated on. Here, the sdb mobile disk is operated.
Step 2: enter [option] to operate
3. [option] main parameters
M: list the commands that can be executed (help) p: check the current partition status of the disk n: create a new disk partition l: list the known partition type d: delete the existing partition t: change the partition type w; save the partition operation and exit Q: do not save the description of the exit partition process
① looks up the hard disk partition table information through the p parameter. Determine the future partition based on the information
② deletes the existing hard disk partitions one by one through the d parameter. If you want to completely change the partition format of the hard disk,
③ adds new partitions through the n parameter
1) Select the new partition type. P is the primary partition and e is the extended partition (when an extended partition exists, the e here becomes l, that is, the logical partition)
2) set the partition number. The primary or extended partition is 1-4, and the logical partition starts with 5
3) set the starting position of the partition. (generally enter is fine by default)
4) set the end position of the partition. (100 units are sectors, + 100m units are MMaginghe 100K units are K)
④ confirms that the partition is established successfully through the p parameter
⑤ exits by parameter w or Q (w for save and exit, Q for no save exit)
Note: when adding partitions, their types are the default Linux Native. If you need to change some of these partitions to other types, you can change them through the command t. When you type "t" to change the partition type, the system will prompt which partition to change and why (type l to view the partition type supported by the system and its corresponding partition class model).
IV. Disk formatting
After partitioning the hard disk, the partition needs to be formatted before it can be used. the main purpose of formatting the partition is to create a file system in the partition. The file system is the method and data structure used by OS to clearly store the files on the device or partition, that is, the method of organizing files on the storage device.
Mkfs command
1. Function
Format partitions and create file systems on partitions
2. Format
① mkfs [options] device name ② mkfs. [- v] device name 3, [option] main parameters
-t: select the type of file system to be created, such as ext3, ext4, etc. Different versions of Linux have different default file systems-V: show more output, including information about the file system (Note:-V must be placed before-t) 4. Application examples
Format the / dev/sdb1 partition and display specific information:
# mkfs-V-t vfat / dev/sdb1 # mkfs.vfat-v / dev/sdb1 read here, this article "what are the methods of Linux disk management" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it before you can understand it. If you want to learn more about related articles, please follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.