1刨疼、創(chuàng)建一個2G的文件系統(tǒng)虐译,塊大小為2048byte瘪板,預(yù)留1%可用空間,文件系統(tǒng)ext4,卷標(biāo)為TEST漆诽,要求此分區(qū)開機(jī)后自動掛載至/mnt/sdd2目錄侮攀,且默認(rèn)有acl掛載選項(xiàng)
[root@centos6 app]#fdisk /dev/sdd
[root@centos6 app]#lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sr0 11:0 1 3.7G 0 rom /media/CentOS_6.9_Final
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1000M 0 part /boot
├─sda2 8:2 0 48.8G 0 part /
├─sda3 8:3 0 39.1G 0 part /app
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 2G 0 part [SWAP]
sdb 8:16 0 100G 0 disk
├─sdb1 8:17 0 10G 0 part
├─sdb2 8:18 0 20G 0 part
├─sdb3 8:19 0 10G 0 part
├─sdb4 8:20 0 1K 0 part
└─sdb5 8:21 0 5G 0 part
sdd 8:48 0 80G 0 disk
├─sdd1 8:49 0 5G 0 part
└─sdd2 8:50 0 2G 0 part ---分區(qū)大小為2G
sdc 8:32 0 150G 0 disk
├─sdc1 8:33 0 20G 0 part
└─sdc2 8:34 0 20G 0 part
[root@centos6 app]#mkfs.ext4 -b 2048 -m 1 -L TEST /dev/sdd2 ---創(chuàng)建文件系統(tǒng)
[root@centos6 app]#blkid /dev/sdd2
/dev/sdd2: LABEL="TEST" UUID="50d7102b-cee8-47f7-9cd8-758f2b063e01" TYPE="ext4"
[root@centos6 app]#tune2fs -l /dev/sdd2
[root@centos6 app]#mkdir /mnt/sdd2
vim /etc/fstab
UUID=50d7102b-cee8-47f7-9cd8-758f2b063e01 /mnt/sdd2 ext4 acl 0 0
[root@centos6 app]#mount -a
[root@centos6 app]#df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 50264772 4784968 42919804 11% /
tmpfs 502056 76 501980 1% /dev/shm
/dev/sda3 40185208 49016 38088192 1% /app
/dev/sda1 991512 34904 905408 4% /boot
/dev/sr0 3878870 3878870 0 100% /media/CentOS_6.9_Final
/dev/sdd2 2005772 9236 1975492 1% /mnt/sdd2
[root@centos6 app]#mount
/dev/sda2 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda3 on /app type ext4 (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
gvfs-fuse-daemon on /root/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev)
/dev/sr0 on /media/CentOS_6.9_Final type iso9660 (ro,nosuid,nodev,uhelper=udisks,uid=0,gid=0,iocharset=utf8,mode=0400,dmode=0500)
/dev/sdd2 on /mnt/sdd2 type ext4 (rw,acl)
2、寫一個腳本拴泌,完成如下功能:
(1) 列出當(dāng)前系統(tǒng)識別到的所有磁盤設(shè)備
(2) 如磁盤數(shù)量為1魏身,則顯示其空間使用信息
否則,則顯示最后一個磁盤上的空間使用信息
#!/bin/bash
df|grep /dev/sd|tr -s " "|cut -d " " -f1
disknu=`df|grep /dev/sd|wc -l`
[ "$disknu" -eq 1 ]&& df|grep /dev/sd |tr -s " " |cut -d " " -f1,5
[ "$disknu" -gt 1 ]&& df|grep /dev/sd |tr -s " " |cut -d " " -f1,5|tail -n1
unset disknu