天天看點

分區

分區

fdisk /dev/vdb

        vfat

        ntfs

        ext

        xfs

n

p

1

2048

+100M

partprobe

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)

[root@localhost ~]# 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.

                                                                                                                                                             1,4-3         Top

Command (m for help): d

Partition number (1-5, default 5):

Partition 5 is deleted

Command (m for help): n

All primary partitions are in use

Adding logical partition 5

First sector (618496-20971519, default 618496):

Using default value 618496

Last sector, +sectors or +size{K,M,G} (618496-20971519, default 20971519):+100M

Partition 5 of type Linux and of size 100 MiB is set

Command (m for help): wq

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

分區類型位主分區

分區類型位擴充分區

[root@localhost ~]# cat /proc/partitions

major minor  #blocks  name

 253        0  10485760 vda

 253        1  10484142 vda1

 253      16   10485760 vdb

 253      17     102400 vdb1

 253      18     102400 vdb2

 253      19     102400 vdb3

 253      20          1 vdb4

 253      21     102400 vdb5

fdisk -l         檢視系統上能識别的裝置

cat /proc/partitions

mkfs.xfs /dev/vdb5      格式化分區/dev/vdb5(換個檔案系統)之後即可識别,挂載使用

blkid                   檢視系統可用的裝置

swapon -s               檢視swap 分區大小使用情況

2.swap

3.磁盤加密

cryptsetup luksFormat /dev/vdb1

cryptsetup open /dev/vdb1 westos

mkfs.xfs /dev/mapper/westos

mount /dev/mapper/westos /mnt/

umount /mnt/

cryptsetup close westos

 cryptsetup open /dev/vdb1 lol

       cryptsetup luksFormat/dev/vdb1  密碼設定成功不提示

       cryptsetup open /dev/vdb1 lol    打開才能用 ll/dev/mapper/ 檢視 

   13 ll /dev/mapper/

   14 mkfs.xfs /dev/mapper/lol 

   15 mount /dev/mapper/lol /mnt/

   16 df

   17 cd /mnt/             儲存檔案資料  挂載前後識别的是不同的裝置

   18 touch tiomo

   19 vim tiomo 

   20 cat tiomo 

   21 umount /mnt/

   22 cd 

   25 umount /mnt/

   26 cryptsetup close lol

                                                                              22.加密磁盤的永久挂載

vim /etc/crypttab

解密後裝置檔案管理檔案 裝置 加密字元存放檔案

vim /root/lukspdfile

chmod 600 /root/lukspsfile

cryptsetup luksAddKey /dev/vdb1 /root/lukspsfile

vim /etc/fstable

    /dev/mapper/taxing /mnt xfs defaults 00 

reboot

3.加密清除

vim /etc/fstab

> /etc/crypttab

rm -rf /root/lukspsfile

umount /mnt

cryptsetup close taxing

mkfs.xfs /dev/vdb1

4.磁盤陣列

C建立

l執行級别

a如果沒有這個盤自動建立

n同時幾塊盤建立riad

x閑置

    1 fdisk /dev/vdb

    3 partprobe 

    4 cat /proc/partitions 

    6 mdadm -C /dev/md0 -a yes -l 1 -n 2 -x 1 /dev/vdb{1..3}

    7 mkfs.xfs /dev/md0

    8 cat /proc/partitions 

    9 mount /dev/md0 /mnt/

   10 df

   11 cd /mnt/

   12 touch aa

   13 ls

watch -n 1 cat /proc/mdstat 監控/dev/md0 狀态

停止磁盤陣列

   15 mdadm -f /dev/md0 /dev/vdb1  先 -f(使停止。處于損壞的狀态) 再 -r(使删除)

   16 mdadm -r /dev/md0 /dev/vdb1

   17 mdadm -f /dev/md0 /dev/vdb3

   18 mdadm -r /dev/md0 /dev/vdb3

   20 mdadm -f /dev/md0 /dev/vdb2  最後一塊在使用,不能删除,需要停止磁盤陣列

   21 df

   22 umount /mnt/

   23 cd

   24 umount /mnt/         停止磁盤陣列前先解除安裝

   25 mdadm -S /dev/md0        停止磁盤陣列

5.配額

mkdir /pub

 chmod 1777 /pub/

mount -o usrquota /dev/vdb1 /pub 

quotaon -uv /dev/vdb1   指定激活顯示

edquota -u student  編輯設定

Disk quotas for user taxing (uid 1001):

  Filesystem                   blocks       soft       hard    inodes     soft     hard

  /dev/vdb1                    482800          0    500000          1        0       0

~                                                                                               

 su - taxing 

[taxing@localhost pub]$ dd if=/dev/zero of=/pub/file bs=1M count=500

dd: error writing ‘/pub/file’: No space left on device

472+0 records in

471+0 records out

494387200 bytes (494 MB) copied, 2.10227 s, 235 MB/s

永久挂載(開機啟動)

    /dev/vdb1    /mnt    xfs     defaults,usrquota   0   0

本文轉自   Taxing祥   51CTO部落格,原文連結:http://blog.51cto.com/12118369/1871428

繼續閱讀