In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Linux to check the size of the hard disk and the implementation of mounting the hard disk? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
1.df
The df command can get information such as how much space the hard disk is occupied and how much space is left so far, and it can also show the use of I nodes and disk blocks by all file systems.
The various options of the df command mean the following:
-a: displays the disk usage of all file systems, including 0 (block) file systems, such as / proc file systems.
-k: displayed in k bytes.
-I: displays I node information instead of disk blocks.
-t: displays the disk space usage of each specified type of file system.
-x: lists disk space usage that is not a specified type of file system (as opposed to the t option).
-T: displays the file system type.
Let's first look at an example of using the df command:
/ / list the disk space usage of each file system # dfFilesystem 1k-blocks Used Available Use% Mounted on/dev/hda5 381139 332921 28540 93% / / dev/hda1 46636 6871 37357 16% / boot/dev/hda3 10041144 6632528 2898556% / homenone 127372 0 127372% / dev/shm/dev/hda2 27474876 24130460 1948772% / usr/dev/hda6 256667 232729 10686 96% / var
The first column represents the pathname of the device file corresponding to the file system (usually the partition on the hard disk); the second column gives the number of blocks (1024 bytes) contained in the partition; and the third and fourth columns represent the number of blocks used and available, respectively.
◆ users may be surprised that the sum of the number of blocks in column 3 and 4 is not equal to the number of blocks in column 2. This is because the default each partition leaves a small amount of space for the system administrator to use. Even if the normal user space is full, the administrator can still log in and leave the workspace needed to solve the problem. The Use% column in the list represents the percentage of normal user space used, and if this number reaches 100%, the partition still has space for the system administrator.
Finally, the Mounted on column represents the mount point of the file system.
/ / lists the I node usage of each file system. # df-/ proc/dev/hda1 12048 38 12010 1% / bootnone 00 iaFilesystem Inodes IUsed IFree IUse% Mounted on/dev/hda5 98392 23919 74473 25% / none 1275456 355008 920448 28% / homenone 31843 1 31842 1% / dev/shm/dev/hda2 3489792 133637 33564% / usr/dev/hda6 66264 9876 56388 15% / var// lists the type of file system. # df-TFilesystem Type 1k-blocks Used Available Use% Mounted on/dev/hda5 ext3 381139 332921 28540 93% / / dev/hda1 ext3 46636 6871 37357 16% / boot/dev/hda3 ext3 10041144 6632528 2898556% / homenone tmpfs 127372 0 127372% / dev/shm/dev/hda2 ext3 27474876 24130460 1948772 93% / usr/dev/hda6 ext3 256667 232729 10686 96% / var2
2. Du
The original meaning of du is "disk usage", which means to show the use of disk space and count the amount of disk space occupied by directories (or files). The function of this command is to step into each subdirectory of the specified directory and show how the directory occupies file system blocks (1024 bytes). If no specified directory is given, the current directory is counted.
The options of the df command mean the following:
-s: only the total number of blocks occupied is given for each Names parameter.
-a: recursively displays the number of data blocks occupied by each file in the specified directory and in each subdirectory. If neither-s nor-an is specified, only the number of disk blocks occupied by each directory and its subdirectories in the Names is displayed.
-b: lists disk space usage in bytes (the system defaults to k bytes).
-k: lists disk space usage in 1024 bytes.
-c: finally, add a total (the system default).
-l: calculate all file sizes, and for hard-linked files, calculate multiple times.
-x: directories skipped on different file systems are not counted.
-h: converted to easy-to-read 2m, 2G format display.
The following example illustrates the use of the du command:
/ / View the disk space occupied by the / mnt directory # du-abk / mnt1 / mnt/cdrom1 / mnt/floppy3 / mnt// lists the disk space occupied by each directory, but does not list in detail the space occupied by each file # du3684. / log84. / libnids-1.17/doc720. / libnids-1.17/src32. / libnids-1.17/samples1064. / libnids-1.174944.
The first column in the output list is the disk space capacity in blocks, and the second column lists the directory names that use that space in the directory.
◆ this can be a long list, sometimes just a total. At this point, you can add the-s option to the du command to get the total:
# du-s / mnt 3 / mnt// lists the space occupied by all files and directories (using option a) and calculates the size in bytes (using option b) # du-ab / root/mail6144 mail/sent-mail1024 mail/saved-messages8192 mail
3 、 fdisk
Fdisk can partition the disk. The following steps are given for disk partitioning using the Fdisk command:
# fdisk / dev/had / / use / dev/had as the default partition device Command (m for help): M / / Select command option Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition l list known partition types m print this menu n add a new partition o create a new empty DOS partition table p print the partition table q quit without saving changes s create a new empty Sun disklabel t change a partition's system id u change display/entry units v verify the partition table w write table to disk and exit x extra functionality (experts only)
The user can display a description of each parameter of the Fdisk command by prompting for "m".
Fdisk has many parameters, but only a few are often used.
◆ in the Linux partition process, generally through the p parameter to display the hard disk partition table information, and then determine the future partition according to the information. As follows:
Disk / dev/sda: 4294 MB, 4294967296 bytes255 heads, 63 sectors/track, 522 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System/dev/hda1 * 41 522 3871665 83 Linux/dev/hda2 1 40 321268 + 82 Linux swapPartition table entries are not in disk orderCommand (m for help):
◆ if you want to completely change the partition format of the hard disk, you can delete the existing hard disk partitions one by one with the d parameter. Once deleted, the new partition can be added with the n parameter. When you press "n", you can see something like this:
Command (m for help): nCommand action e extended p primary partition (1-4) p Partiton number (1-4): 1 First cylinder (1-1023): 1 Last cylinder or + size or + sizeK or + sizeM (1-1023): + 258m
Here you want to select the new partition type, whether it is a primary partition or an extended partition, and select p or e. Then set the size of the partition.
◆ should remind you that if you have extended partitions on your hard disk, you can only add logical partitions, not extended partitions.
When ◆ adds partitions, its type is the default Linux Native. If you want to change some of these partitions to other types, such as Linux Swap or FAT32, you can change them with the command t. When you press "t" to change the partition type, the system will prompt which partition to change and what type to change (if you want to know the partition type supported by the system, type l), as follows:
Command (m for help): tPartition number (1-4): 1Hex code (type L to list codes): 82Changed system type of partition 1 to 82 (Linux swap)
After changing the partition type, you can press "w" to save and exit. If you do not want to save, you can select "Q" to exit directly, as shown below:
Command (m for help): W is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.