For your convenience, I have summarized some commands for Linux disk partitioning. Linux disk partitioning is still quite common. Here I will share the summary results with you, I hope it will be useful to you.
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;
Example:
[Root @ localhostbeinan] # df-lh
Filesystem capacity in use available % mount point
/Dev/hda811G6.0G4.4G58 %/
/Dev/shm236M0236M0 %/dev/shm
/Dev/sda156G22G35G39 %/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 mandf.
Ii. fdsik
Fdisk is a powerful disk operation tool from util-linux software package. Here we only talk about how to view the partition table and structure of Linux disk. The parameter-l is passed through the-l parameter, obtain the partition information of all the hard disks on the machine;
[Root @ localhostbeinan] # fdisk-l
Disk/dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylindersof16065 * 512 = 8225280 bytes
DeviceBootStartEndBlocksIdSystem
/Dev/hda1*176561448317 HPFS/NTFS
/Dev/hda2766280516109300cw95fat32 (LBA)
/Dev/hda328067751397287455Extended
/Dev/hda5280638258193118 + 83 Linux
/Dev/hda6382651001024140683Linux
/Dev/hda751015198787153 + 82 Linuxswap/Solaris
/Dev/hda8519966571171938683Linux
/Dev/hda9665877518787523 + 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; from her own hda5, hda6, hda7, hda8, hda9;
We also noticed that there is no hda4. Why? 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;
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), and the disk size is 80 bytes gb80026361856byte ), in fact, the actual size is 78150.744 M). Through a series of calculations, we can see that this hard disk still has space to use; there is about 18 GB unpartitioned space;
Fdisk-l can list the number of all disks on the machine and all Linux disk partitions. For example:
[Root @ localhostbeinan] # fdisk-l
Disk/dev/hda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylindersof16065 * 512 = 8225280 bytes
DeviceBootStartEndBlocksIdSystem
/Dev/hda1*176561448317 HPFS/NTFS
/Dev/hda2766280516109300cw95fat32 (LBA)
/Dev/hda328067751397287455Extended
/Dev/hda5280638258193118 + 83 Linux
/Dev/hda6382651001024140683Linux
/Dev/hda751015198787153 + 82 Linuxswap/Solaris
/Dev/hda8519966571171938683Linux
/Dev/hda9665877518787523 + 83 Linux
Disk/dev/sda: 60.0 GB, 60011642880 bytes
64 heads, 32 sectors/track, 57231 cylinders
Units = cylindersof2048 * 512 = 1048576 bytes
DeviceBootStartEndBlocksIdSystem
/Dev/sda11572315860452883Linux
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 @ localhostbeinan] # fdisk-l/dev/sda
Disk/dev/sda: 60.0 GB, 60011642880 bytes
64 heads, 32 sectors/track, 57231 cylinders
Units = cylindersof2048 * 512 = 1048576 bytes
DeviceBootStartEndBlocksIdSystem
/Dev/sda11572315860452883Linux
- Fully explain the advantages of Linux Virtualization
- Linux wireless network technology: GPRS, GSM
- 8 practical and interesting Bash command prompt lines in Linux
- Exclusive Report: Will Oracle become the mainstream of Linux and virtualization?
- DIY Linux cluster machines in file cabinets