创建一个2G的文件系统,块大小为2048byte, 预留1%可用空间,文件系统ext4,卷标为TEST,要求此分区开机后自动挂载至/testdir目录,且默认有acl挂载选项
[root@English6 ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xba5c32cb.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xba5c32cb
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): +2G
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@English6 ~]# mke2fs -b 2048 -m 1 -t ext4 -L TEST /dev/sdc1
mke2fs 1.41.12 (17-May-2010)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131560 inodes, 1052240 blocks
10522 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=538968064
65 block groups
16384 blocks per group, 16384 fragments per group
2024 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 27 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@English6 ~]# blkid
/dev/sda1: UUID="47c3f22b-7ed9-4ce1-b341-2d95ff6555af" TYPE="ext4"
/dev/sda2: UUID="33bb1eff-ce5c-4fd8-954e-191c7fb12e6d" TYPE="ext4"
/dev/sda3: UUID="c9eeb128-84ac-402c-bf90-91ef5f355355" TYPE="ext4"
/dev/sda5: UUID="68b451f6-71ee-4631-a98c-c0a201df6009" TYPE="swap"
/dev/sde1: UUID="6fbf0519-88ee-4d99-80aa-3738551ccbcb" TYPE="ext4" LABEL="sde"
/dev/sde2: UUID="46fbd103-c122-4880-8090-e69b7762f3ad" TYPE="swap"
/dev/sdb1: UUID="7454f830-57f9-46f8-bb3d-78cb0c34e803" TYPE="swap"
/dev/sdc1: LABEL="TEST" UUID="04b2bfca-32b9-4d52-beb4-5845281c63a4" TYPE="ext4"
[root@English6 ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Thu Jul 21 16:53:41 2016
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=33bb1eff-ce5c-4fd8-954e-191c7fb12e6d / ext4 defaults 1 1
UUID=47c3f22b-7ed9-4ce1-b341-2d95ff6555af /boot ext4 defaults 1 2
UUID=c9eeb128-84ac-402c-bf90-91ef5f355355 /testdir ext4 defaults 1 2
UUID=68b451f6-71ee-4631-a98c-c0a201df6009 swap swap defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
UUID="04b2bfca-32b9-4d52-beb4-5845281c63a4" /wang ext4 acl 0 0
~
~
[root@English6 ~]# mount -a
[root@English6 ~]# reboot
Broadcast message from root@English6.8
(/dev/pts/2) at 22:33 ...
The system is going down for reboot NOW!
[root@English6 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 50264772 4707780 42996992 10% /
tmpfs 502068 72 501996 1% /dev/shm
/dev/sda1 194241 34207 149794 19% /boot
/dev/sda3 20027260 333816 18669444 2% /testdir
/dev/sdc1 2005740 9236 1975460 1% /wang
写一个脚本,完成如下功能:
(1) 列出当前系统识别到的所有磁盘设备
(2) 如磁盘数量为1,则显示其空间使用信息
否则,则显示最后一个磁盘上的空间使用信息
[root@localhost sh.log]# cat cipan.sh
#!/bin/bash
#author:DYW
#写一个脚本,完成两个功能(1)列出当前系统识别到的所有磁盘设备(2)如磁盘数量为1,则显示其空间使用信息,否则,则显示最后一个磁盘上的空间使用信息
part=`cat /proc/partitions`
echo -e "$part\t"
echo "==============================="
declare -a par=(`cat /proc/partitions|grep -o "sd[a-z]$"|xargs`)
a=${#par[*]}
if [ $a == 1 ];then
echo -e "`df -h /dev/${par[0]}*|sort -r|uniq`\t"
else
echo -e "`df -h /dev/${par[$a-1]}*|sort -r|uniq`\t"
fi
[root@localhost sh.log]# bash cipan.sh
major minor #blocks name
11 0 7587840 sr0
8 0 104857600 sda
8 1 512000 sda1
8 2 104344576 sda2
8 16 20971520 sdb
8 17 10485760 sdb1
8 48 20971520 sdd
8 49 10485760 sdd1
8 32 20971520 sdc
8 33 10485760 sdc1
253 0 52428800 dm-0
253 1 2097152 dm-1
253 2 49750016 dm-2
8 64 104857600 sde
===============================
Filesystem Size Used Avail Use% Mounted on
devtmpfs 479M 0 479M 0% /dev
原创文章,作者:DYW,如若转载,请注明出处:http://www.178linux.com/41844

