2 unit 4

###unit.4管理系統存儲###


###1.分區劃分

fdisk /dev/vdb

Welcome 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.


Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x6490d17b.


Command (m for help): m##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: 0x6490d17b


   Device Boot      Start         End      Blocks   Id  System

/dev/vdb1            2048      206847      102400   83  Linux


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

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.

[root@desktop18 ~]# partprobe ##同步分區表

[root@desktop18 ~]# cat /proc/partitions ##查看

mkfs.xfs /dev/vdb5##格式化

mount /dev/vdb5 /mnt##掛載


###2.swap

swapon -s##查看系統中的swap分區

建立swap分區

mkswap/dev/vdb1##把/dev/vdb1格式化成swap格式

swapon -a /dev/vdb1##激活

vim /etc/fstab##開機自動激活

/dev/vdb1swapswapdefautls0 0



刪除/etc/fstab中的swap自動激活條目

swapoff /dev/vdb1##關閉激活的swap分區




###3.磁盤加密

1.磁盤加密

fdisk/dev/vdb##分區

cryptestup luksFormat /dev/vdb1##加密磁盤

cryptestup open /dev/vdb1 westos##打開磁盤

mkfs.xfs /dev/mapper/westos##格式化

mount /dev/mapper/westos /mnt##掛載

umount /mnt##卸載

cryptestuo close westos##關閉


2.加密磁盤的永久掛載

vim /etc/crypttab##加密磁盤配置文件 

解密後設備管理文件設備加密字符存放文件##格式

westos/dev/vdb1/root/lukspsfile

vim /root/lukspsfile

密碼

chmod 600 /root/lukspsfile

cryptsetup luksAddKey /dev/vdb1 /root/lukspsfile

vim /etc/fstab 

/dev/mapper/westos/mntxfsdefaults0 0

reboot


###加密清除

vim /etc/fstab

> /etc/crypttab

rm -fr /root/lukspsdile

umount /mnt

cryptsetup close wesstos

mkfs.xfs /dev/vdb1 -f


###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

umoun /mnt

mdadm -S /dev.md0



mdadm-C##建立

mdadm-a##文件不存在建立文件

mdadm-l##raid級別

mdadm-n##設備個數

mdadm-x##閒置設備個數

mdadm-r##刪除

mdadm-f##破壞

mdadm-D##查看使用情況

mdadm-S##停止


###5.配額

fdisk /dev/vdb

mkdir /pub

mkfs.xfs /dev/vdb1 -f

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                         0          0      40000          0        0        0

su - student

dd if=/dev/zero of=/pub/file1 bs=1M count=500

dd: error writing ‘/pub/file1’: Disk quota exceeded

40+0 records in

39+0 records out

40960000 bytes (41 MB) copied, 0.0517844 s, 791 MB/s


qupta

Disk quotas for user student (uid 1000): 

     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace

      /dev/vdb1   40000*      0   40000               1       0       0     



開機自動掛載

vim /etc/fstab

/dev/vdb1/mntxfsdefaults,usrquota0 0 


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章