View Linux disk space size

Source: Internet
Author: User
Tags disk usage

One, DF command;

DF is from the Coreutils software package, the system is installed, it comes with, we can use this command to see the disk usage and the location of the file system is mounted;

Example:

[Email protected] beinan]# DF-LH

Filesystem capacity used% mount point available

/dev/hda8 11G 6.0G 4.4G 58%/

/dev/shm 236M 0 236M 0%/dev/shm

/DEV/SDA1 56G 22G 35G 39%/mnt/sda1

As we can see, the system is installed in/dev/hda8, and a 56G disk partition/dev/sda1 mounted in/mnt/sda1;

Other parameters refer to man DF

Second, Fdsik

FDISK is a powerful disk manipulation tool from the Util-linux software package, and we'll just say how he looks at the partition table and the partition structure; parameter-l, which can get the partition of all the hard disks in the machine through the-l parameter;

[Email protected] beinan]# fdisk-l

disk/dev/hda:80.0 GB, 80026361856 bytes

255 heads, Sectors/track, 9729 cylinders

Units = Cylinders of 16065 * 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+-up Linux

/dev/hda6 3826 5100 10241406-Up Linux

/dev/hda7 5101 5198 787153+, Linux Swap/solaris

/dev/hda8 5199 6657 11719386-up Linux

/DEV/HDA9 6658 7751 8787523+-up Linux

In the above blocks, represents the size of the partition, blocks unit is a byte, we can convert to M, such as the first partition/dev/hda1 size if converted to m, it should be 6144831/1024=6000m, that is, about 6G, in fact, no such trouble, A cursory look at the decimal point to move forward three bits, you know how much volume;

The file system represented by system, such as/DEV/HDA1, is in NTFS format;/dev/hda2 represents a file system in FAT32 format;.

In this case, we would like to pay special attention to the/DEV/HDA3 partition, which is the extended partition; he has a logical partition under the bread, in fact, the partition is equivalent to a container, from her own hda5,hda6,hda7,hda8,hda9;

We also noticed a little, why not hda4? Why is HDA4 not included in the extended partition? A disk has a maximum of four primary partitions, the hda1-4 is the primary partition, the HDA4 cannot be included in the extended partition, and the extended partition is also the primary partition, in this case, there is no HDA4 this partition, of course, we can set one of the partitions as the primary partition, but I did not do so when the partition;

To get a closer look, let's see if this disk still has space. Hda1+hda2+hda3= actually already partitioned the volume, so we can calculate this hda1+hda2+hda3=6144831+16386300+39728745 = 62259876 (b), convert to M units, the decimal point moves three bits forward, So the partition that has been partitioned is about 62259.876 (m), in fact the most accurate calculation 62259876/1024=60800.67 (m), and this disk size is 80.0 GB (80026361856byte), In fact, the actual size is 78150.744 (M); Through our series of calculations, we can conclude that the disk currently has a space to use, about 18G unpartitioned space;

Fdisk-l can list the number of all disks in the machine, and can also list all disk partitions, for example:

[Email protected] beinan]# fdisk-l

disk/dev/hda:80.0 GB, 80026361856 bytes

255 heads, Sectors/track, 9729 cylinders

Units = Cylinders of 16065 * 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+-up Linux

/dev/hda6 3826 5100 10241406-Up Linux

/dev/hda7 5101 5198 787153+, Linux Swap/solaris

/dev/hda8 5199 6657 11719386-up Linux

/DEV/HDA9 6658 7751 8787523+-up Linux

disk/dev/sda:60.0 GB, 60011642880 bytes

Heads, Sectors/track, 57231 cylinders

Units = Cylinders of 2048 * 1048576 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 1 57231 58604528 Linux

By the above we can know that this machine has two hard drives, we can also specify fdisk-l to see the partition of one of the hard disks;

[Email protected] beinan]# fdisk-l/DEV/SDA

disk/dev/sda:60.0 GB, 60011642880 bytes

Heads, Sectors/track, 57231 cylinders

Units = Cylinders of 2048 * 1048576 bytes

Device Boot Start End Blocks Id System

/DEV/SDA1 1 57231 58604528 Linux

As you can tell by the above, there is only one partition in the/DEV/SDA disk, and the usage is almost hundred percent;

We can also check out the/dev/hda

[Email protected] beinan]# fdisk-l/dev/hda

Try it yourself?

Third, Cfdisk from the Util-linux software package;

Cfdisk is also a good partitioning tool, in some distributions, this tool has been removed from the Util-linux package, Cfdisk easy-to-use is his feature, and the DOS is similar to Fdisk, in this title, We only explain how to check the disk partition status and the file system used in the machine;

To view disk partition usage Cfdisk-ps disk device name;

Like what

[Email protected] Beinan]cfdisk-ps

[Email protected] Beinan]cfdisk-ps/dev/hda

[Email protected] Beinan]cfdisk-ps

Partition Table For/dev/hda

First Last

# type Sector Sector Offset Length Filesystem type (ID) Flag

-- ------- ----------- ----------- ------ ----------- -------------------- ----

1 Primary 0 23438834 23438835 Linux ($) Boot

2 Primary 23438835 156296384 0 132857550 Extended (None)

5 Logical 23438835 155268224 131829390 Linux (None)

6 Logical 155268225 156296384 1028160 Linux Swap ($) None

We only use the parameters-ps, the partition of the disk is listed, currently in the Slackware Debian Mandrake and other mainstream distribution of cfdisk, and Fedora 4.0 to remove the gadget; it's a pity; this is what I do in Slackware;

If you do this, it is more intuitive;

[[Email protected] Beinan]cfdisk disk device name

Example:

[Email protected] 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 enter the Cfdisk interface; move the pointer to [quit] with the keyboard to exit;

Four, parted function good partition tool; There is a belt in Fedora 4.0 that can be installed on your own; In this topic, we only say how to view the partition of the disk;

The call method is simple, parted default is to open the device is/dev/hda, can also be specified by themselves, such as Parted/dev/hda or/DEV/SDA, etc., quit the method is quit

[Email protected] beinan]# parted

Using/dev/hda

(parted) p

/dev/hda disk geometry: 0.000-76319.085 MBytes

Disk label Type: MSDOS

Minor start point End point type file system flag

1 0.031 6000.842 primary partition NTFS boot

2 6000.842 22003.088 primary 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

We can use P to list the partition of the current disk in PARTD, and if you want to view other disks, you can use Select function, such as SELECT/DEV/SDA;

Five, qtparted, and parted related software and qtparted, can also see the structure of the disk and the file system used, is graphical;

[Email protected] ~]# qtparted

Graphical view, at a glance;

Six, Sfdisk is also a partition tool, the function is also a lot; we're here only to say that the function of the partition of his column disk;

[Email protected] beinan]# sfdisk-l

Take a look at it yourself;

Sfdisk has several useful functions, and interested brothers may wish to look at it;

Seven, Partx also briefly said that some systems bring this tool, the function is simple, and Fdisk, parted, Cfdisk, not worth mentioning;

Usage: PARTX device name

[Email protected] 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: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)

Eight, to view all the current machine disk and partition conditions:

[Email protected] ~]$ cat/proc/partitions

Major Minor #blocks name

3 0 78150744 Hda

3 1 6144831 hda1

3 2 16386300 Hda2

3 5 8193118 Hda5

3 6 10241406 Hda6

3 7 787153 Hda7

3 8 11719386 Hda8

3 9 8787523 Hda9

8 0 58605120 SDA

8 1 58604528 sda1

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.