Management of the Linux file system view disk partitions, file systems, command usage and related tools introduced ...

Author: North-South-North
from: League of Legends Community
Summary: Linux disk partition table, file system view, a lot of statistical tools, some tools are multifunctional, not only to view disk's partition table, but also to disk partitions operation; but in this article, we talk about partition of view, and view usage of partition; this is only to novice purposes; operating on partitioning tool, I will do later devoted;

This article Objective: The main point is to introduce beginners to the basics entry required, with the basics to advanced; if all the disk manipulation tools are placed in a document, we looked tired; based on this the idea, so I write a document, you want to know the novice brothers one eye, can easily point to easily point; live, work and study there were not so;

Operating Environment: Fedora Core 4.0 10.1 i686 & Slackware


++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++++++++++++++++++++++
text
++++++++++++++++++++ ++++++++++++++++++++++++++++++++++++++++++++++++++ +++++++++


a, df command;

df from coreutils package, system installation, it comes; we can view disk usage and the location of the file system is mounted by this command;

For example:

[beinan the root @ localhost] # DF -LH 
the Filesystem capacity has been available with a mount point% 
/ dev / hda8 11G 6.0G 4.4G 58% / 
/ dev / SHM 236M 236M 0 0% / dev / SHM 
/ dev / sda1 56G 22G 35G 39% / mnt / sda1

From which we can see, the system installed in the / dev / hda8; there is a 56G disk partition / dev / sda1 mounted on / mnt / sda1 in;

Other parameters, please refer to man df


Two, fdsik

fdisk is a powerful tool for disk operations, from util-linux package, we are here to just say how his view disk partition table and partition structure; -l parameters, the -l option, the machine can get all of the the hard disk partition situation;

[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

Blocks above, the size of the partition is indicated, Blocks unit is byte, we can be converted into M, such as the first partition / dev / hda1 if the size in terms of M, should be 6144831/1024 = 6000M, i.e. about 6G, in fact, not so troublesome, rough look forward to moving the decimal point three, you know about how much the volume;
file system system representation, such as / dev / hda1 is NTFS format; / dev / hda2 represents It is fat32 formatted file system;.

In this example, we pay special attention to is that / dev / hda3 partition, which is the extended partition; he includes the following logical partition, in fact, this partition is equivalent to a container; subordinate to her there hda5, hda6, hda7, hda8, hda9;

We also note that, how not hda4 it? Why hda4 not included in the extended partition? A disk up to four primary partitions; hda1-4 are considered primary partition; hda4 not contain the extended partition, the partition can be considered further extended primary partition; in this case, no hda4 this partition, we can of course wherein a partition set primary partition, but I did not do it when the district;

A closer look at statistics, we take a look at this disk space is not there? hda1 + hda2 + hda3 = actual volume has been partitioned, so we can count hda1 + hda2 + hda3 = 6144831 + 16386300 + 39728745 = 62259876 (b), in terms of M units to move forward three decimal places, so now divided good partition volume is occupied by approximately 62259.876 (M), in fact the most accurate calculation 62259876/1024 = 60800.67 (M); and the size of the disk is 80.0 GB (80026361856byte), in fact, the actual size is 78150.744 (M); through us series of calculations, we can conclude that there are still using hard disk space that is; there are still about 18G unpartitioned space;

fdisk -l can list the number of machines in all disks, disk partitions can list all cases; 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

Through the above we can see that this machine has two hard drives, we can also specify fdisk -l to see a situation in which partition the hard drive;

[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

Can know by the above case, / dev / sda the disk, only one partition; the use of almost a hundred percent;

Since we can see / dev / hda of

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

Try it yourself?

Three, cfdisk from the util-linux package;

cfdisk is a good partitioning tool; in some release, this tool has been removed from the util-linux package; cfdisk is his characteristic easy to use; and in DOS the fdisk similar; in this title, we have only to explain how to view the status of the machine's disk partitions and file systems used;

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 -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 parameters -Ps, it lists the partitioning disks; cfdisk currently exist in Slackware Debian Mandrake and other mainstream release, and fedora 4.0 removed this gadget up; pity; this is my operation in Slackware of;

If you do this, the more intuitive;

[root@localhost beinan]cfdisk  磁盘设备名  

For example:
[root@localhost beinan]cfdisk  /dev/hda 

You can see the pattern is as follows:

                                        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 entered the cfdisk user interface; the keyboard to move the cursor to the [Quit] you can exit;


Four, parted function good partitioning tool; there are bands in Fedora 4.0, the upper can install yourself; in this topic, we just say how to view partitioning disks;

call the method is simple, parted is on by default device is / dev / hda, you can also specify their own; such parted / dev / hda or / dev / sda etc; exit method is to quit

[root@localhost beinan]# parted

使用 /dev/hda
(parted) p
/dev/hda 的磁盘几何结构:0.000-76319.085 兆字节
磁盘标签类型:msdos
Minor    起始点        终止点  类型      文件系统    标志
1          0.031   6000.842  主分区 ntfs        启动
2       6000.842  22003.088  主分区 fat32       lba
3      22003.088  60800.690  扩展分区
5      22003.119  30004.211  逻辑分区 reiserfs
6      30004.242  40005.615  逻辑分区 reiserfs
7      40005.646  40774.350  逻辑分区 linux-swap
8      40774.381  52219.094  逻辑分区 ext3
9      52219.125  60800.690  逻辑分区 reiserfs

We operate in a surface partd, with p can list the current partition the disk, if you want to see the other disk can be used to select functions, such as select / dev / sda;

five, qtparted, as well as related software parted qtparted, can view the structure of the disk and used by the file system, it is patterned;

[beinan @ localhost ~] # qtparted

Graphical view, at a glance;

qtpartedlinuxsir.org0001.jpg

Six, sfdisk is a partition tool, and feature a lot; we are here to say that only function partitioning of his columns disk;

[root@localhost beinan]# sfdisk -l 

See for yourself;

sfdisk has several useful functions; are interested brothers take a look;


Seven, partx also briefly talk about some system comes with this tool, function is simple, and fdisk, parted, cfdisk is not worth mentioning; not worth mentioning;

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)

Eight, to see all disks and partitions of the current situation in the 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


Nine, mac-fdisk This tool is mainly used in Powerpc version of Linux, we used X86 version does not have this tool; this just explain;

Reproduced in: https: //www.cnblogs.com/licheng/archive/2008/01/21/1047280.html

Guess you like

Origin blog.csdn.net/weixin_34032792/article/details/93800733