4.管理系统存储

来源:互联网 发布:moe域名备案 编辑:程序博客网 时间:2024/05/20 00:17

1.分区划分
fdisk /dev/vda
elcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you 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 (0 primary, 0 extended, 4 free) ##分区类型位主分区
e extended ##分区类型位扩展分区
Select (default p): ##默认位主分区
Using default response p
Partition number (1-4, default 1): 1 ##主分区id
First sector (2048-20971519, default 2048): ##此分区起始位置
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +100M ##分区大小
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): p

Disk /dev/vdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x193488c3

Device Boot Start End Blocks Id System
/dev/vdb1 2048 206847 102400 83 Linux

Command (m for help): wq ##保存推出,如果安q表示放弃更改退出

[root@localhost mnt]# partprobe ##同步分区表

mkfs.xfs /dev/vdb5 ##格式化
mount /dev/vdb5 /mnt ##挂载
这里写图片描述
2.swap
这里写图片描述
3.磁盘加密
1.磁盘加密
fdisk /dev/vdb
cryptsetup luksFormat /dev/vdb1
cryptsetup open /dev/vdb1 westos
mkfs.xfs /dev/mapper/westos
mount /dev/mapper/westos /mnt/
umount /mnt/
cryptsetup close westos
2.自动挂载
[root@desktop19 ~]# vim /etc/crypttab 开机自动生成
[root@desktop19 ~]# vim /root/diskpass 记录密码
[root@desktop19 ~]# chmod 600 /root/diskpass
[root@desktop19 ~]# cryptsetup luksAddKey /dev/vdb1 /root/diskpass
Enter any passphrase:
[root@desktop19 ~]# vim /etc/fstab
加密清除
vim /etc/fstab

/etc/crypttab
rm -fr /root/lukspsfile
umount /mnt/
cryptsetup close redhat
mkfs.xfs /dev/vdb1
这里写图片描述
4.磁盘阵列
fdisk /dev/vdb
mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 /dev/vdb{1..3}
mkfs.xfs /dev/md0
mount /dev/md0 /mnt/
watch -n 1 cat /proc/mdstat

mdadm -f /dev/md0 /dev/vdb1
mdadm -D /dev/md0
mdadm -r /dev/md0 /dev/vdb1
mdadm -a /dev/md0 /dev/vdb1
umount /mnt/
mdadm -S /dev/md0
这里写图片描述
5.配额
mount -o usrquota /dev/vdb1 /pub
quotaon -uv /dev/vdb1
edquota -u student
这里写图片描述

0 0
原创粉丝点击