1.10. 2017-11-15-练习-mount¶
1.10.1. 练习1-mount¶
1、创建一个2G的文件系统,块大小为2048byte,预留1%可用空间,文件系统ext4,卷标为TEST,要求此分区开机后自动挂载至/test目录,且默认有acl挂载选项
[root@centos7 app]$ fdisk /dev/sdb
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
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.
Command (m for help): p
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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: gpt
Disk identifier: CF8E8E9A-2E50-4DD8-AC6F-A621DDD9B8ED
# Start End Size Type Name
1 1953792 58593279 27G Linux LVM primary
Command (m for help): n
Partition number (2-128, default 2):
First sector (34-209715166, default 58593280):
Last sector, +sectors or +size{K,M,G,T,P} (58593280-209715166, default 209715166): +2G
Created partition 2
Command (m for help): p
Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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: gpt
Disk identifier: CF8E8E9A-2E50-4DD8-AC6F-A621DDD9B8ED
# Start End Size Type Name
1 1953792 58593279 27G Linux LVM primary
2 58593280 62787583 2G Linux filesyste
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@centos7 app]$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 128G 0 part [SWAP]
├─sda3 8:3 0 48.8G 0 part /
├─sda4 8:4 0 1K 0 part
└─sda5 8:5 0 19.5G 0 part /app
sdb 8:16 0 100G 0 disk
├─sdb1 8:17 0 27G 0 part
└─sdb2 8:18 0 2G 0 part
sr0 11:0 1 8.1G 0 rom /run/media/root/CentOS 7 x86_64
[root@centos7 app]$ mkfs -t ext4 -b 2048 -m 1 -L "TEST" /dev/sdb2
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=TEST
OS type: Linux
Block size=2048 (log=1)
Fragment size=2048 (log=1)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 1048576 blocks
10485 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=269484032
64 block groups
16384 blocks per group, 16384 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
16384, 49152, 81920, 114688, 147456, 409600, 442368, 802816
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
[root@centos7 app]$ tune2fs -l /dev/sdb2
tune2fs 1.42.9 (28-Dec-2013)
Filesystem volume name: TEST
Last mounted on: <not available>
Filesystem UUID: ac0dfb11-573e-4036-8fe9-256e04f0110c
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent 64bit flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: user_xattr acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 131072
Block count: 1048576
Reserved block count: 10485
Free blocks: 994651
Free inodes: 131061
First block: 0
Block size: 2048
Fragment size: 2048
Group descriptor size: 64
Reserved GDT blocks: 512
Blocks per group: 16384
Fragments per group: 16384
Inodes per group: 2048
Inode blocks per group: 256
Flex block group size: 16
Filesystem created: Mon Dec 4 19:27:56 2017
Last mount time: n/a
Last write time: Mon Dec 4 19:28:00 2017
Mount count: 0
Maximum mount count: -1
Last checked: Mon Dec 4 19:27:56 2017
Check interval: 0 (<none>)
Lifetime writes: 65 MB
Reserved blocks uid: 0 (user root)
Reserved blocks gid: 0 (group root)
First inode: 11
Inode size: 256
Required extra isize: 28
Desired extra isize: 28
Journal inode: 8
Default directory hash: half_md4
Directory Hash Seed: 2008b2d4-8232-4184-8ba8-9badec4f375f
Journal backup: inode blocks
[root@centos7 app]$ mkdir /test
[root@centos7 app]$ mount /dev/sdb2 /test
[root@centos7 app]$ tail -n 1 /etc/mtab >> /etc/fstab
[root@centos7 app]$ cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Tue Nov 7 16:07:01 2017
#
# 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=59ccea87-3c4e-4bbc-9e2f-3fadb1dcf2e6 / ext4 defaults 1 1
UUID=f4e867e8-bcde-43a2-adc7-c80b0948e85f /app ext4 noatime,usrquota,grpquota 1 2
UUID=1d6cbe88-ffb4-4adf-bacf-76be1fa75708 /boot ext4 defaults 1 2
UUID=b2c064f5-1ee5-4b5c-9e75-ed41cb99c5aa swap swap defaults 0 0
/dev/sdb2 /test ext4 rw,seclabel,relatime,data=ordered 0 0
[root@centos7 app]$ cd /test
[root@centos7 test]$ touch a.txt
[root@centos7 test]$ setfacl -m "u:zhaojiedi:rwx" a.txt
[root@centos7 test]$ getfacl a.txt
# file: a.txt
# owner: root
# group: root
user::rw-
user:zhaojiedi:rwx
group::r--
mask::rwx
other::r--