Linux Disk Management

Source: Internet
Author: User
Tags uuid

1, DUMPE2FS (used to view the Super block information)

DUMPE2FS [option] Device name

-H: List only the Super block information

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7E/9A/wKiom1cFCcfzd3KuAAHiW4CR97U436.jpg "title=" 9.JPG " Width= "599" height= "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:599px;height:150px; "alt=" Wkiom1cfccfzd3kuaahiw4cr97u436.jpg "/>

2, DF (used to show the overall amount of disk space usage)

DF [option] [FILE] ...

-A: List all file systems

-K: Listed in kilobytes

-M: listed in megabytes

-H: Listed in the appropriate units

-T: Listed with the system name of the partition

-I: Do not use the hard disk capacity, but the number of inode to display

-T: Displays the usage of a file system type: # DF-T EXT4

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/7E/97/wKioL1cFDn3RbLETAADsrEhNLaE367.jpg "title=" 10.JPG "alt=" Wkiol1cfdn3rbletaadsrehnlae367.jpg "/>

1k-blocks: Note The following is the K unit


3, Du (used to display the size of the directory or file)

Du [OPTION] ... [FILE] ...

-A: Lists all files and directories, by default only the amount of files in the directory (not the files included in the directory)

-H: Display in appropriate units

-S: Lists only the total, not the capacity occupied by the individual directories

-S: Do not include totals under sub-directories

-K: in kilobytes

-M: 650 in MB) this.width=650; "Src=" http://s2.51cto.com/wyfs02/M01/7E/9B/wKiom1cFFwbBymcIAACMa8c-OCQ318.jpg " Title= "11.JPG" alt= "Wkiom1cffwbbymciaacma8c-ocq318.jpg"/>

4. FDISK (for disk partitioning)

fdisk-l [device name]: Lists the contents of the partition behind the device and, if not, outputs all the contents of the partition

FDISK device Name

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M01/7E/9B/wKiom1cFGgbQf8lYAADTdOIJtAw636.jpg "title=" 12.JPG "Width=" 650 "height=" 238 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:650px;height:238px; "alt=" Wkiom1cfggbqf8lyaadtdoijtaw636.jpg "/>


The/DEV/SDA disk has a total of 107.4G, has 255 cylinders, each track contains 63 sectors, a total of 13,054 cylinders

Sector size (logical/physical) is 512bytes, each cylinder has 16,065 sectors, each sector has 512bytes, each cylinder has 8225280bytes


FDISK [device] Internal command:

P: Show partition Table

N: New Partition

D: Delete partition

L: List partition ID

M: Get Help

Q: Exit does not save

W: Exit and save

T: adjust the partition ID

Example: Creating a Partition

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/7E/9B/wKiom1cFHiCiePM6AAEd7Pg6MPs203.jpg "title=" a.jpg " alt= "Wkiom1cfhiciepm6aaed7pg6mps203.jpg"/>device: Device file name boot: Boot area start: from which cylinder end: which cylinder ends

Blocks: In K, Id/system: What should be the file system in this partition


Since the system can only build up to four primary partitions, the fourth is ready to build an extended partition for efficient use of space


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/7E/98/wKioL1cFIdeQ7LCZAAC2Luawl_M946.jpg "title=" 12.JPG "Width=" "height=" 282 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:750px;height:282px; "alt=" Wkiol1cfideq7lczaac2luawl_m946.jpg "/>

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7E/98/wKioL1cFIsiDanniAAB_O1G-VIs357.jpg "title=" 11.JPG After the "alt=" Wkiol1cfisidanniaab_o1g-vis357.jpg "/> extended partition is built, start building the logical partition:

650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/7E/98/wKioL1cFI1bCRoLSAABVdjNAlyc437.jpg "title=" Build a logical Partition "Width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:750px;height:88px; "alt=" Wkiol1cfi1bcrolsaabvdjnalyc437.jpg "/> Note: 10G units must be in uppercase

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/7E/9C/wKiom1cFIzngxid_AACLcxhTvTw507.jpg "title=" Built logical Partition "Width=" 730 "height=" 151 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:730px;height:151px;float:left "alt=" Wkiom1cfizngxid_aaclcxhtvtw507.jpg "/> After the partition to be saved, press W is good, after saving, you will be prompted to say that it must be restarted before it takes effect.

At this point, type the command: partx-a/dev/sda or kpartx-a DEVICE will be able to make the modified effect, we can see/proc/partitions See if it takes effect.

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M01/7E/98/wKioL1cFJtngK_WJAADXDJBjn3I345.jpg "title=" 11.JPG "Width=" "height=" 314 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:700px;height:314px; "alt=" Wkiol1cfjtngk_ Wjaadxdjbjn3i345.jpg "/>

You can see a new extended partition, a logical partition.

After the partition is built, we want to use this partition, we need to mount it to a directory to use this part of the space, and then need to format, write to the filesystem, the following will explain these commands.


5. Mount (for mounting disk devices)

Mount [-LHV]

mount-a [-FFNRSVW] [-t vfstype] [-O optlist]

Mount [-FNRSVW] [-o option[,option] ...] Device|dir

Mount [-FNRSVW] [-t vfstype] [-O options] Device dir

-r,--read-only: Set to read-only

-W,--RW: Set to read/write

-U: Mount with UUID

-A: Mount the/etc/fstab in accordance with the configuration file

-L: Lists the currently mounted information and lable, without adding the words, does not display lable

-T: Can add File system type, such as EXT4,EXT3, etc.

-N: Do not let the system write to the/etc/mtab file in real time

-L: Mount with label

-O: Can be followed by some additional parameters attached to the Mount

RO,RW: Mount file system becomes read-only or writable

Async,sync: Asynchronous write, synchronous write, default async

