未加星标

22期第七周课堂练习

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

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

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

(2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳;

1.创建分区/dev/sdb1,容量为10G
[[email protected] ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa5b8f2f4.
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1435, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-1435, default 1435): +10G
Command (m for help): w
2.查看创建的分区
[[email protected] ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 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: 0xa5b8f2f4
Device Boot Start End Blocks Id System
/dev/sdb1 1 1306 10490413+ 83 linux
3.格式化
[[email protected] ~]# mke2fs -b 2048 -m 2 -t ext4 -L MYDATA /dev/sdb1
4.修改分区属性
[[email protected] ~]# tune2fs -o acl /dev/sdb1
tune2fs 1.41.12 (17-May-2010)
5.查看分区属性
[[email protected] ~]# dumpe2fs -h /dev/sdb1
dumpe2fs 1.41.12 (17-May-2010)
Filesystem volume name: MYDATA
Last mounted on: <not available>
Filesystem UUID: d97d8ba2-ebed-413b-a4c7-a9a0a4986fa1
Filesystem magic number: 0xEF53
Filesystem revision #: 1 (dynamic)
Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize
Filesystem flags: signed_directory_hash
Default mount options: acl
Filesystem state: clean
Errors behavior: Continue
Filesystem OS type: Linux
Inode count: 657408
Block count: 5245206
Reserved block count: 104904
Free blocks: 5123382
Free inodes: 657397
First block: 0
Block size: 2048
Fragment size: 2048
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: Wed Sep 21 17:33:07 2016
Last mount time: n/a
Last write time: Wed Sep 21 17:34:14 2016
Mount count: 0
Maximum mount count: 39
Last checked: Wed Sep 21 17:33:07 2016
Check interval: 15552000 (6 months)
Next check after: Mon Mar 20 17:33:07 2017
Lifetime writes: 226 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: 043a3a0c-ac3a-4728-8bdf-e0347fa690da
Journal backup: inode blocks
Journal features: (none)
Journal size: 64M
Journal length: 32768
Journal sequence: 0x00000001
Journal start: 0
4.挂载
[[email protected] ~]# mount -o noexec,nodiratime /dev/sdb1 /data/mydata/
5.设置开机自动挂载
[[email protected] ~]# vim /etc/fstab
#
# /etc/fstab
# Created by anaconda on Mon Aug 22 18:25:35 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
#
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=e36e7a7c-97a5-4712-ac29-7973c98c847c /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap 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
/dev/sdb1 /mnt ext4 defaults 0 0

2、创建一个大小为1G的swap分区,并创建好文件系统,并启用之;

1.查看当前swap分区大小,目前为3G
[[email protected] ~]# free -m total used free shared buffers cached
Mem: 1862 303 1559 0 19 105
-/+ buffers/cache: 178 1683
Swap: 3071 0 3071
2.创建swap类型的分区/dev/sdb1
[[email protected] ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 11.8 GB, 11811160064 bytes
255 heads, 63 sectors/track, 1435 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: 0xa5b8f2f4
Device Boot Start End Blocks Id System
/dev/sdb1 1 132 1060258+ 82 Linux swap / Solaris
3.转换为交换分区
[[email protected] ~]# mkswap /dev/sdb1
Setting up swapspace version 1, size = 1060252 KiB
no label, UUID=898c07c8-5460-44d5-9ae9-049568b339bc
4.启动交换分区
[[email protected] ~]# swapon /dev/sdb1
5.再次查看交换分区。变成了4G
[[email protected] ~]# free -m total used free shared buffers cached
Mem: 1862 304 1558 0 19 105
-/+ buffers/cache: 179 1683
Swap: 4107 0 4107

3、写一个脚本

(1)、获取并列出当前系统上的所有磁盘设备;

(2)、显示每个磁盘设备上每个分区相关的空间使用信息;

#!/bin/bash
#show dev info
for dev in $(fdisk -l|grep -o "^/dev/[[:alnum:]]\{3,\}");do
echo $dev
echo -e "$(df -h $dev)\n"
done

4、总结RAID的各个级别及其组合方式和性能的不同;


22期第七周课堂练习

5、创建一个大小为10G的RAID1,要求有一个空闲盘,而且CHUNK大小为128k;

1.创建2个raid类型的分区,/dev/sdc1,/dev/sdd1,/dev/sde1,创建raid1
[[email protected] ~]# mdadm -C -l 1 -c 128 -n 2 -x 1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: device /dev/sdc1 exists but is not an md array.
[[email protected] ~]# mdadm -C /dev/md0 -l 1 -c 128 -n 2 -x 1 /dev/sdc1 /dev/sdd1 /dev/sde1
mdadm: Note: this array has metadata at the start and
may not be suitable as a boot device. If you plan to
store '/boot' on this device please ensure that
your boot-loader understands md/v1.x metadata, or use
--metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.
2.查看raid信息
[[email protected] ~]# mdadm -D /dev/md0
/dev/md0:
Version : 1.2
Creation Time : Mon Sep 26 20:03:48 2016
Raid Level : raid1
Array Size : 10482112 (10.00 GiB 10.73 GB)
Used Dev Size : 10482112 (10.00 GiB 10.73 GB)
Raid Devices : 2
Total Devices : 3
Persistence : Superblock is persistent
Update Time : Mon Sep 26 20:04:21 2016
State : clean, resyncing
Active Devices : 2
Working Devices : 3
Failed Devices : 0
Spare Devices : 1
Resync Status : 28% complete
Name : bogon:0 (local to host bogon)
UUID : c63aeb60:7f098351:3ed32a55:e3caca40
Events : 4
Number Major Minor RaidDevice State
0 8 33 0 active sync /dev/sdc1
1 8 49 1 active sync /dev/sdd1
2 8 65 - spare /dev/sde

6、创建一个大小为4G的RAID5设备,chunk大小为256k,格式化ext4文件系统,要求可开机自动挂载至/backup目录,而且不更新访问时间戳,且支持acl功能;

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

主题: LinuxSG4G3G
分页:12
转载请注明
本文标题:22期第七周课堂练习
本站链接:http://www.codesec.net/view/480384.html
分享请点击:


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