The second book, Unit Four, summarizes

Source: Internet
Author: User

################################
# # # #第二本书 IV Unit ##############
###############################
I. Partition DIVISION
Fdisk/dev/vdb
The device presents a logical sector size is smaller than
The physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance could be impacted.
Welcome to Fdisk (Util-linux 2.23.2).

Changes'll remain in memory only, until the decide to write them.
Be careful before using the Write command.


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 # #删除分区
G Create a new empty GPT partition table
G Create an IRIX (SGI) partition table
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 # #修改分区功能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
Partition Type:
P Primary (1 primary, 1 extended, 2 free)
L Logical (numbered from 5)
Select (Default P): # #默认位主分区
Using Default Response P
Partition number (3,4, default 3): # #主分区id
First sector (976773120-976773167, default 976773120): # #此分区起始位置
Using Default Value 976773120
Last sector, +sectors or +size{k,m,g} (976773120-976773167, default 976773167): +100m # #分区大小

Command (M for help): P

disk/dev/sda:500.1 GB, 500107862016 bytes, 976773168 sectors
Units = sectors of 1 * MB = bytes
Sector size (logical/physical): bytes/4096 bytes
I/O size (minimum/optimal): 4096 bytes/4096 bytes
Disk label Type:dos
Disk identifier:0xaa46f25b

Device Boot Start End Blocks Id System
/DEV/SDA1 * 2048 167776255 83887104 7 Hpfs/ntfs/exfat
/dev/sda2 167776256 976773119 404498432 f W95 Ext ' d (LBA)
/dev/sda5 167778304 438312959 135267328 7 Hpfs/ntfs/exfat
/dev/sda6 438315008 708849663 135267328 7 Hpfs/ntfs/exfat
/DEV/SDA7 708851712 708855807 2048-up Linux
/dev/sda8 708857856 709881855 512000-up Linux
/dev/sda9 709883904 717486079 3801088, Linux Swap/solaris
/DEV/SDA10 717488128 976773119 129642496-up Linux


Command (M for help): Wq # #保存退出, if you press Q to discard the change exit


Two. Swap
The swap space or swap area is the space on the disk drive that is used as an overflow that is not currently using partial memory. This allows the system to allow space in the main memory to store the data that is currently being processed and to provide an emergency overflow when the system is at risk of running out of main memory space


Mkswap/dev/vdan will be ready to use the partition as a swap area.
Blkid/dev/vdan will determine the UUID
To add a new swap space to the/etc/fstab:
Uuid=uuid swap swap defaults 0 0
/dev/vdan
SWAPON-A will activate the new swap area
Swapon-s will display the status of the current swap area
Swapoff/dev/vdan will deactivate the specific swap area

Three. Disk
1. Disk Encryption
Fdisk/dev/vdb
Cryptsetup LUKSFORMAT/DEV/VDB1
warning!
========
This would overwrite data on/dev/vdb1 irrevocably.

Is you sure? (Type uppercase Yes): Yes # #确定加密
Enter Passphrase: # #密码大于8位, and can't be too simple
Verify Passphrase: # #确认密码

Cryptsetup open/dev/vdb1 Westos # #解密
Mkfs.xfs/devmapper/westos # #用管理文件格式化设备
mount/dev/mapper/westos/mnt/# #使用设备
umount/mnt/# #使用设备
Cryptsetup Close Westos # #关闭设备加密层

2. Permanent Mount of encrypted disks
Vim/etc/crypttab
Decryption Device management file device encryption character store file
Redhat/dev/vdb1/root/lukspsfile
Vim/root/luspsfile
chmod 600/root/lukspsfile
Cryptsetup Luksaddkey/dev/vdb1/root/lukspsfile
Vim 600/root/lukspsfile
Cryptsetup Luksaddkey/dev/vdb1/root/lukspsfile
Vim/etc/fstab
/DEV/MAPPER/REDHAT/MNT XFS Defaults
Reboot

3. Encryption Erase
Vim/etc/fatab
>/etc/crypttab
Rm-fr/root/lukspsfile
umount/mnt/
Cryptsetup Close Redhat
Mkfs.xfs/dev/vdb1

4. Disk array
FDISK/DEV/VDB # #创建分区

Mdadm-c/dev/md0-a yes-l 1-n 2-x 1/dev/vdb{1..3}
-C # #建立
-A # #文件不存在建立文件
-L # #raid级别
-N # #设备个数
-X # #闲置设备个数

Mkfs.xfs/dev/md0
mount/dev/md0/mnt/
Watch-n 1 Cat/proc/mdstat

Mdadm-f/DEV/MD0/DEV/VDB1 # #损坏设备1
Mdadm-d/dev/md0
Mdadm-r/DEV/MD0/DEV/VDB1 # #移除设备1
Mdadm-a/DEV/MD0/DEV/VDB1 # #恢复设备1
umount/mnt/
Mdadm-s/dev/md0 # #停止设备

5. Quotas
Mount-o usrquota/dev/vdb1/pub
Quotaon-uv/dev/vdb1
Edquota-u Student
Disk Quotas for User student (UID 1000):
Filesystem blocks soft hard inodes soft hard
/DEV/VDB1 102400 0 40000 1 0 0
Su-student
DD If=/dev/zero of=/pub/file bs=1m count=500
Dd:error writing '/pub/file ': Disk quota exceeded

This article from "12100661" blog, declined reprint!

The second book, Unit Four, summarizes

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.