Linux Learning notes a Disk Management common command

Source: Internet
Author: User
Tags ide hard drive

Linux Learning notes a Disk Management common command

Linux system, everything is a file, disk is a special block device files.

Common hard-disk interface types

    • The same port: IDE, SCSI

    • Serial Port: Sata,sas

command rules for disk device file device files :

IDE: Device name/dev/hda,/dev/hdb .... (at the end of A, b ... Represents a different IDE hard drive)

SCSI: The device is named/dev/sda,/dev/sdb .... (At the end of A, A, b ...). Represents a SCSI hard disk that is not used

Mechanical HDD:

Track: Tracks (on the disc are divided into different tracks by outward-facing)

Cylinder: Cylinder (the same track on different discs makes up a cylindrical surface)

Sector: sector (sector size is 512bytes)

HDD 0 Track 0 sector: 512bytes storage MBR and partition table

mbr:master Boot Record
446bytes:boot loader
64bytes: Used to store hard disk partition table, each record a partition, need to occupy 16bytes.
2bytes: Play the role of marking
because the hard disk has only 64byte bytes to access the partition table, and each partition requires 16bytes, a hard disk can have up to 4 primary partitions. To break the limit of 4 partitions, the hard disk can be divided into 3 primary partition +1 extension (n logical partition)
Linux file System Management

Linux File system: EXT2,EXT3,EXT4,XFS,SWAP,BTRFS,REISERFS,JFS

Swap: Swap partition

Depending on whether the "journal" feature is supported, it can be divided into:

journaled File system: ext3, Ext4, EXF
Non-journaled file system: EXT2,VFA

The command to create the file system: MKFS, which uses the following format:

  1. Mkfs. Fs_type/dev/devic, Fs_type can be ext4,xfs,btrfs,vfat.

  2. Mkfs-t Fs_type/dev/device, Fs_type can be ext4,xfs,btrfs,vfat


Mke2fs:ext Series file system dedicated management tool-t {EXT2|EXT3|EXT4} file system

Size of the-B {1024|2048|4096} block

-L ' LABEL ' volume label

-j equivalent to-t ext3

-I #: Create an inode for every number of bytes in the data space, this size should not be smaller than the size of the block, or there will be a waste of inode

-M #: The percentage of space reserved for the administrator, #表示百分比, the system retains 5% space by default


Bllid command to view block device information

[Email protected] ~]# blkid/dev/sda1

/dev/sda1:uuid= "D4443e1c-7ecc-4393-9193-94beffba73e7" type= "XFS"

In addition:
Blkid-u UUID: Find the corresponding device based on the specified UUID
Blkid-l LABEL: Find the corresponding device according to the specified volume label

E2labe: Managing the volume label of the EXT series file system

The command uses the format: $e 2label DEVICE [LABEL]

[[email protected] ~]# E2LABEL/DEV/SDA5 #查看/dev/sda5 's label

Mydata

[[email protected] ~]# e2label/dev/sda5 Testdata #修改/dev/sda5 volume labeled Testdata

[Email protected] ~]# E2label/dev/sda5 #查看修改后的结果

Testdata


TUNE2FS: Re-adjust the values of the adjustable parameters of the EXT series file system

Options:

-L: View the file system's Super block information

-L "LABEL" to modify the volume label

-M #: Percentage of space reserved for executives

-j: Turn on the log feature to upgrade ext2 to Ext3

-O: File System Properties enabled or disabled

-O: Adjust default mount options for the file system

-U uuid: Modifying the UUID number


DUMPE2FS:

-H: View Super block information

Mkswap: Create a swap partition if this partition ID is a (Linux swap partition)

Mkswap [Options] Device

-L ' LABEL '

[[email protected] ~]# mkswap-l "swap"/dev/sda6

Setting up Swapspace version 1, size = 10490408 KiB

Label=swap, uuid=62f6b158-6012-4340-919f-137ca21b360b

[Email protected] ~]# Blkid/dev/sda6