Auto,noauto: Allow this partition to be mount-a auto mount/not allowed

Dev,nodev: Whether to allow device files to be created on this partition

Suid,nosuid: Whether this partition is allowed to contain suid/sgid file format

Exec,noexec: Whether to allow executable binary files on this partition

User,nouser: Allows the user to execute mount on this partition, generally only root, after adding user, the general user can also

Defaults: Default value is Rw,suid,dev,exec,auto,nouser,async

Remount: Re-mount, useful when a system error occurs, or when a parameter is changed

Note: Mount points are best for empty directories

ACL: Enable ACLs on this file system (Access control list, 6 means default is not enabled, 7 means enabled by default)

Diratime/nodiratime: Directory Access timestamp/

Relative unload command:umount device/mount_point


6, MKFS (file system format)

-T: Specify File system

-L: Specify the volume label

Mkfs-t Fs_type DEVICE


7, MKE2FS (ditto, powerful, ext file system dedicated)

-T {ext2| ext3 | EXT4}

-B {1024 | 2048 | 4096} specify block size

-L lable: Specify volume label

-j: Equivalent to-t ext3, add log to ext2 function

-I #: Create an inode for every number of bytes in the data space (#不小于块大小, or there will be a waste of inode)

-N #: How many Inode is created for the data space

-M #: Percentage of space reserved for executives, default 5%

-O FEATURE [, ...] Enable specified attribute-o ^feature [, ...] close specified attribute

-C Device: Check for specified devices

-G #: Specifies the number of blocks in a block group

Next, we format the newly created partition above as a EXT4 partition and mount the

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7E/A0/wKiom1cFxWXzSJL3AAE4Yfl5tlA561.jpg "title=" 11.JPG "alt=" Wkiom1cfxwxzsjl3aae4yfl5tla561.jpg "/>

650) this.width=650; "src=" http://s4.51cto.com/wyfs02/M00/7E/9C/wKioL1cFxoWx9efkAABQuxLC5YM748.jpg "title=" 11.JPG "alt=" Wkiol1cfxowx9efkaabquxlc5ym748.jpg "/>

Display Lost+found instructions mounted successfully, already available


8, Swapon and Swapoff (Mount/unload swap partition)

swapon [option] [device]

-A: Activate all swap partitions

-P Priority: Specifies that precedence (0-32767) can be specified in/etc/fstab pri=value

-S: Displays the swap on the current system (the higher the number the higher the priority)

swapoff [option] [device]


View swap:]# cat/proc/swaps or free command


Demo: Add a 500M swap


650) this.width=650; "src=" http://s5.51cto.com/wyfs02/M00/7E/9F/wKiom1cFusKiub_gAABibSmFnbM566.jpg "title=" 11.JPG "alt=" Wkiom1cfuskiub_gaabibsmfnbm566.jpg "/>


650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/7E/9F/wKiom1cFvDPAdV2OAAB0aK4Bs3s300.jpg "title=" 11.JPG "Width=" "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "style=" width:750px;height:130px; "alt=" Wkiom1cfvdpadv2oaab0ak4bs3s300.jpg "/>

Modify the system Id,swap corresponds to 82, details with L view

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/7E/9C/wKioL1cFvUvQNcckAABWeP9mhBE327.jpg "title=" 11.JPG "alt=" Wkiol1cfvuvqncckaabwep9mhbe327.jpg "/>

Save and let the system read, that is the format of the swap partition, with the Mkswap command

650) this.width=650; "src=" http://s1.51cto.com/wyfs02/M00/7E/9F/wKiom1cFvXzSJl28AACgrOsSdVc451.jpg "title=" 11.JPG "Width=" "height=" 199 "border=" 0 "hspace=" 0 "vspace=" 0 "style=" WIDTH:750PX;HEIGHT:199PX; "alt=" Wkiom1cfvxzsjl28aacgrossdvc451.jpg "/>

You can see that the swap is already 500M out.


9. Some other commands for disk Management

Blkid: Block Device properties Information view

-U UUID view based on UUID

-L label view based on label

E2lable: Modify Device label

E2label DEVICE LABEL


TUNE2FS: Reset the value of the Ext file system adjustable parameter

-L: View the file system super fast Information

-L Label: Modify label

-M: Modify the percentage of space reserved for administrators

-j: Raise ext2 to Ext3

-O FEATURE: Enable feature

-O: Adjust default mount options for the file system

-U uuid: Modifying the UUID number


FSCK: Disk Inspection

Fsck-t file system [-acay] device name

-A: Scan the required devices according to the contents of the/etc/fstab file

-A: Auto fix checked to problematic sectors

-Y: Similar to-A, some file systems only support-y

-C: Displays a histogram showing the current progress during the inspection process

-F: Forced check

-r: Interactive fix error

Note: The partitions checked by fsck must not be mounted

E2fsck:ext Dedicated

-Y: Auto Fix

-F: Forced repair


10. Set up automatic mount on boot

Add in/etc/fstab

/dev/sda5/mnt/test EXT4 Defaults 0 0

/dev/sda6 swap swap defaults 0 0


First column: Device name, also can be label=...,uuid= ...

Second column: mount point, swap more special for swap

Third column: File system, CDROM for iso9660

Fourth column: Mount option, same as Mount-o option

Fifth column: Dump frequency (dump operation), 0 means do not make a backup, 1 represents daily dump,2 every other day, usually not 0, 1

The sixth column: whether to test the sector with FSCK, 0 not self-test, 1 first self-test, generally only rootfs is self-test, but more than 1 late, in addition to the root partition 1, the other generally 2



Reference: "Bird's Linux Private cuisine"







This article is from the "11095819" blog, please be sure to keep this source http://11105819.blog.51cto.com/11095819/1761223

Linux Disk Management

Related Article

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.