Linux File System Management

Source: Internet
Author: User
Tags parent directory uuid disk usage hex code

Partitioning Type:  

MBR: Supports up to 4 primary partitions with a maximum of 2T hard drives

GPT: Max support capacity 18EB (EB=1024PB,PB=1024TB), single partition up to 1EB capacity, theoretically support unlimited disk partitions

file System:

EXT4:EXT4 is backwards compatible with ext3 and ext2, with subdirectories up to 64000, and higher with the "Dir_nlink" feature (although the parent directory's link count stops increasing). To prevent performance from being affected by a large number of catalogs, Ext4 opens the Htree (a special B-tree) indexing feature by default. This feature has been implemented in Linux core 2.6.23 version

DF view mount points and disk usage

-a displays all file system Information

-H uses common units to display capacity, such as MB, GB, TB

-I display inode information

-t display file system type

du Statistics directory or File size

-a displays disk usage per file instead of directory

-h displays disk usage in common units

-S statistics total consumption instead of sub-directories and sub-files

du and the the difference between DF

DF is considered from the file system, not only to consider the space occupied by the file, but also to count the space occupied by the command or program

Du is file-oriented and calculates only the space occupied by a file or directory

Fsck File System repair (for ext file system)

-A automatically fix file system without displaying user prompts

-Y automatic repair, and-a consistent, but some file systems only support-y

Xfs_repair File system repair (for XFS file system) before repair, we recommend using Xfs_metadump Backup metadata

-N Check the file system for damage, the damage will list the actions to be performed

Fix Failure Method (caution):

-L empties the log, may lose some data, and then execute Xfs_repair

DUMPE2FS Display disk status (for Ext file system)

Xfs_info Display of disk status (for XFS file systems)

Mount Mount File System

–a automatically mounts according to the contents of the/etc/fstab/

-T joins the file system type to specify the type of mount that can be ext3, Ext4, iso9660 and other file systems

-O To specify additional options for mounting

Atime/noatime Update access time/Do not update access time. When accessing a partition file, whether to update the access time of the file, the default update
Async/syna Asynchronous/synchronous, default to asynchronous
Auto/noauto Auto/manual, mount–a when executing, automatically install/etc/fstab/file content mount, default to Auto
Defaults Define default values, equivalent to the seven options of Rw,suid,dev,exec,auto,nouser,async
Exec/noexec Execute/Not execute, set whether executable file is allowed in file system, default is exec allow
Remount To re-mount a file system that is already mounted, typically to specify that special permissions be modified
Rw/ro Read/write/read-only, file system mount, read and write permissions, default is W
Suid/nosuid with/without SUID permissions, set whether the file system has suid and Sgid permissions, default is
User/nouser Allow/Disallow normal user mount, set whether the file system allows ordinary users to mount, default is not allowed, only root can mount the partition
Usrquota Write on behalf of file system support user disk quotas, default does not support
Grpquota Write on behalf of File system support Group disk quotas, default does not support

Example: Mount-o remount,noexec/home does not allow executable files in the file system (do not select the root partition, my centos7/home do not know why can not hang, directly hang the root partition to try, after successful what command can not be executed)

To mount the CD-ROM step:

Mkdir/mnt/cdrom

Mount/dev/sr0/mnt/cdrom

Unmount disc: (Note: You cannot unmount the disc in the CDROM directory, otherwise you will be prompted for a busy target)

Umount/dev/sr0 or

Umount/mnt/cdrom

Mounting USB Drive Steps

FDISK–L Check the USB drive device name first

Mkdir/mnt/upan

[Email protected] ~]# mount-t Vfat/dev/sdb2/mnt/upan

Uninstalling the USB flash drive: (Note: You cannot uninstall the USB flash drive in the Upan directory, otherwise you will be prompted to busy)

Umount/dev/sdb2

Support for NTFS file system-ntfs_3g

NTFS_3G Installation: (Installation of the source package must be installed GCC)

Download the ntfs_3g and its dependent fuse-2.9.3

Install fuse-2.9.3 First

Tar xzvf fuse-2.9.3.tar.gz

CD fuse-2.9.3

./configure&&make&&make Install

Installing NTFS_3G

Tar xzvf ntfs-3g-1.328.tgz

CD ntfs-3g-1.328

./configure&&make&&make Install

MOUNT-T NTFS-3G/DEV/SDB4/MNT/NTFS mount NTFS hard disk

Fdisk-l list all available partition types

Fdisk/dev/sdb for hard disk partitioning

A To set a bootable tag
B Edit BSD Disk Labels
C Set DOS operating system compatible tags
D Delete a partition
L Shows the known file system type, 82 is the swap partition, and 83 is the Linux partition
M Show Help
N New Partition
O Create a blank DOS partition table
P Show Partition list
Q Do not save exit
S New Blank Sun Disk label
T Change the system ID of a partition
U Change the display recording unit
V Verify partition Table
W Save exit
X Additional features (experts only)

Partprobe the kernel to synchronize partition information

MKFS-T EXT4/DEV/SDB1 formatted as EXT4 partition

/etc/fstab file:

Uuid=fd370686-828c-49bf-ba6c-c000d0a47ecc/boot XFS Defaults 0 0

First field: Partition device file name or UUID (hard disk universal unique identification code)

Second field: Mount point

Third field: File system name

Fourth field: Mount parameters

Fifth field: Specify whether the partition is dump backup, 0 not backup, 1 daily backup, 2 unscheduled backup

Sixth field: Specifies whether the partition is detected by fsck, 0 is not detected, the other number represents the priority of the detection, and 1 priority is higher than 2

After you modify this file, you can detect errors based on mount-a.

When the boot prompt partition is not found, you can enter the root user password, and then perform Mount-o REMOUNT,RW/

Then edit/etc/fstab to correct the error and perform mount-a detection error

Free view memory and swap partition usage

Cached (cache): refers to the data read out in memory, when read again, directly from memory read, speed up the reading of the data

Buffer (buffered): refers to the writing of the data, the scattered write operations in memory, when reached a certain extent in the central write to the hard disk, reduce disk fragmentation and hard disk repeatedly seek, speed up the data writing process

To increase the swap partition:

[Email protected] ~]# Fdisk/dev/sdb

Command (enter M for help): N

Select (default p): E #先创建逻辑分区, creating an extended partition

Partition code (2-4, default 2): 2

Start sector (1050624-4194303, default = 1050624):

Last sector, + sector or +size{k,m,g} (1050624-4194303, default = 4194303): +1024m

Command (enter M for help): N

Select (default P): L #创建扩展分区

Start sector (1052672-3147775, default = 1052672):

Last sector, + sector or +size{k,m,g} (1052672-3147775, default = 3147775): +512m

Command (enter M for help): T #把分区文件系统更改为82 swap

Partition code (1,2,5, default 5): 5

Hex code (input L list all codes): 82

Command (enter M for help): W

The partition table has been altered!

Calling IOCTL () to re-read partition table.

Warning:re-reading the partition table failed with error 16: The device or resource is busy.

The kernel still uses the old table. The new table is being used at

The next reboot or after you run Partprobe (8) or KPARTX (8)

#分区表读取失败, execute the following command to reread the partition table

[Email protected] ~]# Partprobe

[Email protected] ~]# MKSWAP/DEV/SDB5 #格式化

[Email protected] ~]# SWAPON/DEV/SDB5 #加入swap分区

[Email protected] ~]# SWAPOFF/DEV/SDB5 #取消swap分区

[Email protected] ~]# Vim/etc/fstab #swap分区开机自动挂载

/DEV/SDB5 swap swap defaults 0 0

Linux File System Management

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.