September 01 Course Assignments (exercise)-linux File System Management

Source: Internet
Author: User
Tags uuid

1, review the contents of this course;

Linux Disk Management
Hard disk: Hard disk is the common term, in fact, hard disk and disk are the same, are used to store things, as well as tapes, CDs, u disk and so on just storage media is not the same.
Mechanical hard-disk
SSD Solid State Drive

Mechanical type:
Track tracks
Per sector (sector): 512bytes
Magnetic column (CYLINDER): The basic unit of the partition;

Master boot record mbr:master boot record 512bytes
446:bootloader
64:filesystem Allocation table
16: Identify a partition
2:55aa

Primary boot Sector of disk = Disk Master boot record (MBR 446) + Disk partition table (DPT 64) + Terminator (55AA)

Bootload can be installed on disk master boot record (MBR) or partition boot record (PBR, also called DBR)
(1)Linux bootload can be installed on both (MBR,PBR)
(2) TheWindows self-installing MBR is used only as a jump to the specified partition, and Windows Bootloader is installed on the partition's PBR .

Disk interface type:
IDE (ATA): 133MB/S,/DEV/HD
scsi:640mb/s
sata:6gbps
sas:6gbps
usb:480mb/s

        Identify hard disk devices:/DEV/SD  
             mark different hard disk devices:/dev/sd[a-z]    
             mark different partitions on the same device:/dev/sd[a-z][1-]    
                 1-4: Primary or extended partition identification    
                 5+: Logical partition identifier

Device Files: Special files
Device number:
Major, minor
Major: Device type
Minor: Different devices under the same type

"Block": block, Random device
"Character": Character, linear device

Gpt

There are two types of device files: Block device file (b) and character device file (c)

The device files are generally stored in the/dev directory, and the common device files are described as follows:

/dev/hd[a-t]:ide Equipment

/DEV/SD[A-Z]:SCSI Equipment

/DEV/FD[0-7]: Standard floppy drive

/DEV/MD[0-31]: Soft RAID device

/DEV/LOOP[0-7]: Local loopback device

/DEV/RAM[0-15]: Memory

/dev/null: Unlimited data reception device, equivalent to black hole

/dev/zero: Unlimited 0 Resources

/DEV/TTY[0-63]: Virtual terminal

/DEV/TTYS[0-3]: Serial port

/DEV/LP[0-3]: the same port

/dev/console: Control Console

/dev/fb[0-31]:framebuffer

/dev/cdrom =/dev/hdc

/dev/modem =/dev/ttys[0-9]

/dev/pilot =/dev/ttys[0-9]

/dev/random: Random number devices

/dev/urandom: Random number devices

Partitioning: Separates the storage space into multiple small spaces, each of which can use the file system independently;

Partitioning tools:
Fdisk, parted, Sfdisk

Use of the Fdisk tool:
Support for up to 15 partitions on one hard drive;

Partition Management sub-command:
P: Display
N: Create
D: Delete
T: Modify the partition ID
L: List all support ID types
W: Save exit
Q: Discard Changes and exit
M: Get Help

After the creation is complete, check to see if the kernel has identified the new partition:
# cat/proc/partitions

There are three commands that allow the kernel to reread the disk partition table:
CentOS 5:partprobe [DEVICE]
CentOS 6, 7:
Partx
Kpartx

PARTX command:
Partx DEVICE
Partx-a DEVICE
Partx-a-N m:n DEVICE
M
M:
: N

KPARTX command:
KPARTX-AF DEVICE notifies the kernel to forcibly reread the partition table "The kernel is not directly recognized for an existing disk."

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m00/73/41/wkiom1x4rbgjannbaabqbnblsru484.jpg "height="/>

2, summarize the Disk Management and file system Management design of the use of various commands, and note certain examples;

1), view system partition status

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/73/41/wkiom1x4rbhyqjwpaadaktspj0c793.jpg "height=" 244 "/>

2) Get help with fdisk parameter information

Command: FDISK/DEV/SDA #进入fdisk操作环境

M #打印帮助 List

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m02/73/41/wkiom1x4rblyhtcaaab1vyqcgiy864.jpg "height="/>

3) New Partition

Press N #创建一个分区

Command (M for help): M
Command Action
A toggle a bootable flag
b Edit BSD Disklabel
C Toggle the DOS compatibility flag
D Delete a partition
L list known partition types
M Print this menu
n Add a new partition
o Create a new empty DOS partition table
P Print the partition table
Q Quit without saving changes
s create a new empty Sun Disklabel
t change a partition ' s system ID
U Change display/entry units
V Verify the partition table
W Write table to disk and exit
X Extra functionality (experts only)

