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 > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Linux disk management Linux disk management is directly related to the performance of the whole system the three commands commonly used in Linux disk management are df, du and fdiskdf: list the overall disk usage of the file system
Df command parameter function: check the disk space consumption of the file system. You can use this command to get information such as how much space the hard disk is occupied and how much space is left.
Syntax:
Df [- ahikHTm] [directory or file name]
Options and parameters:
-a: list all file systems, including system-specific / proc file systems
-k: displays each file system in the capacity of KBytes
-m: displays each file system in the capacity of MBytes
-h: self-display in GBytes, MBytes, KBytes and other formats that are easy for people to read
-H: the carry mode of replacing Mistral 1024K with MIMO 1000K
-T: displays the file system type, along with the filesystem name of the partition (for example, ext3)
-I: no hard disk capacity is used, but the number of inode is displayed.
Du
The Linux du command also looks at the usage space, but what is different from the df command is whether the Linux du command looks at the space used by the file and directory disk, or there is some difference from the df command. Here is the Linux du command.
Syntax:
Du [- ahskm] file or directory name
Options and parameters:
-a: list all the file and directory capacity, because by default only the number of files under the directory is counted.
-h: displayed in a capacity format that is easy for people to read (Gplop M)
-s: list only the total amount, but not the capacity occupied by each separate directory
-S: does not include the total under the subdirectory, which is slightly different from-s.
-k: displayed in KBytes list capacity
-m: displayed in MBytes list capacity
Fdisk
Fdisk is Linux's disk partition table manipulation tool.
Syntax:
Fdisk [- l] device name
Options and parameters:
-l: outputs all the partition contents of the device that follows. If there is only fdisk-l, the system will list the partitions of the devices that can be found in the entire system.
Disk formatting
After the partition of the disk is completed, it is natural to format the file system. The formatting command is very simple, using the mkfs (make filesystem) command.
Syntax:
Mkfs [- t file system format] device file name
Fdisk
Fdisk is Linux's disk partition table manipulation tool.
Syntax:
Fdisk [- l] device name
Options and parameters:
-l: outputs all the partition contents of the device that follows. If there is only fdisk-l, the system will list the partitions of the devices that can be found in the entire system.
Disk mounting and dismounting
Disk mount of Linux uses the mount command, and uninstall uses the umount command.
Disk mount syntax:
Mount [- t file system] [- L Label name] [- o extra option] [- n] device file name mount point
Now let's manage our disks on Linux.
First of all, click a small button in the lower right corner like the hard disk, come out a virtual machine settings to choose which item of the hard disk, and click "add"
Click the next step directly here.
Select to add 60 G and click next.
Disk files are recommended to be placed in the same file as the virtual machine to facilitate deletion at that time. After adding, we must restart the computer and use the command reboot or init 6. If we do not restart the computer hard disk, it will not be recognized.
After reboot, go to the / dev directory to see if the hard drive you just added is recognized. This sdb is the hard drive that has just been added. It seems that the system has successfully identified the hard drive.
Use the fdisk-l command to view the current disk information. You can also see the second disk sdb you just added. For specific disk management commands, please see the beginning of the article.
Use fdisk / dev/sdb to enter configuration mode for sdb hard drives
Enter m to get help, and the specific English explanation is below
A switch of startable flags
B Edit bsd disk label
C Toggle dos compatibility Flag
D delete partition
G create a new empty GPT partition table
G create an IRIX (SGI) partition table
L list known partition types
M print this menu
N add a new partition
O create a new empty DOS partition table
P print partition table
Q quit without saving your changes
S Let's create a new empty disk label
T change the system id of the partition
U change display / input unit
V verify partition table
W write the table to disk and exit
X additional features (for experts only)
Enter n to choose to add a new partition. Primary (0 primary, 0 extended, 4 free) here means that the primary partition (0 primary partition, 0 extended partition, 4 free) Linux system can only have 4 primary partitions on the local disk. If you want to configure the extended partition, you must already have one primary partition.
Next, press p to create a main partition, enter the partition number defaults to 1 enter, and the starting sector defaults to 2048 direct enter. I chose 15G to set the partition size.
Press p to query, okay, the first partition has been completed.
Continue to enter n to create a second primary partition with a set size of 10G
Continue to create a partition with n, this time instead of creating a primary partition, create an extended partition and give it the remaining 35G size.
Press p to view the extended partition on this side is also set up, because the extended partition can not directly write data, we need to continue to create logical partitions.
Then press n, and then enter "l" to create the first logical partition. A question arises here: why doesn't the partition of a logical partition start with the default partition 4? It is obvious that partition 4 was not set just now, because the Linux system leaves the first four partition numbers to the primary partition by default. If the primary partition does not use enough partition numbers, it also retains it by default, so the logical first partition starts from partition 5.
Next, enter "n" and "l" to create the second logical partition and enter all the way to give the remaining 27g to the last partition.
Next, press "m" to view the partition information. All the space of the newly added disk here has been allocated.
Then we need to change the ID number of partition 5 to swap mode. Enter the "t" partition number 5 and the ID number 82 of the swap partition. If you don't know it, you can enter L to view it.
If you want to delete a partition, press "d" to enter the partition number, the partition has been deleted, because the latest version of Linux is the xfs file system directly choose the default does not need to change its file system
Type "w" to save and exit, and then we are going to format what has just been divided.
Directly format the first partition you just added using mkfs-t xfs / dev/sdb1
The partition has been formatted and cannot be used in Linux. Another indispensable step is mounting. Create a mount point (folder 1) in the file that the system mounts to us by default. Use
The mount / dev/sdb1 / mnt/1 command mounts the sdb1 partition to / mnt/1. Using the df-hT command to check the mount, it is found that the sdb1 partition has been successfully mounted.
Swap partitions are virtual memory, and swap acts as a function of memory when there is insufficient hardware memory. But how to use it? first of all, the command used here is mkswap / dev/sdb5. You can see that the swap partition sdb5 has been formatted.
Use the command cat / proc/meminfo | grep-I swap to see that the capacity of the current swap partition is 4G
Use the command swapon / dev/sdb5 to enable the use of swap partitions and the command to close swap partitions is (swapoff device file name). Continue to use cat / proc/meminfo | grep-I swap to check the swap capacity. You can see that swap partitions have been added to 12 gigabytes. If you don't want to use it, you can just use the swapoff command.
These are some simple disk management on the Linux system.
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.