未加星标

N26 第七周作业

字体大小 | |
[系统(linux) 所属分类 系统(linux) | 发布者 店小二05 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

1、创建一个10G分区,并格式为ext4文件系统;

(1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;

[[email protected] ~]# fdisk /dev/sdb

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): d

Selected partition 1

Partition 1 is deleted

Command (m for help): n

Partition type:

p primary (0 primary, 0 extended, 4 free)

e extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-41943039, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +10G

Partition 1 of type Linux and of size 10 GiB is set

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[[email protected] ~]# mke2fs -b 2048 -m 2 -t ext4 -L MYDATA /dev/sdb1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=MYDATA

OS type: Linux

Block size=2048 (log=1)

Fragment size=2048 (log=1)

Stride=0 blocks, Stripe width=0 blocks

655360 inodes, 5242880 blocks

104857 blocks (2.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=273678336

320 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, 1327104,

2048000, 3981312

Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

[[email protected] ~]# tune2fs -o acl /dev/sdb1

tune2fs 1.42.9 (28-Dec-2013)

[[email protected] ~]# tune2fs -l /dev/sdb1

tune2fs 1.42.9 (28-Dec-2013)

Filesystem volume name: MYDATA

Last mounted on: <not available>

Filesystem UUID: ddd0ab73-0f58-414c-ae46-d2b354d2bdde

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: 655360

Block count: 5242880

Reserved block count: 104857

Free blocks: 5121266

Free inodes: 655349

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: Sat Feb 4 11:31:58 2017

Last mount time: n/a

Last write time: Sat Feb 4 11:32:29 2017

Mount count: 0

Maximum mount count: -1

Last checked: Sat Feb 4 11:31:58 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: a05dbfa7-5483-4885-9295-2418b7bd76ea

Journal backup: inode blocks

(2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳; [[email protected] ~]# mount -o noexec,noatime /dev/sdb1 /data/mydata [[email protected] ~]# stat /data/mydata/aaa.txt

File: ‘/data/mydata/aaa.txt’

Size: 15 Blocks: 4 IO Block: 2048 regular file

Device: 811h/2065d Inode: 16 Links: 1

Access: (0644/-rw-r r ) Uid: ( 0/ root) Gid: ( 0/ root)

Context: unconfined_u:object_r:unlabeled_t:s0

Access: 2017-02-04 10:45:12.167018328 +0600

Modify: 2017-02-04 10:45:12.167018328 +0600

Change: 2017-02-04 10:45:12.197018328 +0600

Birth:

# 读取文件后Access时间戳不会改变

[[email protected] ~]# cat /data/mydata/aaa.txt

I study Linux.

[[email protected] ~]# stat /data/mydata/aaa.txt

File: ‘/data/mydata/aaa.txt’

Size: 15 Blocks: 4 IO Block: 2048 regular file

Device: 811h/2065d Inode: 16 Links: 1

Access: (0644/-rw-r r ) Uid: ( 0/ root) Gid: ( 0/ root)

Context: unconfined_u:object_r:unlabeled_t:s0

Access: 2017-02-04 10:45:12.167018328 +0600

Modify: 2017-02-04 10:45:12.167018328 +0600

Change: 2017-02-04 10:45:12.197018328 +0600

Birth:

# 即使设置挂载选项noatime,修改文件或touch文件仍然可以改变时间戳

[[email protected] ~]# touch /data/mydata/aaa.txt [[email protected] ~]# stat /data/mydata/aaa.txt

File: ‘/data/mydata/aaa.txt’

Size: 15 Blocks: 4 IO Block: 2048 regular file

Device: 811h/2065d Inode: 16 Links: 1

Access: (0644/-rw-r r ) Uid: ( 0/ root) Gid: ( 0/ root)

Context: unconfined_u:object_r:unlabeled_t:s0

Access: 2017-02-04 10:48:16.080017861 +0600

Modify: 2017-02-04 10:48:16.080017861 +0600

Change: 2017-02-04 10:48:16.080017861 +0600

Birth:

# 运行二进制程序会提示“权限拒绝”

[[email protected] ~]# /data/mydata/bash

-bash: /mnt/bash: Permission denied

2、创建一个大小为1G的swap分区,并创建好文件系统,并启用之; [[email protected] ~]# fdisk /dev/sdb

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): n

Partition type:

p primary (1 primary, 0 extended, 3 free)

e extended

Select (default p): 1

Invalid partition type `1'

Command (m for help): n

Partition type:

p primary (1 primary, 0 extended, 3 free)

e extended

Select (default p):

Using default response p

Partition number (2-4, default 2):

First sector (20973568-41943039, default 20973568):

Using default value 20973568

Last sector, +sectors or +size{K,M,G} (20973568-41943039, default 41943039): +1G

Partition 2 of type Linux and of size 1 GiB is set

Command (m for help): t

Partition number (1,2, default 2): 2

Hex code (type L to list all codes): L

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris

1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-

2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-

3 XENIX usr 3c PartitionMagic 84 OS/2 hidden C: c6 DRDOS/sec (FAT-

4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx

5 Extended 41 PPC

本文系统(linux)相关术语:linux系统 鸟哥的linux私房菜 linux命令大全 linux操作系统

主题: Linux360
分页:12
转载请注明
本文标题:N26 第七周作业
本站链接:http://www.codesec.net/view/530931.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(linux) | 评论(0) | 阅读(38)