Hard disk partitioning and mounting

Source: Internet
Author: User

First, partition creation:

To view disk partitions:

#fdisk-l [DEVICE] ...

Do not specify device files, default to all hard disk devices;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/F1/wKioL1WMycHgVyGPAAFCp65SHsI702.jpg "title=" 1.jpg " alt= "Wkiol1wmychgvygpaafcp65shsi702.jpg"/>


To create a partition:

#fdisk [DEVICE]

Interactive interface, with many subcommands:

-CU: The sector is the display unit, the default is the cylinder surface;

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/F5/wKiom1WMyFew4SFGAAH5oiDb2Ok595.jpg "title=" 2.jpg " alt= "Wkiom1wmyfew4sfgaah5oidb2ok595.jpg"/>

Disk Management Example:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/F5/wKiom1WMyGuhP7gCAAMGSkNBeVw327.jpg "title=" 3.jpg " alt= "Wkiom1wmyguhp7gcaamgsknbevw327.jpg"/>

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/F1/wKioL1WMyjfDfXvDAAPXS3AXsAE485.jpg "title=" 4.jpg " alt= "Wkiol1wmyjfdfxvdaapxs3axsae485.jpg"/>


For disks that already have partitions in use, you need to have the kernel reread its partitioned table after you create a new partition:

CentOS 5:

#partprobe [DEVICE]

CentOS 6:

#partx-A [device] #kpartx-AF [device]

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/F5/wKiom1WMyN6i7HF6AABvMOvLiSc354.jpg "title=" 5.jpg " alt= "Wkiom1wmyn6i7hf6aabvmovlisc354.jpg"/>


Second, create the file system:

1 , MKFS ( Make file System ):

#mkfs-T Fstype[device]

-T Fstype: Specifying the file system type

#mkfs-T fstype = #mkfs. Fstype, namely Mkfs-t ext4= MKFS.EXT4;

Note: Centos

The Linux kernel is modular, which supports dynamic loading and unloading , and file systems can be packaged directly into the kernel or compiled into kernel modules;


If you expect a partition to be formatted as a particular file system, you typically need a command-line tool that corresponds to it in the user space to implement:

#yum-y Install Xfsprogs


Add: Windows not recognized Linux the file system

U -Disk File system FAT32

#mkfs-T VFAT


2 , MKE2FS :

#mke2fs

-T{EXT2|EXT3|EXT4}: Specify File system

-b{1024|2048|4096}: Specify block size

-L LABEL: marking

-j: equivalent to-t ext3

-I #: each number of bytes to create an inode, this number of bytes should not be less small block size

-N #: Specify the number of available inode directly ;

-M #: Specifies the percentage of space reserved for the entire partition; default is 5;

-O: Specify partition Attributes


Example:/dev/sdb1 creates a ext4 file system with a block size of 1024kand marked as chencer;

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/6E/F1/wKioL1WMy8fhHTGIAAHbgGvOwcY133.jpg "title=" 5.5. JPG "alt=" wkiol1wmy8fhhtgiaahbggvowcy133.jpg "/>


3 , modify partition properties:

#tune2fs

-j:ext2-->ext3

-L LABEL: Modify the volume label;

-M #: Modify the percentage of reserved space;

-o[^]feature: Enable the specified attribute, plus ^ for the feature toturn off this feature;

-o[^]mount-options: Turns the specified mount option on or off;

Note: block size cannot be adjusted;


4 , view information:

to view information for a specified block device:

#blkid DEVICE

To view or set a volume label:

E2labeldevice [LABEL]


5 , repair file system:

the file system should be repaired when the import write operation abnormally aborts due to an unexpected process abort or a system crash;

Note: Offline repair,umount;

#fsck

-T fstype;

-A: auto fix error;

-r: interactive fix error;

#e2fsck

dedicated to modify the Ext series file system;

-Y: answer the question automatically Yes;

-F: mandatory detection;


Third, file system mount:

By default, only the administrator has permission, the additional partition and the root file system on a directory to establish an association relationship process, the directory of the original file will be hidden;

1.Mount:

#mount [option] ... [-T Fstype] [-o option] DEVICE Mount_point

mount point : access entry for another file system

1, pre-existing;

2, the use of free directory;

fixed mount point:/mnt,/media

Common Mount options:

-tfstype: Specifying the file system type

-r:readonly, read-only Mount

-w:read and Write, read- write Mount

-llabel: Specify the device as a label, mount-l MYDATA mount point

-uuuid: Specify device as UUID, Mount Uuid= ' uuid ' mount point , mount-u uuid mount point

-A: automatically mounts all supported auto-mount devices ( as defined in the/etc/fstab file )

-N: The/etc/mtab file is not updated when mounted

-ooption:

Async: Asynchronous I/O, Data writes are completed before memory, and then synchronized to a persistent device based on a policy

Sync: Synchronous I/O,

Atime/noatime: updates the last access timestamp when files and directories are accessed

Auto/noauto: Whether the device supports Mount -a option to mount automatically

Diratime/nodiratime: The last access timestamp is updated when the directory is accessed

Dev/nodev: whether to support the use of devices on this device;

Exec/noexec: Whether binary program files on this device are allowed to execute

Suid/nosuid: whether to support the use of suid on files on this device

Remount: Re -mount, typically used to reassign mount options without unloading

RO: read-only

RW: Read and write

User/nouser: whether to allow normal mount of this file device

ACL: This device is supported by using Facl, which is not supported by default;

2. View all devices that have been mounted:

#mount #cat/proc/mounts#cat/etc/mtab

3. Uninstall:

The mount point can be unloaded without being accessed by the process;

#umount Device#umount Mount_point


See which processes are accessing the mounted device:

#fuser-V Mount_point


to abort a process that is in this mount point:

#fuser-km Mount_point


Iv. Swap partitions:

Swap: to alleviate the lack of physical memory resources;

To view usage information for memory and swap partitions:

#free


Example of creating a swap partition:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/6E/F5/wKiom1WMzSqDpsY9AAIzGv5WlI4043.jpg "title=" 6.jpg " alt= "Wkiom1wmzsqdpsy9aaizgv5wli4043.jpg"/>


Mkswap [-l LABEL] DEVICE

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/6E/F5/wKiom1WMzZKhn_Z8AAFWmD9zqBI880.jpg "title=" 7.jpg " alt= "Wkiom1wmzzkhn_z8aafwmd9zqbi880.jpg"/>


To enable a swap partition device:

Swapon[device]

-a:all, enable all swap partitions;

-p#: Specifies the priority of this switching device;


To disable a swap partition device:

Swapoff[device]

-A: disable all;


Five, automatic mount device configuration file:

#/etc/fstab

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/6E/F5/wKiom1WMzjWTKYgKAAHAn1e4kZ0444.jpg "title=" 8.jpg " alt= "Wkiom1wmzjwtkygkaahan1e4kz0444.jpg"/>

per line 6 fields:

1. Mounted Equipment:

Device Files

LABEL

Uuid

2, mount point:

3. File system Type

4. Mount option:

mount options can have multiple, separated from each other using commas;

5. Dump Frequency:

0: never Dump

1: Daily dumps

2: every other day

6. Self-Test order:

0: No self-test, additional file system created without automatic self-test

1: First self-test, usually only the root file system needs to self-test first

2: Secondary self-test, different devices can use the same self-test order

3

...

This article is from the "Pony Learning Record" blog, make sure to keep this source http://masachencer.blog.51cto.com/8683770/1665870

Hard disk partitioning and mounting

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.