Command (M for help): N
Command Action
E Extended
P primary partition (1-4)
P
Partition number (1-4): 3
First cylinder (7063-26108, default 7063):
Using Default Value 7063
Last cylinder, +cylinders or +size{k,m,g} (7063-26108, default 26108): +10g

Command (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)
Syncing disks.

Take effect after reboot.

Linux File System Management

File system:

Vfs:virtual File System

Linux:ext2,ext3,ext4,reiserfs,xfs,btrfs,swap
Disc: iso9600

Windows:fat32 (VFAT), NTFS

Unix:ffs,ufs,jfs,jfs2

Network File system: Nfs,cifs

Cluster file system: OCFS2,GFS2

Distributed File System: Ceph

Mosefs,mogilefs,hdfs,gfs,gluterfs

(1) Log-type file

Non-journaled file: ext2

journaled File System: Ext3,ext4,reserfs,xfs,btrfs,swap

The difference between a journaled file system [EXT3,EXT4] and a non-journaled file system [EXT2]:

Log write steps: 1. Prepare, when the system is writing to a file, the information that a file prepares to write is recorded in the log record block first

2. Actual write, start writing permissions and steps to the file; start updating meta data[Intermediate data] data

3. Finish, complete the data and metadata after the update, in the log record block to complete the record of the file

Non-log write steps: 1. Determine if the user has W and x permissions for the directory to which you want to add the file, and if so, add

2. Locate the unused inode number according to the inode bitmap and write the permissions/attributes of the new file

3. Locate the unused block number according to block bitmap and write the actual data to the block, and update the Inode's block to point to the data

4. Synchronize the inode with block data that was just written to update the Inode bitmap with the block bitmap, and update the contents of the Superblock

When the power outage and other factors caused the system to break, there will be inconsistent state of data, then the non-log file system needs to conduct consistency check, very time-consuming. and the log file system, just to check the log record block to know that the file is a problem, do not have to go to the whole file system to check.

(2) Swap: Swap partition

To create a file system:

Perform formatting on a partition (advanced formatting)

To use a file system, meet two conditions

Kernel: Support for this file system

User space: There are file System management tools

Create tool: MKFS (make file system)

-t {EXT2|EXT3|EXT4}: Indicates the type of file system to be created

Mkfs-t Ext4 = MKFS.EXT4 = Mke2fs-t Ext4

b {1024|2048|4096}: The upper limit is determined by page frame

-L LABEL: Specifies the volume label to use [label= ' Mylabelname ' when used]

-j: equivalent to using-TEXT3

mkfs.ext3= mkfs-t ext3 = mke2fs-j = Mke2fs-t ext3

-I #: Indicates the ratio of inode to byte [no%], i.e., each number of bytes to create an inode;

-N #: Direct indication of how many inode to create for this file system

-M #: Specifies the percentage of reserved space [only root can be used, not%]; default is 5;

-O [^]feature: Can be used to indicate the additional attributes this filesystem can have, see the man Manual

Example:-O Has_journa Enable logging properties

-O ^has_journa do not enable log properties

E2label: Adjusting the volume label

View: E2label/dev/device

Set Volume Label: E2label/dev/device label

TUNE2FS: View or modify some properties of the EXT series file system

View data information in a super block: such as UUID: globally unique identifier

Tune2fs-l/dev/device

Example Tune2fs-l/dev/sda5

To modify the properties of the specified file system:

-J:EXT2-Ext3

-L LABEL: Modify the volume label;

-M #: Adjust the percentage of reserved space;

-O [^]feature: Turn a feature on or off

-O [^]mount_options: Turn on or off a default mount option

-O ACL open ACL

-O ^acl close ACL

DUMPE2FS command: Show ext Series File system Property information

DUMPE2FS[-H]/dev/device

Example Dumpe2fs-h/dev/sda5

Blickid command: Can view file types

Detecting file Systems

Fsck.ext2, Fsck.ext3, FSCK.EXT4, Fsck.xfs ...

Fsck: File System check Command

-tfstype

Fsck-t Fstype = fsck. Fstype

Example fsck-t ext4 fix delete inconsistent files

-A: Automatically fix all errors [caution]

-r: Interactive fix error

