Linux_ Disk partition mount

Source: Internet
Author: User
Tags uuid

Disk Management:
DF: View disk partitions and usage
-H
-I.
-P


Device files:
B: Devices that are randomly accessed by block
Hard disk
C: by character, linear device
Keyboard

Ll/dev
Main device number: (Major numbers)
Identifying Device Types

Secondary device number: (minor No.)
Identify different devices in the same type

To create a device file:
Mknod [-M mode] Dev_name Dev_type [Major_num] [Minor_num]


Device file name for hard disk device: Use a,b,c under the same type ... To differentiate between different devices.
Ide,ata:/dev/hd*
First IDE port: Master, slave
HDA, HDB
Second IDE port: Master, slave
HDC, HDD

SATA:/dev/sd*
SCSI:/dev/sd*
USB:/dev/sd*

Sda:
SDA1: First primary partition
Sda2
Sda3
Sda4
SDA5: First logical partition

To manage disk partitions:
View the current system identifies several hard disk devices:
Fdisk-l

# FDIDK/DEV/SDA into disk SDA partition management
P: Displays partition information for the current hardware, including unsaved changes
N: Create a new partition
E: Expand the partition
P: Primary partition
D: Delete a partition
W: Save exit
Q: Do not save exit
T: Modify the partition type
L
L: Show all supported types

Create a file system (format) for the new partition you created:
Mkfs:make File System
File system type:
Cat/proc/filesystems: Used to view the file systems supported by the current kernel


Mkfs-t ext4/dev/sdb1 ==> MKFS.EXT4/DEV/SDB1


Specialized in managing EXT system files:
MKE2FS:
-j:ext3
-T Ext4:
-B block_size: Specifies the block size, default 4096, available values 1024,2048,4096
-L Label_name: Specifies the partition volume label
-M 5: Specifies the percentage of blocks reserved for super users to 5%
-I 4096: Specifies the corresponding data size for an inode, which is typically 2 times the block_size
-N num: Specify the number of Inode
-F: Forced formatting
-E: Used to specify additional file system Properties


Blkid: View related properties for disk devices:
Uuid
TYPE
LABEL ==> e2label/dev/sdb2-E2LABEL/DEV/SDB2 lable_name

[Email protected] ~]# BLKID/DEV/SDB2
/dev/sdb2:uuid= "2da90784-1a20-4316-a84a-527d97f44994" type= "Ext4"

To adjust file system related properties:
TUNE2FS:
-j: Upgrade ext2 to ext3 without compromising the original data
-L Lable_name: used to set or modify volume labels
-M 3: Adjust the percentage reserved for super users to 3%
-R num: Specifies the number of blocks reserved
-O: Set default mount Options
Acl
-C num: Specifies that the mount count is reached after a certain number of times to self-test, 0 or 1 means to turn off this feature
-I num: self-test with a specified number of days after each mount, 0 or 1 means off
-L: Displays information in the Super block

DUMPE2FS:
Dumpe2fs/dev/sdb2
-H: Show only information in the Super block

Fsck: Checking and repairing the Linux file system
-T Fstype: Specifying the file system type
-A: Automatic repair
E2FSCK: Dedicated to repairing EX2/EXT3/EXT4
-F: Forced check
-P: Automatic repair


To associate a new file system to the current root file system (Mount):
Mount: Displays devices and mount points that are already mounted on the current system
-A: Indicates that all file systems defined in the/etc/fstab file are mounted
-N: Use this parameter to not write mount information to/etc/mtab; By default, the Mount command mounts each device and saves the mounted device information to/ETC/MTB
-T Fstype: Specifies the type of file system on the mounted device; The default mount calls Blkid to obtain the corresponding device file system type
-R: Read-only Mount
-W: Read-write Mount
-O: Specify additional mount options; Specify file system enabled properties
Remount: Re-mount the current file system
RO:-R
RW:-W
Loop: Hangs on a local loopback device, loopback, loopback device, hardware with software emulation

Mount Mount
Mount Device mount point
Equipment:
Device file:/DEV/SDB2
Volume Label: label= ""
Uuid:uuid= ""
mount point: Directory
Requirements:
1. This directory is not used by other processes
2. Directory must exist
3. The original file in the directory will be temporarily hidden

When the mount is complete, access the files on the corresponding device via the mount point

Umount Uninstall:
Umount Equipment | Umount mount point
Attention:
1. The mounted device is currently not in process use

Fuser: Verifying the file or socket file that the process is using
# fuser-v/mydir/--View the processes that are being allowed on the file
# fuser-km/mydir/---terminate all processes that are accessing/mydir hanging at the point

Swap partition
Free-m: View memory and swap size and usage

To create a swap partition:
Dividing a swap partition when there is still unformatted space on the disk
Fdisk to create a partition
T: modified to swap partition type 82

MKSWAP/DEV/SDB5 and Format swap


SWAPON/DEV/SDB5---Mount Swap
-A: Mount the device in the/etc/fstab file
SWAPOFF/DEV/SDB5--Offload Swap

When the disk does not have unformatted space, you can use DD to create a file for swap

DD Command:
if= Data sources
of= Data storage target
Bs=1-->byte
count=2--Specify the number of BS
seek=1023-the size of skipped space when creating a data file

DD IF=/DEV/SDA of=/mnt/usb/mbr.backup bs=512 count=1--Backup disk MBR
DD if=/mnt/usb/mbr.backup OF=/DEV/SDA bs=512 count=1--restores the backed up MBR to disk

# dd If=/dev/zero of=/var/swapfile bs=1m count=1024--Create a file to create a swap partition
#-Mkswap/var/swapfile format this file as swap
# swapon/var/swapfile--Load Swap


/etc/fstab content:
When the OS is initialized, each file system defined in this file is automatically hung

/etc/fstab format
$ $4 $ $6

$: Device (device name, Label,uuid)
$: Hanging at a point (directory)
$ $: File system type
$4: Hang on options, default defaults
$ $: Dump frequency, make a full backup every few days
$6: File system detection Order, only/1, other file system can be used all 2

Linux_ Disk partition mount

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.