/dev/sda6:label= "swap" uuid= "62f6b158-6012-4340-919f-137ca21b360b" type= "swap"


File System Detection:

fsck:file System Check
fsck. Fs_type=fsck-t Fs_type # Fs_type must be the same type as the file system to be detected-a
: Auto Fix error

-R: Interactive repair, before repair, requires user confirmation


E2FSCK: Fix Ext series file Special tool


File System Management

An association is established between an additional file system and an existing empty directory under the root file system, so that the directory acts as an access entry for other file systems, which is called mounting

The process of releasing this association is called unloading


Mount method: Mount DEVICE Mount_point

Mount does not take any parameters to display all devices mounted on the current system (the read file is/etc/mtab)

The Mount command is used in the following format:

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

Device: Indicates which devices to mount

1. device files, such as/dev/sda5

2. Volume Label:-L ' LABEL ' For example-l ' MYDATA '

3.UUID,-u ' UUID ': Format:-U "d4443e1c-7ecc-4393-9193-94beffba73e7" type= "XFS"

4. Pseudo file system name: Proc, SYSFS, Devtmpfs, configs

dir: mount point
mount points must exist beforehand, it is recommended to use an empty directory, if the file system is mounted to a non-empty, the original files in the directory will no longer be displayed.
Common options:
-T Vfstype: Specifies the type of file system on the device you want to mount
-r:readyonly, read-only Mount
-w:read & Write, read-write Mount
-A: Automatically mounts all devices that support automatic mounts (defined in/etc/fstab with automatic mount in Mount option)
-
N: Do not update/etc/fstab
-
L "LABEL": Mount device with volume label name
-
U "UUID": Mount device with UUID
-
b,--bind: Bind directory to another directory

Exercise: Create a 10G on SDB with a block size of 2048, the volume labeled MYDATA,EXT4 Primary partition, and read-only mount to/mydata.

First step: Create a partition and format
[email protected] ~]# Fdisk/dev/sdb
You are
Welcome to use FDISK (Util-linux 2.23.2).
The
changes will remain in memory until you decide to write the changes to disk.
Think
twice before you use the Write command.
command (enter M for help): N # New to create a fresh partition
Partition Type:
p Primary (0 primary, 0 extended, 4 free)
e Extended
Select (default p): P #选择类型为主分区
Partition code (1-4, default 1): 1
Starting sector (2048-125829119, default = 2048):
The default value 2048 will be used
Last
sector, + sector or +size{k,m,g} (2048-125829119, default = 125829119): +10g #指定大小为10G
partition 1 has been set to Linux type, size set to ten GiB

command (enter M for help): P # Print partition information

disk/dev/sdb:64.4 GB, 64424509440 bytes, 125,829,120 sectors
Units = Sector of 1 * bytes
sector size (logical/Physical): 512 Bytes/512 bytes
I/O size (min/best): 512 Bytes/512 bytes
disk label type: DOS
disk identifier: 0xb3c3c1de

device Boot Start End Blocks Id System
/dev/sdb1 2048 20973567 10485760
-up Linux

command (enter M for help): W # Confirm, save
The
partition table has been altered!

calling IOCTL () to re-read partition table.
The
disk is being synchronized.
Step two: Create a directory and mount
[[email protected] ~]# mkdir/mydata   #创建挂载点

[[email protected] ~]# mount-r/dev/sdb1  /mydata/  #挂载文件系统
[[email&nbs P;protected] ~]# ls/mydata/
lost+found
[[email  Protected] ~]# Touch f1/mydata/ 
touch: Setting Time for "/mydata/": Read-only file system

On uninstall: The device can be used or the mount point can be used to unload

Uninstall command:

#umount DEVICE

Mount swap partition:

Enabled: Swapon

Swapon [OPTION] ... [DEVICE]

-A: Activate all swap partitions

-p:priority Assigning a priority level

Linux Learning notes a Disk Management common command

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.