In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This "Linux system view partition commands which" article, the article sample code is very detailed, with a certain reference value, interested friends must refer to, for the "Linux system view partition commands what", Xiaobian sorted out the following knowledge points, please follow the pace of the editor step by step slowly understand, then let us enter the topic.
The lsblk command lists all block devices for the system and their logical partitions. Enter the following command in the terminal to list the partition table:
Lsblk
NAME-device name
MAJ:MIN-Major and Min Device number
Whether the RM- device is removable (1) or non-removable (0)
SIZE-device siz
RO-whether the device is read-only (1) or not (0)
TYPE-device type, that is, if it is a disk or partition, etc.
MOUNTPOINT-installation point of the device, if applicable.
In the output above, you can see all the logical partitions of my sda device from sda1 to sda5. The following seven columns are shown:
The fdisk command that uses the fdisk command to get the partition list represents a formatted disk or fixed disk is mainly used to create or delete hard disk partitions. It is also used to format disks, but here we will use it to list partition tables by using specific flags.
The-l flag is used with fdisk to list the partition table for the specified device, and then exit. If no device name is mentioned, fdisk uses the device mentioned in the / proc/partitions file.
The-l option displays the partition table for the specified device, and then exits. If no devices are given, those mentioned in / proc/partitions are used (if present). Enter the following command:
Linuxidc@linuxidc:~/www.linuxidc.com$ sudo fdisk-l
As you scroll down, the output displays the partition table, as follows:
Disk / dev/loop0:34.7 MiB,36323328 bytes, 70944 sector units: sector / 1 * 512 = 512 byte sector size (logical / physical): 512 bytes / 512 bytes Imax O size (minimum / best): 512 bytes / 512 bytes
…… Omit.
Linuxidc@linuxidc:~/www.linuxidc.com$ fdisk-l / dev/sda
Device boot start end sector size Id type / dev/sda1 * 2048 41940991 41938944 20G 8e Linux LVM
This is what the columns show:
Device-name of the device / logical partition
The * symbol in the boot-This column indicates that the corresponding partition contains the boot loader information used to boot the system
Start point-the start sector assigned to this partition.
End-the end sector assigned to this partition.
Sectors-the number of sectors allocated for this partition.
Size-the size of the partition.
The ID used by the ID- system for this partition
Type-the file type or system used by this partition.
Using the sfdisk command to view partitions although the sfdisk command is mainly used to manipulate partition tables on Linux, it can also be used to list partition tables for devices by using the following syntax:
Sudo sfdisk-l/dev/devicename
For example:
Sudo sfdisk-l / dev/sda
As you can see, this command provides the same partition table information as the fdisk command. You can only view the results of the fdisk and sfdisk commands as an authorized sudo user.
Another way to get the hard disk partition list device partition table using the parted command is through the parted command. The parted command has an advantage over the previously mentioned fdisk and sfdisk commands because the former does not list partitions larger than 2 TB in size.
View the partition table of the device using the following syntax:
Sudo parted / dev/devicename
Example:
Linuxidc@linuxidc:~/www.linuxidc.com$ sudo parted / dev/sdaGNU Parted 3.2Use / dev/sda Welcome to GNU Parted! Enter 'help' to get a list of commands. (parted)
The command enters "(parted)" prompt mode. You can enter the following values here to help you view the partition table of the device.
Unit GB: with this input, you can select the output displayed in GB.
Unit TB: with this input, you can select the output to display in TB.
Enter your selection, and the system will display the corresponding partition table.
Enter the help command and all available commands are listed. Cp,rm,resize,resure,set,mkparfs,print is commonly used.
1) print is used to display the current partition situation.
2) set can set the flag of the partition: set 1 boot on
3) mkpartfs creates a partition: mkpartfs primary linux-swap 1KB 2MB
4) rm deletes partitions, which can be restored with resure
5) cp will copy the partition content to the new partition
6) resize can change the size of the partition
Practical application scenarios: lossless compression of large partitions
You can modify the size of a partition with resize, but to be lossless, you can only reduce the end position of the partition because the information of the partition table is at the beginning. But how to know how much space the partition has taken up. You can use the df command to check: one item is available, and note that it cannot be calculated with the total capacity-used part, so let's not say why. In this way resize can guarantee lossless compression.
Note that the partition should be unmount before use. The swap partition must be swapoff before it can be modified. Open it with swapon after modification, and swapon-s can show the usage of the swap partition.
To exit parted command mode, simply type quit, and then click Enter.
Alternatively, you can list all partition layouts on all block devices on the system using the following command:
Linuxidc@linuxidc:~/www.linuxidc.com$ sudo parted-l
Because sda is my only block device, this command displays only that partition.
Note: the lsscsi command, which is primarily used to list SCSI devices and their attributes, also lists partition tables on some systems. You can install it with the following command: $sudo apt-get install lsscsi
What is Linux system Linux is a free-to-use and free-spread UNIX-like operating system, is a POSIX-based multi-user, multi-task, multi-threaded and multi-CPU operating system, using Linux can run major Unix tools, applications and network protocols.
The above is all the contents of the article "what are the partition commands in the Linux system?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to 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.