Linux Disk Management (ii)

Source: Internet
Author: User

The previous article describes the disk structure and partition structure, an article that describes managing partitions and managing file systems

Manage partition 1. Creating a partition (1) Fdisk: Creating an MBR partition
fdisk-l [-u] [device ...]      /dev/sdb   admin partition             subcommand:                  p partition list                  t change partition type                  n Create new partition                  D Delete partition                  v check partition                  u conversion Unit                    W  Save and exit                  Q do not save and rewind

FDISK is interactive when creating a partition, so writing a script requires

  Echo " n\np\n1\n\n+1g\nw\n " | Fdisk/dev/sdb

To enable non-interactive creation of partitions

(2) Gdisk: Creating a GPT partition

Gdisk Creating a partition is similar to FDISK

(3) Parted: Advanced partitioning operation

The parted operation is in real time and no w save operation is used, so be careful with

Parted usage

parted [OPTION] ... [DEVICE [COMMAND [PARAMETERS] ...] ...]
Parted/dev/sdb Mklabel gpt| msdos     creating GPT or MBR disks       /dev/sdb                 Print printing sdb information    1   /dev/SDB rm 1                  Delete partition 1parted–l                             list partition information

You can also use interactive

2. Notify the kernel to identify the new partition

CentOS 5,7: Using Partprobe

CentOS 6 using Partx

    • Added partition by: Partx-a/dev/device
    • Delete Partition by: partx-d--NR m-n/dev/device

To see if the kernel has identified a new partition: Cat/proc/partations

List partitions: lsblk

Manage file System 1. File system Overview (1) Introduction to file Systems
    • A file system is the method and data structure used by the operating system to explicitly store files on a device or partition; The method of organizing files on a storage device. The software structure that manages and stores the file information in the operating system is called the file management system, referred to as file system
    • From a system perspective, a file system is a system that organizes and distributes the space of a file storage device, which is responsible for storing files and protecting and retrieving the files deposited. Specifically, it is responsible for creating files for users, depositing, reading, modifying, dumping files, controlling file access, security control, logging, compression, encryption, etc.

View system-supported file systems

ls /lib/modules/'uname -R '/kernel/fsbinfmt_misc.ko.xz  cifs    ext4     gfs2   Mbcache.ko.xz  nls        udfbtrfs              cramfs  fat      isofs  NFS            OVERLAYFS  xfscachefiles         DLM     fscache  jbd2   nfs_common     pstoreceph               exofs   fuse     lockd  NFSD           SQUASHFS
(2) File system type
    • Linux file systems: Ext2,ext3,ext4,xfs,btrfs (Oracle), ReiserFS, JFS (AIX), swap, etc.
    • Disc: iso9660
    • Windows:fat32, Exfat,ntfs
    • Unix:ffs (FAST), UFS (Unix), JFS2
    • Network File system: NFS, CIFS
    • Clustered file system: GFS2, OCFS2 (Oracle)
    • Distributed File systems: Fastdfs,ceph, Moosefs, MogileFS, Glusterfs, Lustre
    • RAW: Unprocessed or unformatted file system

Depending on whether it supports the "journal" feature:

    • journaled file system: ext3, Ext4, XFS, ...
    • Non-journaled file system: ext2, VFAT
2. Create file System (1) MKFS command
Mkfs. fs_type/dev/-tfs_type/dev/          DEVICE'LABEL': Setting the          volume label -F : Forced rebuild If the device has been split into another format file system

" MyData " /dev/sdb1
(2) Mke2fs:ext series file system dedicated management tools
-t {ext2|ext3| EXT4} -B {1024  | 2048  | 4096   "block fast size -l "  label   "volume label -j: equivalent to-t ext3 mkfs.ext3  = mkfs-t E XT3 = Mke2fs-j = mke2fs-t ext3 -i #: Create an inode for each number of bytes in the data space, which should not be less than the size of the block -n #: Specify how many inode to create in a partition -I The amount of disk space occupied by an Inode record, 128 ---4096 -M #: Default 5%< Span style= "COLOR: #000000", the percentage of total space reserved for administrative staff -o feature[,...] : Enable specified attribute -o ^feature: Close specified attribute 
2048 8192 10000 3 /DEV/SDC1
3. Adjusting file system parameters (1) TUNE2FS: Reset the value of the EXT series file system adjustable parameters
-L: View specified file system super block information; Superblock'LABEL': Modify Volume label -m #: percent of space to fix reserved for administrators -J: Upgrade ext2 to ext3-o: File System Properties enabled or disabled, such as –o ^has_journal-o: Adjust default mount options for file system, such as –o ^ACL-u UUID : Change the UUID number
(2) E2label: Manage the label of the EXT series file system
e2label/dev/sd#                'LABEL' renaming a     volume label
4. Information view (1) Blkid: Block Device properties Information view
blkid [OPTION] ... [DEVICE]        -U UUID: Finds the corresponding device       according to the specified UUID -l Label: finds the corresponding device according to the specified LABEL
(2) Findfs: Finding partitions
Findfs [Options] label=<label>findfs [options] UUID=<uuid>
(3) DUMPE2FSView file system Information, Superblock information and block group information

-H: View Super block, do not show block group but only show Superblock and tune2fs-l consistent

5. File system detection and Repair

After the crash or abnormal shutdown, mount the file system with a chance to mark as "no clean"

Note: Be sure not to fix it in a mounted state

(1) fsck

-t Fs_type DEVICE      -p: Auto Fix error      -r: Interactive fix error
(2) E2fsck:ext series file-specific detection and repair tool
E2fsck DEVICE
-y: Auto Answer yes- f: Force fix

Linux Disk Management (ii)

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.