Linux Fourth week micro jobs

Source: Internet
Author: User

1, create a 10G partition, and the format of the Ext4 file system;

1) Use Fdisk-l to view the disk

2) use the fdisk/dev/[hs]d[a-z] command, for example, my fdisk/dev/sdb into the Fdisk tool

3) 650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9D/CE/wKioL1mGvR-AD_J3AAAfj5XXQ2M657.jpg "title=" 1502002440 (1). jpg "alt=" wkiol1mgvr-ad_j3aaafj5xxq2m657.jpg "/>

4) 650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9D/CF/wKiom1mGvbnhSFbrAABJ3iZP91A121.jpg "title=" 1502002585 (1). jpg "alt=" wkiom1mgvbnhsfbraabj3izp91a121.jpg "/>

n choose to create a new partition

P Create logical partition, E Create extended partition

W Save changes and exit the Fdisk tool

650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/9D/CF/wKiom1mGvy_TdoQYAAB0Ft45nnk098.jpg "title=" 1502002877 (1). jpg "alt=" wkiom1mgvy_tdoqyaab0ft45nnk098.jpg "/>

After saving the Fdisk tool, update the partition table with Partx-a/dev/sdb

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M02/9D/CF/wKiom1mGwHXCeROsAAAvpiTfykw199.jpg "title=" 1502003162 (1). jpg "alt=" wkiom1mgwhxcerosaaavpitfykw199.jpg "/>

Use MKFS.EXT4 to format the corresponding partition, MKFS.EXT4/DEV/SDB5,

Then use Blkid to view the specified block device information: BLKID/DEV/SDB5

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9D/CF/wKioL1mGweuB2iUsAAAgppqWrLM798.jpg "title=" 1502003531 (1). jpg "alt=" wkiol1mgweub2iusaaagppqwrlm798.jpg "/>

(1) The block size is required to 2048, the reserved space percentage is 2, the volume label is MyData, the default Mount property contains ACLs;

~]# mke2fs-t ext4-b 2048-m 2-l mydata/dev/sdb7

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M00/9D/CF/wKiom1mGxlfTkCqBAABFoIWluAc754.jpg "title=" 1502004790 (1). jpg "alt=" wkiom1mgxlftkcqbaabfoiwluac754.jpg "/>

Then use Df-h to view


(2) Mount to the/data/mydata directory, require the mount to prohibit the program to run automatically, and do not update the file access time stamp;

1) Create the/data/mydata directory first

2) Mount Mount-o noatime,noexec/dev/sdb7/data/mydata #noatime不更新文件时间戳

Prevent programs from running automatically when #noexec mounted


2, create a swap partition of size 1G, and create a good file system, and enable it;

1) Use FDISK/DEV/SDB to enter the disk utility

2) using N to create a new partition, I am here to create a new partition on the extended partition, and by default select Start Cylinder, +1g

3) Input L query the type to be partitioned, find swap,

4) Use T to select Type and enter 82, save and eject W

5) Update the partition table with Partx-a/dev/sdb

6) Use a dedicated MKSWAP format partition MKSWAP/DEV/SDB6

7) enable the Swap partition SWAPON/DEV/SDB6

650) this.width=650; "src=" Https://s4.51cto.com/wyfs02/M01/9D/CF/wKioL1mGyyPCelwHAAAaIBdKCTw321.jpg "title=" 1502006027 (1). jpg "alt=" wkiol1mgyypcelwhaaaaibdkctw321.jpg "/>


3. Write a script

(1), obtain and list all disk devices on the current system;

650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/9D/D0/wKiom1mGzpHiP6fQAABb6cuqB_k415.jpg "title=" 1502006901 (1). jpg "alt=" wkiom1mgzphip6fqaabb6cuqb_k415.jpg "/>

(2), display the space usage information about each partition on each disk device;

#!/bin/bash

Read-p "Please enter the SDA,SDB or any key" key #读取变量

Case $KEY in #如果变量为sda

Sda

df-h | grep SDA

Fdisk-l/DEV/SDA

;;

Sdb

df-h | grep SDB

Fdisk-l/dev/sdb

;;

*)

Df-h

Esac


4. Summarize the different levels of RAID and its combination mode and performance;

raid-0:0, strip reel, strip; RAID-1:1, mirrored volume, mirror; RAID-2 ... Raid-5:raid-6 RAID10 RAID01

RAID-0: Read and write performance improvement; free space: N*min (S1,s2,...)

No fault tolerance, minimum number of disks: 2,

Continuously split the data and read/write on multiple disks in parallel. Therefore has a high data transmission rate, the disadvantage is no redundancy

RAID-1: Read performance improvement, write performance slightly decreased; free space: 1*min (S1,s2,...)

Redundant capacity, minimum number of disks: 2,

But data security is very high, one-to-one redundancy, performance, read Medium, slow write

RAID-5: Read, write performance improvement, free space: (N-1) *min (s1,s2,...)

Fault tolerance: 1 disks, minimum number of disks: 3, data divided into three parts

If a disk is broken, does the data self-derive 1+? +1=3, so raid is redundant. But the actual capacity of the RAID5 is only 2 blocks of 3 hard drives, with high read performance and low write performance


Mixed type

RAID-10: Read, write performance improvement, free space: N*min (S1,s2,...) /2

Fault tolerance: Each group of mirrors can only be broken at most; minimum number of disks: 4, 4+



5, the creation of a size of 10G RAID1, requires a free disk, and chunk size of 128k;

1) Create 2 + 10G partitions using the Fdisk tool

2) Fdisk/dev/sdb, and then use N to create a partition of 10G 2 partitions

650) this.width=650; "src=" Https://s2.51cto.com/wyfs02/M01/9D/D0/wKioL1mG1dij9e0iAAAvh1FidoM754.jpg "title=" 1502008760 (1). jpg "alt=" wkiol1mg1dij9e0iaaavh1fidom754.jpg "/>

3) Save W, then partx-a/dev/sdb Update partition table

mdadm -C  /dev/md0 -l 1 -c 128 -n 2  4 /dev/sdb5 ) /dev/sdb6或者

mdadm -C  /dev/md0 -l 1 --chunk 128 -n 2  /dev/sdb5 /dev/sdb6 #创建级别为1chunk为128,的磁盘md0 5)mkfs.ext4  /dev/md0 #建立成功后格式化 6)mkdir /tmp/md0 #创建文件夹 7)mount /dev/md0 /tmp/md0 #挂机文件系统 8)df -h  #查看文件系统



6, the creation of a size of 4G RAID5 device, chunk size of 256k, format Ext4 file system, required to automatically mount to the/backup directory, and do not update the access timestamp, and support ACL function;

1) Use Fdisk/dev/sdb to enter the Fdisk tool to create a new partition Sdb11,sdb12,sdb13 each 4G

2) Save exit, partx-a/DEV/SDB Update partition table

3) ~]# mdadm-c/dev/md5-a yes-l 5-c 256-n 3/dev/sdb11/dev/sdb12/dev/sdb13

4) ~]# Mkfs.ext4/dev/md5 #建立成功后格式化

5) ~]# Mkdir/bachup #创建文件夹

6) ~]# Mount-o acl,noatime/dev/md5/backup #挂机文件系统不更新时间戳, and has ACL function

7) ~]# blkid/dev/md5 look at the UUID and copy the file in the back row of the/etc/fstab to let it boot up

8) df-h View File system










































This article is from the "11822904" blog, please be sure to keep this source http://11832904.blog.51cto.com/11822904/1954034

Linux Fourth week micro jobs

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.