View disk partition tables and file systems in Linux

Source: Internet
Author: User

Abstract: There are many tools for viewing and counting disk partition tables and file systems in Linux. Some tools are versatile, not only viewing disk partition tables, but also performing disk partition operations; however, in this article, we only talk about viewing disk partitions and the usage of partitions. This article is just for beginners. operations on the partition Tool, I will give a special introduction later. The purpose of this article is to introduce some basic knowledge necessary for beginners to learn more; if you put all the disk operation tools in one document, you will be tired of reading them. Based on this idea, when I write a document, I want to learn more about it, it's easy to understand. This is not true for life, work, and study. Operating Environment: Fedora Core 4.0 i686 & slackware 10.1
++
Body
++

1. df command;

DF comes from the 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 that the system is installed in/dev/hda8; there is also a 56 GB disk partition/dev/sda1 mounted in/mnt/sda1; for other parameters, see man DF
Ii. fdsik

Fdisk is a powerful disk operation tool from util-linux. Here we only talk about how to view the disk partition table and partition structure. The parameter-L is passed through the-l parameter, obtain the partition information of all the hard disks on 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 indicates the partition size, and 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; we have noticed that hda5, hda6, hda7, hda8, and hda9 belong to her. 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 = actually partitioned volume, 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 of unpartitioned space. fdisk-l can list the number of all disks on the machine and 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

We can know from the above that this machine has two hard disks, and we can also specify fdisk-L to view the partition of one of the hard disks;

[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

We can see from the above situation that there is only one partition in the/dev/SDA disk; The usage is almost; we can also view the/dev/hda

[root@localhost beinan]# fdisk -l /dev/hda

Try it yourself?

3. cfdisk comes from the util-Linux software package;

Cfdisk is also a good partitioning tool. In some releases, this tool has been removed from the util-linux package; cfdisk is simple and easy to use; similar to fdisk in DOS; in this topic, we will only describe how to view the disk partition status and the file system used in the machine; view the usage of the disk partition cfdisk-PS disk device name;
For example

[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 to list the disk partitions. Currently, cfdisk exists in mainstream releases such as slackware Debian manrake, and Fedora 4.0 removes this tool. A pity; this is what I operate in slackware; if you do this, it will be more intuitive;

[Root @ localhost beinan] cfdisk disk device name

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 enter the cfdisk operation interface. Move the pointer to [quit] on the keyboard to exit;
4. Parted is a good partitioning tool. You can install parted in fedora 4.0. In this topic, we only talk about how to view the disk partition information;

The call method is simple. By default, parted enables/dev/hda and can be specified by itself. For example, parted/dev/hda or/dev/SDA. The exit method is quit.

[root@localhost beinan]# parted

Use/dev/hda
(Parted) P
Disk geometric structure of/dev/hda: 0.000-76319.085 MB
Disk tag type: msdos
Minor start point termination point type file system flag
1 0.031 6000.842 startup of primary partition NTFS
2 6000.842 22003.088 primary partition FAT32 LBA
3 22003.088 60800.690 extended partitions
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 partd operation plane, P can be used to list the partitions of the current disk. If you want to view other disks, you can use the select function, such as select/dev/SDA;

5. qtparted. The software related to parted and qtparted can also view the disk structure and the file system used, which is graphical;

[Beinan @ localhost ~] # Visual display of qtparted at a glance;

6. sfdisk is also a partitioning tool with many features. Here we only talk about its column partitioning function;

[root@localhost beinan]# sfdisk -l 

Let's take a look. sfdisk has several useful functions. If you are interested, you may wish to take a look;
VII. partx: Some systems come with this tool, and its functions are simple. It is not worth mentioning 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:  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/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

9. Mac-fdisk is mainly used in PowerPC Linux. We do not use this tool in x86. This is just an introduction;
Related documents: Two Representation Methods for storing devices in Linux
Rational Planning of your hard disk partition
System guiding process and hard disk partition structure
Introduction to Linux commands for viewing disk partitions, file systems, usage, and related tools
How to Use fdisk for instance explanation
Loading NTFs and FAT32 partitions in Fedora Core 4.0
Fedora Core 4.0 Hal configuration plug-and-play mobile storage (USB and 1394) practices

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.