RH133读书笔记(7)-Lab 7 Advanced Filesystem Mangement
Lab 7 Advanced Filesystem Mangement
Goal: Develop skills and knowlege related to Software RAID, LVM, quota and backup.
Estimated Duration: 120 minutes
Sequence 1: Implementing Quotas
Deliverable: A user diskhog that cannot use more than 1024k of space in /home.
Instructions:
1. Create a user diskhog.
# useradd diskhog
2. Activate user quotas for /home.
a. In /etc/fstab change the mount options for /home to include usrquota. If you do not have a separate /home partition use /.
LABEL=/home /home ext3 defaults,usrquota 1 2
b. Activate the new mount option.
# mount -o remount /home
c. Bring the system into single user mode, to ensure correct quota calculation:
# init 1
d. Run quotacheck -cu /home to create the quota file.
e. Leave single user mode
# init 5
f. Enable Quota enforcing.
# quotaon /home
3. Set the soft block quota of user diskhog to 512 1k blocks and the hard limit to 1024 1k blocks.
# setquota -u diskhog 512 1024 0 0 /home
4. Test the restrictions.
To test these restrictions, run the following commands:
su - diskhog
quota
dd if=/dev/zero of=bigfile bs=1k count=400
quota
(Should work fine.)
dd if=/dev/zero of=bigfile bs=1k count=800
quota
(Should issue a warning.)
dd if=/dev/zero of=bigfile bs=1k count=1600
quota
(Should fail to write the whole file.)
Sequence 2: Software RAID
Deliverable: A system with two RAID1 devices with two partitions each.
Instructions:
1. This lab assumes that the computers are only equipped with one hard drive. Setting up RAID on a single disk obviously does not provide any kind of fault protection.
Create four additional partitions with at least 100MB each. The partition type should be set to “Linux raid auto”.
a. Use fdisk to create four logical partitions
b. Set the Partition Type (T) to fd
c. Save and exit fdisk
2. Make sure that the kernel uses the new partition table.
# partprobe
3. Use mdadm to create two RAID 1 devices, with two partitions each. These devices should be /dev/md0 and /dev/md1. Create a filesystem on the first device.
Note: Adjust the partition numbers to match your system.
# mdadm -C /dev/md0 -a yes -l 1 -n 2 /dev/sda{6,7}
# mdadm -C /dev/md1 -a yes -l 1 -n 2 /dev/sda{8,9}
# mkfs.ext3 /dev/md0
4. Mount the filesystem under /data and put some files on it.
# mkdir /data
# mount /dev/md0 /data
Note: Do NOT put it in fstab yet.
# cp -a /lib /data
5. Get a printout of the current RAID configuration.
# mdadm --detail /dev/md0
6. It is now time to simulate a disk failure. Use mdadm --fail to mark one of your partitions as faulty. Use mdadm --remove to remove this partition from the RAID array. Check /proc/mdstat and /var/log/messages to see how the system reacts to this error.
Note: The device names in this example might differ from your setup
# mdadm --fail /dev/md0 /dev/sda7
# cat /proc/mdstat
# mdadm --remove /dev/md0 /dev/sda7
Re-add the partition to the RAID device with mdadm --add.
7. If this had been a real hard disk error, you would have to replace the broken disk and repartition it. Since our partition was never really damaged we can skip this part and re-add the partition to the RAID device with mdadm --add. After you re-add the partition, note the content of /proc/mdstat.
# mdadm -a /dev/md0 /dev/sda7
# cat /proc/mdstat
Sequence 3: Creating Logical Volumes with LVM
Deliverable: A volume group that uses one of the RAID1 devices as a physical volume and has one logical volume.
Instructions:
1. Unmount the filesystem from the last exercise and convert your first RAID device (/dev/md0) into a physical volume.
# umount /dev/md0
# pvcreate /dev/md0
2. Create a volume group named volgroup with the default extent size of 4MiB, which uses the physical volume that was just created.
# vgcreate volgroup /dev/md0
3. Create a logical volume named data , that uses all available extents. Create a filesystem on it and make sure that this filesystem is mounted to /data during boot.
Note: LVM caches device information. Due to this cache new volume groups are ignored during boot. Delete /etc/lvm/.cache, so that LVM rescans the system for volume groups.
a. Use vgdisplay to find out how many extents are available.
# vgdisplay volgroup
b. Create the logical volume with all available extents.
Replace the word "free_extents" below with the number of free extents you found when running vgdisplay not the word "free_extents"
# lvcreate -n data -l free_extents volgroup
c. # mkfs.ext3 /dev/volgroup/data
d. Edit /etc/fstab so that /data will be mounted automatically.
/dev/volgroup/data /data ext3 defaults 1 2
e. Run mount -a to mount and check for errors.
f. Delete the LVM devices cache to ensure that the new volume group is detected during boot.
# rm /etc/lvm/.cache
g. Reboot to verify that the filesystem is automatically mounted.
Sequence 4: Extending a filesystem
Deliverable: An LVM that uses both RAID1 devices as physical volumes and has one increased logical volume.
Instructions:
1. Add the second RAID device to your volume group.
# pvcreate /dev/md1
# vgextend volgroup /dev/md1
2. Increase the data logical volume and filesystem by 40MiB.
# lvextend -L +40M /dev/volgroup/data
# resize2fs -p /dev/volgroup/data
# df -h
Challenge Sequence 5: Reducing a filesystem
Deliverable: The existing logical volume is reduced by 100MiB.
Instructions:
1. To reduce the volume the filesystem has to be reduced first. Reduce the filesystem and the logical volume by 100MiB.
a. First you need to determine the current filesystem size. This can be done with df -h
b. The filesystem has to be umounted before reducing
# umount /data
c. Make sure that the filesystem is in a consistent state before reducing.
# fsck -f /dev/volgroup/data
d. Now reduce the filesystem by 100MiB. This example assumes that the original size was 140MiB.
# resize2fs /dev/volgroup/data 40M
e. It is now possible to reduce the logical volume. Be careful with this command. Wrong parameters can render your filesystem unusable.
# lvreduce /dev/volgroup/data -L 40M
f. Verify the new size, by mounting the filesystem and running df -h
Challenge Sequence 6: Backing a Logical Volume with Snapshots
Deliverable: Take a backup from an active Logical Volume by using an LVM snapshot and dump. Destroy the data on the Logical Volume and recover from the backup.
System Setup: Confirm that the Logical Volume /dev/volgroup/data from an earlier lab is mounted on /data and configured in /etc/fstab.
Instructions:
1. Copy the contents of the /var/log directory into /data. View the contents of /data.
# cp -r /var/log/* /data/
# ls /data/
2. Create a read-only Snapshot Volume of /dev/volgroup/data called data-backup, allocate 16MB of space to the Snapshot.
# lvcreate -L 16M -p r -s -n data-backup /dev/volgroup/data
3. Mount /dev/volgroup/data-backup read-only as /mnt/data-backup and view it's contents.
# mkdir /mnt/data-backup
# mount -o ro /dev/volgroup/data-backup /mnt/data-backup
4. Use dump to backup /mnt/data-backup to a file named /tmp/databackup.dump. Confirm that the backup file was created.
# dump -0u -f /tmp/data-backup.dump /mnt/data-backup
# ls -la /tmp/data-backup.dump
5. Unmount /mnt/data-backup and remove the snapshot volume.
# umount /mnt/data-backup
# lvremove /dev/volgroup/data-backup
6. Unmount /data create a new filesystem on /dev/volgroup/data. Remount /data and confirm that it only contains the lost+found directory.
# umount /data
# mkfs.ext3 /dev/volgroup/data
# mount /data
# ls /data
7. Use dump to recover the lost contents of /data from the backup. Check the contents of the directory.
# cd /data
# restore -rf /tmp/data-backup.dump
# ls
RH133读书笔记(7)-Lab 7 Advanced Filesystem Mangement的更多相关文章
- RH133读书笔记(6) - Lab 6 Adding New Filesystems to the Filesystem Tree
Lab 6 Adding New Filesystems to the Filesystem Tree Goal: Develop skills and knowlege related to par ...
- RH133读书 笔记(5) - Lab 5 User and Group Administration
Lab 5 User and Group Administration Goal: To build skills for user and group administration. Estimat ...
- RH133读书 笔记(3) - Lab 3 Configuring the kernel
Lab 3 Configuring the kernel Goal: Develop skills tuning the /proc filesystem. Gain some experience ...
- RH133读书笔记(9)-Lab 9 Installation and System-Initialization
Lab 9 Installation and System-Initialization Goal: Successfully install Red Hat Enterprise Linux. Sy ...
- RH133读书笔记(11)-Lab 11 System Rescue and Troubleshooting
Lab 11 System Rescue and Troubleshooting Goal: To build skills in system rescue procedures. Estimate ...
- RH133读书笔记(1)-Lab 1 Managing Startup
Lab 1 Managing Startup Goal: To familiarize yourself with the startup process System Setup: A system ...
- RH133读书笔记(2)-Lab 2 Working with packages
Lab 2 Working with packages Goal: To gain working experience with package management System Setup: A ...
- RH133读书 笔记(4) - Lab 4 System Services
Lab 4 System Services Goal: Develop skills using system administration tools and setting up and admi ...
- RH133读书笔记(8)-Lab 8 Manage Network Settings
Lab 8 Manage Network Settings Goal: To build skills needed to manually configure networking Estimate ...
随机推荐
- Android 通过调用系统,如接口 谷歌语音、百度语音、科大讯飞语音等语音识别方法对话框
现在app在发展过程中会集成一些语音识别功能,不具有其自己的显影剂一般正在开发的语音识别引擎,所以在大多数情况下,它是选择一个成熟的语音识别引擎SDK集成到他们的app在. 平时,这种整合被分成两个, ...
- [WPF] 使用Grid与GridSplitter排版布局
原文:[WPF] 使用Grid与GridSplitter排版布局 前言 在開發應用程式時,一個很重要的工作項目就是設計使用者介面的排版布局.WPF中所提供的Grid控制項,讓開發人員擁有將版面分割為欄 ...
- WPF疑难杂症会诊
原文:WPF疑难杂症会诊 为什么图片像素是模糊的? 容器边框设为非整数时,其内容中的像素图片会产生模糊,即使设置SnapsToDevicePixels="True"也无效. 以下是 ...
- Audio Offload
Audio Offload 音频分载,是系统将音频分载到声卡硬件进行分载处理的功能.从Windows 8开始,音频的硬件加速和分载处理又回来了.为什么说又回来了呢? 因为声卡自创通公司发明开始,相当长 ...
- SSH协议详解(转)
转发的http://blog.csdn.net/macrossdzh/article/details/5691924 很透彻啊,学习了 一.什么是SSH SSH是英文Secure Shell的简写形式 ...
- cocos2d-x环境搭建(win7+cocos2d-x-3.0)
一.环境需准备的材料: 1.VS2012,下载地址:官网 2.cocos2d-x和cocostudio,下载地址:官网 3.eclispe,我用的是:adt-bundle-windows-x86_64 ...
- hdu5338 (二进制,双指针)
这种双循环的优化问题碰到过很多了.层出不穷. 但无非就是要利用前面循环时,所产生的信息,从而减少计算. 可以注意到log其实是不超过40的, 那么以这方面入手,时间复杂度就可以降为nlogn log= ...
- 【ECSHOP插件】商品颜色尺寸仿淘宝选择功能免费发布
先放效果图,如此实用的功能是不是迫不及待的要添加到自己的网店中了呢 牵涉到的修改文件(default模板为例) /themes/default/style.css /themes/default/ ...
- poj Optimal Milking
Optimal Milking 题目: 有K个机器.C仅仅牛.要求求出最全部牛到各个产奶机的最短距离.给出一个C+K的矩阵,表示各种标号间的距离. 而每一个地方最多有M仅仅牛. 算法分析: 二分+最短 ...
- NSPredicate的用法
一般来说这种情况还是蛮多的,比如你从文件中读入了一个array1,然后想把程序中的一个array2中符合array1中内容的元素过滤出来. 正 常傻瓜一点就是两个for循环,一个一个进行比较,这样效率 ...