Special tools for the EXT series file system:

E2fsck

-Y: Automatically reply to Yes for all questions;

-F: Force detection even if the file system is in clean state;

Windows does not recognize a dedicated file system on Linux, so when you have a storage device that requires cross-use between two systems, you should use a file system supported by Windows:

#mkfs-T Vfat/dev/device

Mount:

Note: 1. On Linux systems, all file systems must be accessed through a branch of the root filesystem;

2. A single file system should not be repeatedly mounted in a different mount point (directory)

3. A single directory should not repeatedly mount multiple file systems

4. As a mount point of the directory should theoretically be a blank directory, otherwise the original directory files will be hidden

Root file system: Root is the access portal for all file systems, the root associated to the partition, there are certain requirements: FHS

In addition to the root, all other file systems, if they want to be accessed, can only be implemented by "associating" to a directory on the root filesystem, which is called "Mount", that is, Mount; the opposite action, that is, unload, the command is Umount

Mount point: Mount_point, which is the directory used to access the portal as another file system;

Mount Command:

Mountdevice Mount_point

Mount point

1, pre-existing;

2, should use the other process unused directory;

3. The existing files under the mount point will be hidden;

Mount: Displays information about all file systems that are currently mounted on the system;

Mount[option] ... [-T Fstype] [-O OPTION] [DEVICE] Mount_point

Command options:

-R: Read-only Mount

-w:read and write, read-write Mount

-T Fstype: The type of file system on the mounted device, which can be omitted, at which point the mount will automatically use the Blkid command to determine;

-L LABEL: Specifies the device to be mounted as a volume label, so that at this time device must be saved;

-U UUID: Specifies the device to be mounted as a UUID, so devices must be saved at this time;

-A: Automatically mounts all devices that support automatic mounting (as defined in the/etc/fstab file);

-N: By default, changes to the device mount or not will be saved in one copy of the/etc/mtab; the-n option is used to change the file without updating it

At this point, if you want to view all the file systems that are mounted: cat/proc/mounts
-A: Automatically mount all devices that support automatic mounting;
-B: Bind the directory to another directory;

-O mount option:
Async: Async Mode
Sync: Synchronous mode
Atime/noatime: Whether to update the access timestamp;
Diratime/nodiratime: Whether to update the access timestamp of the directory;
Auto/noauto: Whether this device is allowed to be automatically mounted;
Exec/noexec: Whether the application is allowed to execute on this file system;
Dev/nodev: Whether to support the use of device files on this device;
Suid/nosuid:
Remount: Re-mount
Ro
rw
User/nouser: Is it permissible to mount the device normally;
ACL: whether to support the use of FACL on this device;
DEFAULTS:RW, suid, Dev, exec, auto, Nouser, and Async

Umount: Uninstall command
# Umount DEVICE
# Umount Mount_point

To view the process that is accessing the specified mount point:
# fuser-v Mount_point

Terminates all processes that are accessing the specified mount point:
# fuser-km Mount_point

3, create a 10G file system, type EXT4, require the boot can be automatically mounted to the/mydata directory

1) Create mount point #mkdir/mydata

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/73/41/wKiom1X4RbLyA-3WAAA9qkNx_78252.jpg "height=" "/>"

2) Create a partition #我已创建sda3

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "border=" 0 "alt=" image "src=" http:// S3.51cto.com/wyfs02/m01/73/41/wkiom1x4rblzqmteaabjtjxvrrs509.jpg "height=" 117 "/>

3) partition file system advanced format #mkfs. Ext4/dev/sda3

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M02/73/41/wKiom1X4RbKBVJKwAAC2JXKSLi0717.jpg "height=" 221 "/>

4) configuration mount file:/etc/fstab #vim/etc/fstab

/mydata EXT4 Defaults 0 0

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M00/73/41/wKiom1X4RbKgdPAaAABKFpm-Ksk430.jpg "height="/>

5) Mount to/mydata

# Mount/dev/sda3/mydata

650) this.width=650; "title=" image "style=" border-top:0px;border-right:0px;background-image:none;border-bottom:0 px;padding-top:0px;padding-left:0px;border-left:0px;margin:0px;padding-right:0px; "border=" 0 "alt=" image "src=" Http://s3.51cto.com/wyfs02/M01/73/41/wKiom1X4RbLBoKF-AAAkgY3tDtE670.jpg "height="/>

September 01 Course Assignments (exercise)-linux File System Management

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.