Linux Disk Management with Margo Linux (Lesson 4)

Source: Internet
Author: User
Tags uuid

Linux File System Management:

MKFS, Mkfs-type = mkfs.ext2,3,4

Cases:

[[email protected] ~]# mkfs -type ext4 /dev/sdbmkfs.ype: no such  File or directory[[email protected] ~]# mkfs -t ext4 /dev/sdbmke2fs  1.41.12  (17-may-2010)/dev/sdb is entire device, not just one  partition! proceed anyway?  (y,n)  yFilesystem label=OS type: LinuxBlock size=4096  (log=2) fragment size=4096  (log=2) stride=0 blocks, stripe width=0 blocks1310720  inodes, 5242880 blocks262144 blocks  (5.00%)  reserved for the super  userFirst data block=0Maximum filesystem blocks=4294967296160 block  Groups32768 blocks per group, 32768 fragments per group8192 inodes  per groupSuperblock backups stored on blocks: 32768, 98304,  163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000writing inode tables : done                             Creating journal  (32768  blocks):  donewriting superblocks and filesystem accounting information:  doneThis filesystem will be automatically checked every 25  Mounts or180 days, whichever comes first.  use tune2fs -c or  -i to override.

Ext:mke2fs

Cases:

[[email protected] ~]# mkfs.ext4 /dev/sdbmke2fs 1.41.12  (17-May-2010)/dev/sdb  is entire device, not just one partition! proceed anyway?  (y,n)  yFilesystem label=OS type: LinuxBlock size=4096  (log=2) fragment size=4096  (log=2) stride=0 blocks, stripe width=0 blocks1310720  inodes, 5242880 blocks262144 blocks  (5.00%)  reserved for the super  userFirst data block=0Maximum filesystem blocks=4294967296160 block  Groups32768 blocks per group, 32768 fragments per group8192 inodes  per groupSuperblock backups stored on blocks: 32768, 98304,  163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000writing  inode tables: done                             Creating journal  (32768 blocks): donewriting  Superblocks and filesystem accounting information: donethis filesystem will  be automatically checked every 37 mounts or180 days, whichever  comes first.  use tune2fs -c or -i to override.


Creating a file system

MKE2FS [OPTION]: DEVICE

-T EXT2,EXT3,EXT4

-B 1024,2048,4096

-l ' lable ' label

-j MKE2FS-T Ext

-I. Inode

-N Reserved how many inode

-M reserves the percentage of disk space for post-management

-O feature[...] Turn on reserved features

-o^featuew[...] Turn off reserved features

File System Properties View and adjustment tools:

E2lable: Managing File System Volume labels

E2lable DEVICE [Lavle]

Cases:

[Email protected] ~]# e2label/dev/sdb ' mydisk ' [[email protected] ~]# E2label/dev/sdb

Mydisk

TUNE2FS: Display file System Properties, or adjust file system Properties

-L Display superblock information

-l lable Modifying the volume label

-m manage reserved space for administrators

-j EXT2-->EXT3

-O Enable or disable attributes

-o File system default mount option turned on or off

Example 1:

[[email protected] ~]# tune2fs -l /dev/sdbtune2fs 1.41.12  (17-May-2010) filesystem volume name:   mydisklast mounted on:           <not available>Filesystem UUID:           e2ec1086-064d-4eac-950f-0672a508213efilesystem magic number:   0xEF53Filesystem revision #:    1  (dynamic) filesystem  features:      has_journal ext_attr resize_inode dir_index  Filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_ Nlink extra_isizefilesystem flags:         signed_ directory_hash default mount options:     (None) Filesystem state:          cleanerrors behavior:           continuefilesystem os type:       linuxinode count:               1310720Block count:               5242880Reserved block  count:     262144free blocks:               5116591Free inodes:               1310709First block:               0Block size:                4096Fragment size:             4096reserved  gdt blocks:      1022blocks per group:          32768Fragments per group:       32768inodes per group:         8192inode blocks  per group:   512Flex block group size:     16filesystem created:       sun sep  6 19:08:01  2015Last mount time:          n/aLast  write time:          sun sep  6  19:10:29 2015mount count:               0Maximum mount count:      37Last checked:              sun sep  6 19:08:01 2015check interval:            15552000  (6 months) Next check after:          Fri Mar  4 19:08:01  2016lifetime writes:          452 mbreserved  blocks uid:      0  (user root) Reserved blocks gid:       0  (group root) first inode:               11Inode size:           256required extra isize:     28desired extra  isize:      28Journal inode:             8default directory hash:   half_md4directory hash seed:       4fc68caf-3b7f-401e-8022-707100c2b923Journal backup:            inode blocks


DUMPE2FS display file system layout and superblock information

Cases:

Dumpe2fs/dev/sdb

File System Detection System

FSCK File System Detection

Fsck-t test = Fsck.type

-A automatically fix file system errors

-F Interactive Repair

-F Force Detection

Cases:

[Email protected] ~]# fsck.ext4-a/dev/sdb Mydisk:clean, 11/1310720 files, 126289/5242880 blocks

E2fsck:ext File System Special Detection Tool

