Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use fdisk Command Partition in Linux

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use the fdisk command partition in Linux, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Df-report the disk space usage of the file system

Overview

Df [OPTION]... [FILE]... POSIX option: [- kP]

GNU option (shortest way): [- ahHiklmPv] [- t fstype] [- x fstype] [--block-size=size] [--print-type] [--no-sync] [--sync] [--help] [--version] [- -]

Description

This man page document is the GNU version of df. The df command lists the amount of disk space available on the file system on which each file name you specify resides. If no file name is specified, all file systems currently in use are displayed. By default, the disk space is displayed in 1K or 512 bytes if the environment variable POSIXLY_CORRECT is set. If the parameter is a disk device name that contains the used file system, the df command shows the free space of the file system, not the file family that contains the device node (only the root file system). This version of df cannot show the available space of an unused file system because most systems must be clear about the structure of the file system when responding to such requests.

GNU parameter description

-a,-- all

List file systems that include BLOCK 0

-- block-size=SIZE use SIZE-byte blocks

Specify the size of the block

-hmm. humaWhat readable

Display the size in a common format (for example: 1K 234m 2G)

-Hmam Mushsi

Ditto, but 1k here equals 1000 bytes instead of 1024 bytes

-I-- inodes

Use information index points instead of blocks to indicate usage

-k,-- kilobytes

Specifies that the block size equals 1024 bytes to show usage

-l,-- local

Show only local file system usage

-m,-- megabytes

Displays usage with a specified block size equal to 1048576 bytes (1m)

-- no-sync

Disable calling synchronization (default) before obtaining usage information

-P,-- portability

Export using POSIX format

-- sync

Call synchronization before getting usage information

-t,-- type=TYPE

Show only file systems of the specified type (TYPE)

-T,-- print-type

Output the type of each file system

-x,-- exclude-type=TYPE

Only file systems other than the specified type (TYPE) are displayed.

-v (ignore)

-- help

Output help information for the command and exit

-- version

Output version information and exit

Example:

The code is as follows:

[root@localhost ~] # df # lists the disk space usage of each file system

[root@localhost ~] # df-ia # lists the I node usage of each file system

[root@localhost ~] # df-T # lists the types of file systems

[root@localhost ~] # df-h # current disk space and usage are displayed in a more readable way

[root@localhost ~] # df-k # shows disk usage in units

Fdisk disk Partition Command

-v

Print the version information of fdisk and exit.

-l

Lists the partition table information for the specified device and exits. If no device is given, then use those mentioned in / proc/partitions (if any).

-u

Displays the information of each partition in the partition table in the form of the number of sectors rather than the number of cylinders.-s partitions output partition size (in blocks) information to standard output

For example a, view all partitions

The code is as follows:

[root@localhost ~] # fdisk-l

Disk / dev/sda: 500.1 GB, 500107862016 bytes

255 heads, 63 sectors/track, 60801 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/ dev/sda1 * 1 17 136552 83 Linux

/ dev/sda2 18 279 2104515 82 Linux swap / Solaris

/ dev/sda3 280 60801 486142965 5 Extended

/ dev/sda5 60801 486142964 + 83 Linux

Example bforce fdisk partition

The code is as follows:

[root@localhost ~] # fdisk / dev/hdc # partition, do not add numbers

The number of cylinders for this disk is set to 5005.

There is nothing wrong with that, but this is larger than 1024

And could in certain setups cause problems with:

1) software that runs at boot time (e.g.old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): M # can view help

Command action

A toggle a bootable flag

B edit bsd disklabel

C toggle the dos compatibility flag

D delete a partition # Delete a partition

L list known partition types # list known partitions

M print this menu

N add a new partition # add Partition

O create a new empty DOS partition table

P print the partition table # displays the partition table

Q quit without saving changes # does not save exit partition

S create a new empty Sun disklabel

T change a partition's system id # change Partition ID

U change display/entry units

V verify the partition table

W write table to disk and exit # Save partition operation

X extra functionality (experts only)

Command (m for help): P

Disk / dev/hdc: 41.1 GB, 41174138880 bytes # disk name and size

255heads, 63 sectors/track, 5005 cylinders # number of heads, regions and columns, how much

Units = cylinders of 16065 * 512 = 8225280 bytes # size of each pillar

Device Boot Start End Blocks Id System

/ dev/hdc1 * 1 13 104391 83 Linux

/ dev/hdc2 14 1288 10241437 + 83 Linux

/ dev/hdc3 1289 1925 5116702 + 83 Linux

/ dev/hdc4 1926 5005 24740100 5 Extended

/ dev/hdc5 1926 2052 1020096 82 Linux swap / Solaris

Command (m for help): Q # Q does not save exit, w do not enter casually

For example, c\ {# # * * $$} c <...

The code is as follows:

[root@server7 ~] # fdisk-cl / dev/vdb

Disk / dev/vdb: 8589 MB, 8589934592 bytes

16 heads, 63 sectors/track, 16644 cylinders

Units = cylinders of 1008 * 512 = 516096 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xce720981

Device Boot Start End Blocks Id System

/ dev/vdb1 3 206 102400 83 Linux

/ dev/vdb2 206 409 102400 83 Linux

/ dev/vdb3 409 612 102400 83 Linux

[root@server7 ~] # fdisk-ul / dev/vdb

Disk / dev/vdb: 8589 MB, 8589934592 bytes

16 heads, 63 sectors/track, 16644 cylinders, total 16777216 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0xce720981

Device Boot Start End Blocks Id System

/ dev/vdb1 2048 206847 102400 83 Linux

Partition 1 does not end on cylinder boundary.

/ dev/vdb2 206848 411647 102400 83 Linux

Partition 2 does not end on cylinder boundary.

/ dev/vdb3 411648 616447 102400 83 Linux

Partition 3 does not end on cylinder boundary.

The above is how to use the fdisk command to partition in Linux. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report