In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to disk space under the linux system". In the daily operation, I believe that many people have doubts about how to disk space under the linux system. The editor consulted all kinds of data and sorted out a simple and easy-to-use method of operation. I hope it will be helpful to answer the doubts about "how to disk space under the linux system". Next, please follow the editor to study!
1. Df command
Df comes from the coreutils software package, which comes with the system when it is installed. We can check the disk usage and the location where the file system is mounted through this command.
For example:
[root@localhost beinan] # df-lh
Filesystem capacity used available used mount point
/ dev/hda8 11G 6.0G 4.4G 58% /
/ dev/shm 236M 0 236m 0% / dev/shm
/ dev/sda1 56G 22G 35G 39% / mnt/sda1
We can see that the system is installed in / dev/hda8; there is also a 56g disk partition / dev/sda1 mounted in / mnt/sda1
For other parameters, please refer to man df
II. Fdsik
Fdisk is a powerful disk operation tool, from the util-linux software package, we only say here how to view the disk partition table and partition structure; parameter-l, through the-l parameter, you can get the partition of all the hard drives in the machine.
[root@localhost beinan] # fdisk-l
Disk / dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/ dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/ dev/hda3 2806 7751 39728745 5 Extended
/ dev/hda5 2806 3825 8193118 + 83 Linux
/ dev/hda6 3826 5100 10241406 83 Linux
/ dev/hda7 5101 5198 787153 + 82 Linux swap / Solaris
/ dev/hda8 5199 6657 11719386 83 Linux
/ dev/hda9 6658 7751 8787523 + 83 Linux
In the above Blocks, it represents the size of the partition. The unit of Blocks is byte, and we can convert it to M. For example, if the size of the first partition / dev/hda1 is converted to M, it should be 6144831 1024mm 6000m, that is, about 6G. In fact, it is not so troublesome. Take a rough look at moving the decimal point forward three places, you will know how big the approximate volume is.
System represents a file system, such as / dev/hda1 is in NTFS format; / dev/hda2 is a file system in fat32 format;.
In this case, we should pay special attention to the / dev/hda3 partition, which is an extended partition; it contains a logical partition, which is actually equivalent to a container; her subordinate is hda5,hda6,hda7,hda8,hda9
We also noticed that there is no hda4. Why is hda4 not included in the extended partition? A disk has at most four primary partitions; hda1-4 counts as the primary partition; hda4 cannot be included in the extended partition, and the extended partition is also counted as the primary partition; in this case, there is no hda4 partition, of course, we can set one of the partitions as the primary partition, but I didn't do it at that time.
Let's take a closer look at the statistics and see if there is still room on this disk. Hda1+hda2+hda3= actually has the volume of the partition, so we can calculate hda1+hda2+hda3=6144831+16386300+39728745 = 62259876 (b), converted into M units, and the decimal point moves forward three places, so the partition that has been divided so far occupies a volume of about 62259.876 (M), in fact, the most accurate calculation is 62259876 GB (M); and the disk size is 80.0 GB (80026361856byte), in fact, the actual size is 78150.744 (M). Through a series of calculations, we can conclude that there is still room for use on this hard disk; there is still about 18G of unpartitioned space.
Fdisk-l can list the number of all disks in the machine, as well as all disk partitions; for example:
[root@localhost beinan] # fdisk-l
Disk / dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/ dev/hda1 * 1 765 6144831 7 HPFS/NTFS
/ dev/hda2 766 2805 16386300 c W95 FAT32 (LBA)
/ dev/hda3 2806 7751 39728745 5 Extended
/ dev/hda5 2806 3825 8193118 + 83 Linux
/ dev/hda6 3826 5100 10241406 83 Linux
/ dev/hda7 5101 5198 787153 + 82 Linux swap / Solaris
/ dev/hda8 5199 6657 11719386 83 Linux
/ dev/hda9 6658 7751 8787523 + 83 Linux
Disk / dev/sda: 60.0 GB, 60011642880 bytes
64 heads, 32 sectors/track, 57231 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 1 57231 58604528 83 Linux
From the above we can know that this machine has two hard drives, and we can also specify fdisk-l to check the partition of one of the hard drives.
[root@localhost beinan] # fdisk-l / dev/sda
Disk / dev/sda: 60.0 GB, 60011642880 bytes
64 heads, 32 sectors/track, 57231 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Device Boot Start End Blocks Id System
/ dev/sda1 1 57231 58604528 83 Linux
As you can see from the above, there is only one partition on the / dev/sda disk; the usage is almost 100%.
We can also check / dev/hda 's
[root@localhost beinan] # fdisk-l / dev/hda
Try it yourself?
Cfdisk comes from the software package of util-linux.
Cfdisk is also a good partitioning tool; in some distributions, this tool has been removed from the util-linux package; cfdisk is easy to use; it is similar to fdisk in DOS; in this title, we will only explain how to check the disk partition status and the file system used in the machine.
View the use of disk partitions cfdisk-Ps disk device name
such as
[root@localhost beinan] cfdisk-Ps
[root@localhost beinan] cfdisk-Ps / dev/hda
[root@localhost beinan] cfdisk-Ps
Partition Table for / dev/hda
First Last
# Type Sector Sector Offset Length Filesystem Type (ID) Flag
-
1 Primary 0 23438834 63 23438835 Linux (83) Boot
2 Primary 23438835 156296384 0 132857550 Extended (05) None
5 Logical 23438835 155268224 63 131829390 Linux (83) None
6 Logical 155268225 156296384 63 1028160 Linux swap (82) None
We only use the parameter-Ps, which lists the partition of the disk; currently, cfdisk exists in mainstream distributions such as Slackware Debian Mandrake, and fedora 4.0 removes this gadget; it's a bit of a pity; this is what I do in Slackware.
If you do this, it will be more intuitive.
[root@localhost beinan] cfdisk disk device name
For example:
[root@localhost beinan] cfdisk / dev/hda
What you see is the following pattern:
Cfdisk 2.12a
Disk Drive: / dev/hda
Size: 80026361856 bytes, 80.0 GB
Heads: 255 Sectors per Track: 63 Cylinders: 9729
Name Flags Part Type FS Type [Label] Size (MB)
-
Hda1 Boot Primary Linux ReiserFS 12000.69
Hda5 Logical Linux ReiserFS 67496.65
Hda6 Logical Linux swap 526.42
[Bootable] [Delete] [Help] [Maximize] [Print] [Quit]
[Type] [Units] [Write]
Toggle bootable flag of the current partition
You have entered the cfdisk interface; you can exit by moving the pointer to [Quit] with the keyboard
4. Parted is a good partitioning tool; it comes with Fedora 4.0and can be installed by yourself. In this topic, we only talk about how to check the partition of a disk.
The calling method is simple. Parted defaults to open device / dev/hda, or you can specify it yourself, such as parted / dev/hda or / dev/sda. The exit method is quit.
[root@localhost beinan] # parted
Use / dev/hda
(parted) p
/ dev/hda disk geometry: 0.000-76319.085 megabytes
Disk label type: msdos
Minor start point end point type file system flag
1 0.031 6000.842 primary partition ntfs startup
2 6000.842 22003.088 main partition fat32 lba
3 22003.088 60800.690 extended Partition
5 22003.119 30004.211 logical partition reiserfs
6 30004.242 40005.615 logical partition reiserfs
7 40005.646 40774.350 logical partition linux-swap
8 40774.381 52219.094 logical partition ext3
9 52219.125 60800.690 logical partition reiserfs
On the operating surface of partd, we can use p to list the partitions of the current disk. If you want to view other disks, you can use select functions, such as select / dev/sda
Qtparted, and parted-related software such as qtparted, can also see the structure of the disk and the file system used, which is graphical
[beinan@localhost ~] # qtparted
Graphical view, clear at a glance
6. Sfdisk is also a partitioning tool with many functions. Here we will only talk about its functions of listing disk partitions.
[root@localhost beinan] # sfdisk-l
See for yourself.
Sfdisk has several useful functions; if you are interested, take a look at it.
7. Partx also briefly said that some systems come with this tool, and the function is simple, which is not worth mentioning compared with fdisk, parted, and cfdisk.
Usage: partx device name
[root@localhost beinan] # partx / dev/hda
# 1: 63-12289724 (12289662 sectors, 6292 MB)
# 2: 12289725-45062324 (32772600 sectors, 16779 MB)
# 3: 45062325-124519814 (79457490 sectors, 40682 MB)
# 4: 0-1 (0 sectors, 0 MB)
# 5: 450 62388-61448624 (16386237 sectors, 8389 MB)
# 6: 61448688-81931499 (20482812 sectors, 10487 MB)
# 7: 81931563-83505869 (1574307 sectors, 806 MB)
# 8: 83505933-106944704 (23438772 sectors, 12000 MB)
# 9: 106944768-124519814 (17575047 sectors, 8998 MB)
8. Check all the disks and partitions in the current machine:
[beinan@localhost ~] $cat / proc/partitions
Major minor # blocks name
3 0 78150744 hda
31 6144831 hda1
3 2 16386300 hda2
3 5 8193118 hda5
3 6 10241406 hda6
3 7 787153 hda7
38 11719386 hda8
3 9 8787523 hda9
8 0 58605120 sda
8 1 58604528 sda1
At this point, the study of "how to get disk space under the linux system" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.