-Y auto Fix error

-F Force Detection

Cases:

[Email protected] ~]# e2fsck-f/dev/sdbe2fsck 1.41.12 (17-may-2010) Pass 1:checking inodes, blocks, and Sizespass 2:che cking directory structurepass 3:checking directory connectivitypass 4:checking reference countspass 5:checking group Su Mmary informationmydisk:11/1310720 files (0.0% non-contiguous), 126289/5242880 blocks

File system mount and use

Kernel--ROOTFS partition

ROOTFS partition

Bin,sbin,boot,etc,lib,lib64,dev,tmp,usr,proc

Establish an association between the additional file system and a pre-asked directory of the root filesystem, making this directory the gateway to the other directory, becoming a mount

The process of contacting this association, called unloading

Mount points: mount point device mounts to this directory

Note: Mount points need to be empty directories

Mount Method: Mount: Reads the/etc/mtab file to display all the current system

Mount-a Mount/etc/fstab All devices that support automatic mounting in the volume file

Mount [OPTION] [-o-option] DEVICE Mount_point

[option] Command options

[-o option] hangs on options

Device: Devices to be mounted

(1) Device file:/DEV/SDA

(2) Volume label-l

(3) Uuid-u

(4) Pseudo file System file name mount

Common options

-T File System Properties

-R mount in read-only mode

-W Mount in read-write mode

-N Each file system is automatically updated when mounted/etc/mtab-n disable this feature

-A automatically mounts all devices that support automatic mounting

-B Bind directory to another directory

Cases:

[Email protected] ~]# mkdir/mydata[[email protected] ~]# mount-o rw,async,noatime/dev/sdb/mydata

-O mount option

Async Async Mode

Sync Sync mode

Atime/noatime whether to update the access timestamp

Diratime/nodiratime whether to update access directory timestamp

Auto/noauto whether this device is allowed to mount automatically

Exec/noexec whether executable programs on this file system are allowed to execute

Dev/nodev support for using device files on this device

Suid/nosudi

Remount Re-mount

Ro/rw

User/nouser whether a normal user is allowed to mount this device

Whether the ACL allows this device to use Facl

Umount: Uninstall command

Umount DEVICE

Umount Mount_point

Cases:

[Email protected] ~]# umount/dev/sdb[[email protected] ~]# Umount/mydata

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

Cases:

[[email protected] ~]# fuser-v/mydata USER PID ACCESS command/mydata:root 2476.. C.. bash[[email protected] ~]# fuser-km/mydata/mydata:2476c

Swap partition:

Free command

View menmory and Swap usage status

Free-m shown in MB

Cases:

[[email protected] ~]# free -m               total       used        free     shared    buffers      cachedMem:          1862         253       1609           0         51          63-/+ buffers/cache:        137        1724 swap:         3071           0       3071


Free-g with G display (4 5 in Display)

Cases:

[[email protected] ~]# free -g              total       used        free     shared    buffers      cachedmem:             1           0          1           0           0          0-/+ buffers/cache:           0          1  swap:            2          &Nbsp;0          2 

Practice:

Create a 10G file system, type EXT4, require boot to automatically mount to/mydata directory

[[email protected] ~]# fdisk -l /dev/sdbdisk /dev/sdb: 21.5 gb,  21474836480 bytes255 heads, 63 sectors/track, 2610 cylindersunits =  cylinders of 16065 * 512 = 8225280 bytessector size  (logical/ Physical): 512 bytes / 512 bytesi/o size  (minimum/optimal): 512  bytes / 512 bytesdisk identifier: 0x13a6c9bf   device boot       Start         End       Blocks   Id  System/dev/sdb1                1        1306     10490413+  83  linux[[email protected] fs]# kpartx  -a /dev/sdb1[[email protected] fs]# mkfs.ext4 /dev/sdb1mke2fs 1.41.12  (17-May-2010) Filesystem  label=OS type: LinuxBlock size=4096  (log=2) fragment size=4096  (log=2) stride=0 blocks, stripe width=0 blocks655776 inodes, 2622603 blocks131130  blocks  (5.00%)  reserved for the super userfirst data block= 0maximum filesystem blocks=268854886481 block groups32768 blocks per group,  32768 fragments per group8096 inodes per groupsuperblock backups &NBSP;STORED&NBSP;ON&NBSP;BLOCKS:&NBSP;32768,&NBSP;98304,&NBSP;163840,&NBSP;229376,&NBSP;294912,&NBSP;819200,  884736, 1605632Writing inode tables: done                              creating journal  (32768 blocks):  donewriting superblocks and filesystem accounting  information: donethis filesystem will be automatically checked every  39 mounts or180 days, whichever comes first.  use tune2fs  -c or -i to override. [[email protected] fs]# e2label /dev/sdb1  ' MyData ' [[email protected] fs]# &NBSP;E2LABEL&NBSP;/DEV/SDB1MYDATA[[EMAIL&NBSP;PROTECTED]&NBSP;FS] #vim  /etc/fstabLABEL=mydata                   /mydata                  ext4     defaults        0 0


Linux Disk Management with Margo Linux (Lesson 4)

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.