8月7日作业

1、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统ext4,卷标为TEST,要求此分区开机后自动挂载至/mnt/sdd2目录,且默认有acl挂载选项

[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   ---分区大小为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  ---创建文件系统
[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
8月7日作业_第1张图片
QQ截图20170808153447.png
[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) 列出当前系统识别到的所有磁盘设备
(2) 如磁盘数量为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

你可能感兴趣的:(8月7日作业)