View Linux disk space

Source: Internet
Author: User
View disk space size in Linux 1. df command; df comes from coreutils software package and comes with it during system installation; we can use this command to view the disk usage and the location where the file system is mounted. for example: [root @ localhostbeinan] # df-lhFile... view disk space size in Linux 1. df command; df comes from coreutils software package and comes with it during system installation; we can use this command to view the disk usage and the location where the file system is mounted. for example: [root @ localhost beinan] # df-lhFilesystem capacity in use available % mount point/dev/hda8 11G 6.0G 4.4G 58%/dev/shm 236 M 0 236 M 0%/ dev/shm/dev/sda1 56G 22G 35G 39%/mnt/sda1 we can see from this, the system is installed in/dev/hda8; there is also a 56 GB disk partition Mount/dev/sda1 to/mnt/sda1. for other parameters, see man df 2. fdsikfdisk is a powerful disk operation tool from util-linux software package, here we will only talk about how to view the disk partition table and partition structure. the-l parameter can be used to obtain the partition information of all the hard disks on the machine; [root @ localhost beinan] # fdisk-lDisk/dev/hda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice Boot Start End Blocks Id System/dev/hda1 * 1 765 6144831 7 HPFS/NTFS/dev/hda2 766 2805 16386 300 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 on Blocks, it indicates the partition size. the unit of Blocks is byte. 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/1024 = 6000 M, that is, about 6 GB. In fact, it is not so troublesome. let's take a rough look at moving the decimal point forward to three digits and we will know the approximate size. System indicates the file System. for example,/dev/hda1 is in NTFS format;/dev/hda2 indicates a file System in fat32 format ;. in this example, 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; from her, there are hda5, hda6, hda7, hda8, and hda9. We also noticed that why is there no hda4? Why is hda4 not included in the extended partition? A disk can have up to four primary partitions; a hda1-4 is regarded as the primary partition; hda4 cannot be included in the extended partition, and the extended partition is also considered the primary partition; in this example, there is no hda4 partition, of course, we can set one of the partitions as the primary partition, but I didn't do this at the time of partitioning. then, let's take a closer look at the statistics and see if there is space on this disk? Hda1 + hda2 + hda3 = volume of already partitioned instances, so we can calculate hda1 + hda2 + hda3 = 6144831 + 16386300 + 39728745 = 62259876 (B) and convert it into M units, the decimal point is shifted to three places, so the size of the partition that has been divided is about 62259.876 (M). In fact, the most accurate calculation is 62259876/1024 = 60800.67 (M ); the size of this disk is 80.0 GB (80026361856 bytes). In fact, the actual size is 78150.744 (M). through a series of calculations, we can see that there is still space for this hard disk; there is about 18 GB unpartitioned space. fdisk-l can list the number of all disks on the machine and all disk partitions. for example: [root @ localhost beinan] # fdisk-lDisk/dev/hda: 80.0 GB, 80026361856 bytes255 heads, 63 sectors/track, 9729 cylindersUnits = cylinders of 16065*512 = 8225280 bytesDevice 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 Linu X/dev/hda9 6658 7751 8787523 + 83 LinuxDisk/dev/sda: 60.0 GB, 60011642880 bytes64 heads, 32 sectors/track, 57231 cylindersUnits = cylinders of 2048*512 = 1048576 bytesDevice Boot Start End Blocks Id System/dev/sda1 1 57231 58604528 83 Linux through the above we can know that this machine has two hard disks, you can also specify fdisk-l to view the partition of one of the hard disks. [root @ localhost beinan] # fdisk-l/dev/sdaDisk/dev/sda: 60.0 GB, 60011642880 bytes64 heads, 32 sectors/trac K, 57231 cylindersUnits = cylinders of 2048*512 = 1048576 bytesDevice Boot Start End Blocks Id System/dev/sda1 1 57231 58604528 83 Linux you can see through the above situation, in the/dev/sda disk, there is only one partition, and the usage is almost; you can also view the [root @ localhost beinan] # fdisk-l/dev/hda of/dev/hda? 3. cfdisk comes from the util-linux software package; cfdisk is also a good partition tool; in some releases, this tool has been removed from the util-linux package; cfdisk is simple and easy to use. it is similar to fdisk in DOS. in this topic, we will only explain how to view the disk partition status and the file system used in the machine; view disk partition usage cfdisk-Ps disk device name; for example, [root @ localhost beinan] cfdisk-Ps [root @ localhost beinan] cfdisk-Ps/dev/hda [root @ localhost beinan] cfdisk-PsPartition Table for/dev/hdaFirst Last # type Sector Offset Length Filesystem Type (ID) flag -------------------- ----------- ------ ----------- ------------------ ---- 1 Primary 0 23438834 63 23438835 Linux (83) Boot2 Primary 23438835 156296384 0 132857550 Extended (05) None5 Logical 23438835 155268224 63 131829390 Linux (83) none6 Logical 155268225 156296384 63 1028160 Linux swap (82) None we only use the-Ps parameter to list the disk partitions. Currently, cfdisk exists in mainstream releases such as Slackware Debian manrake, fedora 4.0 removes this gadget. it's a pity that I am using this tool in Slackware. if you [Root @ localhost beinan] cfdisk device name example: [root @ localhost beinan] cfdisk/dev/hda what you see is the following mode: cfdisk 2.12 aDisk Drive:/dev/hdaSize: 80026361856 bytes, 80.0 GBHeads: 255 Sectors per Track: 63 Cylinders: 9729 Name Flags Part Type FS Type [Label] Size (MB) ------------------------------------------------------------------------------------------- hda1 Boot Primary Linux ReiserFS 12000.69hda5 Logical Linux ReiserFS 67496.65hda6 Logical Linux swap 526.42 [Bootable] [Delete] [Help] [Maximize] [Print] [Quit] [Type] [Units] [Write] Toggle bootable flag of the current partition you enter the cfdisk operation interface; move the pointer to [Quit] on the keyboard to exit. 4. parted is a good partitioning tool. it is included in Fedora 4.0 and can be installed by yourself. in this topic, we only talk about how to view the partition information of the disk. The Calling method is simple. by default, parted enables/dev/hda, or you can specify it yourself; for example, parted/dev/hda or/dev/sda. the exit method is quit [root @ localhost beinan] # part. Ed uses the/dev/hda (parted) p/dev/hda disk RY: 0.000-76319.085 MB disk tag type: msdosMinor start point termination point type file system flag 1 0.031 6000.842 primary partition ntfs start 2 6000.842 primary partition fat32 lba3 22003.088 extended partition 5 22003.088 60800.690 logical partition reiserfs6 22003.119 logical partition reiserfs7 30004.211 30004.242 logic partition linux-swap8 40774.381 52219.094 logical partition ext39 52219.125 60800.690 logical partition reiserfs we're on the partd operation side, use p to list the partitions of the current disk. if you want to view other disks, you can Using the select function, such as select/dev/sda; 5. qtparted, the parted-related software and qtparted can also view the disk structure and the file system used, which is graphical; [beinan @ localhost ~] # Qtparted graphical display at a glance; 6. sfdisk is also a partition tool with many features; here we only talk about its column disk partition function; [root @ localhost beinan] # sfdisk-l Let's take a look at it. sfdisk has several useful functions. if you are interested, let's take a look. 7. partx also gives a brief description, some systems come with this tool, which has simple functions. it is not worth mentioning in terms of fdisk, parted, and cfdisk. no need to mention it. 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, 4068 2 MB) #4: 0--1 (0 sectors, 0 MB) #5: 45062388-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. View all disks and partitions on the current machine: [beinan @ localhost ~] $ Cat/proc/partitionsmajor minor # blocks name3 0 78150744 hda3 1 6144831 hda13 2 16386300 hda23 5 8193118 hda53 6 10241406 hda63 7 787153 hda73 8 11719386 hda83 9 8787523 hda98 0 58605120 sda8 1 58604528
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.