1、创建一个10G分区,并格式为ext4文件系统;
(1) 要求其block大小为2048, 预留空间百分比为2, 卷标为MYDATA, 默认挂载属性包含acl;
(2) 挂载至/data/mydata目录,要求挂载时禁止程序自动运行,且不更新文件的访问时间戳;
在扩展分区/dev/sda4下新建一个10G的分区/dev/sda5:
~]# fdisk /dev/sda 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 First cylinder (4242-8158, default 4242): Using default value 4242 Last cylinder, +cylinders or +size{K,M,G} (4242-8158, default 8158): +10G
强制内核重读磁盘分区信息并确认新分区创建成功:
~]# partx -a /dev/sda ~]# cat /proc/partitions major minor #blocks name 8 0 83886080 sda 8 1 512000 sda1 8 2 31457280 sda2 8 3 2097152 sda3 8 4 1 sda4 8 5 10488790 sda5
将此分区按要求创建为ext4文件系统:
~]# mke2fs -t ext4 -b 2048 -L MYDATA -m 2 /dev/sda5 ~]# tune2fs -o acl /dev/sda5 tune2fs 1.41.12 (17-May-2010)
在指定的目录下按要求挂载此分区:
[root@CentOS6 ~]# mount -o noexec -o noatime /dev/sda5 /data/mydata/ [root@CentOS6 ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 1.5G 27G 6% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 477M 31M 421M 7% /boot /dev/sda5 9.8G 13M 9.6G 1% /data/mydata
2、创建一个大小为1G的swap分区,并创建好文件系统,并启用之;
在扩展分区/dev/sda4下新建一个1G的分区/dev/sda6并修改类型为SWAP:
Command (m for help): n First cylinder (5548-8158, default 5548): Using default value 5548 Last cylinder, +cylinders or +size{K,M,G} (5548-8158, default 8158): +1G Command (m for help): t Partition number (1-6): 6 Hex code (type L to list codes): 82 Changed system type of partition 6 to 82 (Linux swap / Solaris) Command (m for help): p Disk /dev/sda: 85.9 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 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: 0x000cfe14 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 3981 31457280 83 Linux /dev/sda3 3981 4242 2097152 82 Linux swap / Solaris /dev/sda4 4242 8158 31461679 5 Extended /dev/sda5 4242 5547 10488790 83 Linux /dev/sda6 5548 5679 1060258+ 82 Linux swap / Solaris
强制内核重读磁盘分区信息并确认新分区创建成功:
~]# partx -a /dev/sda ~]# cat /proc/partitions major minor #blocks name major minor #blocks name 8 0 83886080 sda 8 1 512000 sda1 8 2 31457280 sda2 8 3 2097152 sda3 8 4 1 sda4 8 5 10488790 sda5 8 6 1060258 sda6
将此分区按要求创建为SWAP文件系统并挂载启用:
~]# mkswap -L SWAP2 /dev/sda6 Setting up swapspace version 1, size = 1060252 KiB LABEL=SWAP2, UUID=ee1b3009-e8aa-4a2d-8200-dd91b78a89aa
先查看本机目前的SWAP分区大小为2G:
~]# free -m total used free shared buffers cached Mem: 980 119 860 0 8 34 -/+ buffers/cache: 76 903 Swap: 2047 0 2047
挂载新SWAP分区后再验证本机的SWAP分区大小为3G:
~]# swapon /dev/sda6 ~]# free -m total used free shared buffers cached Mem: 980 120 860 0 8 34 -/+ buffers/cache: 77 903 Swap: 3083 0 3083
3、写一个脚本
(1)、获取并列出当前系统上的所有磁盘设备;
(2)、显示每个磁盘设备上每个分区相关的空间使用信息;
``` #!/bin/bash # fdisk -l /dev/[sh]d[a-z] | grep -o "Disk /dev/[sh]d[a-z]" echo fdisk -l ```
4、总结RAID的各个级别及其组合方式和性能的不同;
RAID称为独立(廉价)冗余磁盘阵列。是最初由伯克利大学提出的一种将多块廉价的单块硬盘按某种标准组合起来作为一块硬盘来使用的解决方案。RAID的优点是能够提高磁盘的I/O能力和冗余(恢复)能力。
RAID根据磁盘组合方式的不同分为多个RAID级别,常用的级别有RAID-0,RAID-1,RAID-,5,RAID-10,RAID-50,JBOD。
RAID-0: 又称为条带卷
RAID-0模式下,RAID控制会将每一个数据文件分为一个个小的数据块,称chunk。然后平均分配将chunk分别存储到各个磁盘上。如此一来,RAID-0的整体IO能力
比单块磁盘提高了N倍(N为组成RAID-0的磁盘数量),但RAID-0没有任何冗余能力,一旦一块磁盘损坏,所有数据都会丢失,故RAID-0只能用于存放临时数据或不重要的文件,不能用于生产环境。
性能总结:IO能力提高N倍,无冗余能力,磁盘数量大于等于两块,最大存储空间为N*MIn{disk1,2,3…}
RAID-1:又称为镜像卷
RAID-1模式下,RAID控制会将每一个数据文件分为一个个小的数据块,称为chunk。然后每一个chunk在各个磁盘上都会被存储一份。如此一来, RAID-1的写性能大大减少,因为每一个数据块原来只需要写一遍,现在要写N遍,但读性能却大大提高,因为读取数据时可以从各个磁盘中同时读取,同时,RAID-1具有很强的数据恢复能力,一块磁盘的损坏不会丢失数据。
性能总结:写性能下降,读性能上升,冗余能力强,磁盘数量大于等于两块,最大存储空间Min{disk1,2,3,…}
RAID-5:
RAID-5至少由3块以上磁盘构成,每次存储数据时,轮流拿出一块磁盘存储校验码。校验码的作用是如果有一块磁盘损坏,可以根据其他几块磁盘上的数据和校验码恢复出完整数据,但此时称为RAID-5工作于降级模式,必须马上修复损坏的磁盘。RAID-5存储一个数据的过程如下:假设RAID-5由3块磁盘组成。存储一个数据,RAID控制器将数据分为6个chunk,第一次,存储chunk1,chunk2于磁盘1,2,磁盘3存放校验码。第二次,存储chunk3,chunk4于于磁盘1,3,磁盘2存放校验码。第三次,存储chunk5,chunk6于磁盘2,3,磁盘1存放校验码。
性能总结:读写性能提升,有1块磁盘的冗余能力,磁盘数量大于等于两块,最大存储空间(N-1)*Min{disk1,2,3….}
混合类型:
RAID-10
假设RAID-10由10块磁盘组成。先两两组合构成RAID-1,然后再将5组磁盘构成RAID-0。RAID-10是目前比较理想的RAID模型。RAID-10有一块磁盘的冗余能力,读写能力也有提升。
性能总结:读写性能提升,有冗余能力(各镜像中允许损坏一块磁盘),磁盘数量大于等于4块,最大存储空间min{disk1,2,3,4…}*N/2
RAID-50
先组合出几个RAID-5,然后将几个RAID-5组按照RAID-0组成。也是一种比较理想的RAID模型。
性能总结:读写性能提升,有冗余能力(损坏一块磁盘工作于降级模式),磁盘数量大于等于6块
JBOD:Just a Bunch Of Disks
功能:将多块磁盘的空间合并一个大的连续空间使用;
可用空间:sum(S1,S2,…)
用于存放一个超大的数据文件。
RAID的配置实现是通过RAID控制器在安装硬盘时在BIOS上完成的。但我们也可以用软件来模拟个RAID级别的实现。
5、创建一个大小为10G的RAID1,要求有一个空闲盘,而且CHUNK大小为128k;
在扩展分区/dev/sda4下新建3个逻辑分区,每个为10G,并将分区类型改为fd:
Command (m for help): p Disk /dev/sda: 85.9 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 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: 0x000cfe14 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 3981 31457280 83 Linux /dev/sda3 3981 4242 2097152 82 Linux swap / Solaris /dev/sda4 4242 8158 31461679 5 Extended /dev/sda5 4242 5417 9444565 fd Linux raid autodetect /dev/sda6 5418 6593 9446188+ fd Linux raid autodetect /dev/sda7 6594 7769 9446188+ fd Linux raid autodetect
用两个分区创建RAID-1,另一个作为空闲分区:
~]# mdadm -C /dev/md0 -n 2 -l 1 -a yes -c 128 -x 1 /dev/sda{5,6,7} ~]# cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sda7[2](S) sda6[1] sda5[0] 9436352 blocks super 1.2 [2/2] [UU] unused devices: <none>
6、创建一个大小为4G的RAID5设备,chunk大小为256k,格式化ext4文件系统,要求可开机自动挂载至/backup目录,而且不更新访问时间戳,且支持acl功能;
在扩展分区/dev/sda4下新建3个逻辑分区,每个为2G,并将分区类型改为fd:
Command (m for help): p Disk /dev/sda: 85.9 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 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: 0x000cfe14 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 3981 31457280 83 Linux /dev/sda3 3981 4242 2097152 82 Linux swap / Solaris /dev/sda4 4242 8158 31461679 5 Extended /dev/sda5 4242 4503 2102860 fd Linux raid autodetect /dev/sda6 4504 4765 2104483+ fd Linux raid autodetect /dev/sda7 4766 5027 2104483+ fd Linux raid autodetect
创建为RAID-5:
~]# mdadm -C /dev/md0 -n 3 -l 5 -a yes -c 256 /dev/sda{5,6,7} ~]# cat /proc/mdstat Personalities : [raid6] [raid5] [raid4] md0 : active raid5 sda7[3] sda6[1] sda5[0] 4201472 blocks super 1.2 level 5, 256k chunk, algorithm 2 [3/3] [UUU] unused devices: <none>
格式化为ext4文件系统:
~]# mkfs.ext4 /dev/md0 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=64 blocks, Stripe width=128 blocks 262944 inodes, 1050368 blocks 52518 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=1077936128 33 block groups 32768 blocks per group, 32768 fragments per group 7968 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 正在写入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 34 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
编辑/etc/fstab文件使/dev/md0能够开机自动挂载:
~]# tail -n 1 /etc/fstab UUID=2165b6ca-78fa-403e-bd9b-3ea1092b6811 /data/mydata ext4 defaults,acl,noatime 0 0 ~]# reboot ~]# mount /dev/sda2 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) /dev/sda1 on /boot type ext4 (rw) /dev/md127 on /data/mydata type ext4 (rw,noatime,acl) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
7、写一个脚本
(1) 接受一个以上文件路径作为参数;
(2) 显示每个文件拥有的行数;
(3) 总结说明本次共为几个文件统计了其行数;
``` #!/bin/bash # for i in $*;do line_num=$(wc -l $i | cut -d" " -f1) echo "$i has $line_num lines." done echo echo "we count $# files's line number this time." ```
8、写一个脚本
(1) 传递两个以上字符串当作用户名;
(2) 创建这些用户;且密码同用户名;
(3) 总结说明共创建了几个用户;
``` #!/bin/bash # if [ $# -le 2 ];then echo "Please enter two more user_id." && exit 2 fi for i in $*;do useradd $i echo $i | passwd --stdin $i done echo echo "we add $# users this time." ```
9、写一个脚本,新建20个用户,visitor1-visitor20;计算他们的ID之和;
``` #!/bin/bash # declare -i num=0 for i in `seq 20`;do useradd visitor$i id=$(id -u visitor$i) num=$[$num+$id] done echo "The id_sum of these twenty users are $num." ```
10、写一脚本,分别统计/etc/rc.d/rc.sysinit、/etc/rc.d/init.d/functions和/etc/fstab文件中以#号开头的行数之和,以及总的空白行数;
``` #!/bin/bash # declare -i count1=0 declare -i count2=0 for i in /etc/{fstab,rc.d/{rc.sysinit,init.d/functions}};do count1=$[$(grep "^#" $i | wc -l) + $count1] count2=$[$(grep "^[[:space:]]*$" $i | wc -l) + $count2] done echo "$count1 lines start with # and $count2 blank lines in {/etc/rc.d/init.d/functions,/etc/fstab,/etc/rc.d/rc.sysinit " ```
11、写一个脚本,显示当前系统上所有默认shell为bash的用户的用户名、UID以及此类所有用户的UID之和;
``` #!/bin/bash # declare -i num=0 cat /etc/passwd | grep "bash$" | cut -d: -f1,3 echo for i in `cat /etc/passwd | grep "bash$" | cut -d: -f1,3 | cut -d: -f2`;do num=$[$num+$i] done echo "The id_sum of these users are $num." ```
12、写一个脚本,显示当前系统上所有,拥有附加组的用户的用户名;并说明共有多少个此类用户;
``` #!/bin/bash # declare -i count=0 for i in `cat /etc/passwd | cut -d: -f1`;do group_num=$(id $i -G | wc -w) if [ $group_num -gt 1 ];then echo "user $i has appand group." let count++ fi done ```
13、创建一个由至少两个物理卷组成的大小为20G的卷组VG;要求,PE大小为8M;而在卷组中创建一个大小为5G的逻辑卷mylv1,格式化为ext4文件系统,开机自动挂载至/users目录,支持acl;
先在扩展分区/dev/sda4划出3个逻辑分区/dev/sda5,/dev/sda6,/dev/sda7作为底层块设备PV,分区类型改为8e并创建为PV:
Command (m for help): p Disk /dev/sda: 85.9 GB, 85899345920 bytes 255 heads, 63 sectors/track, 10443 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: 0x000cfe14 Device Boot Start End Blocks Id System /dev/sda1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 64 3981 31457280 83 Linux /dev/sda3 3981 4242 2097152 82 Linux swap / Solaris /dev/sda4 4243 9465 41953747+ 5 Extended /dev/sda5 4243 5548 10490413+ 8e Linux LVM /dev/sda6 5549 6332 6297448+ 8e Linux LVM /dev/sda7 6333 6855 4200966 8e Linux LVM [root@CentOS6 ~]# pvcreate /dev/sda{5,6,7} Physical volume "/dev/sda5" successfully created Physical volume "/dev/sda6" successfully created Physical volume "/dev/sda7" successfully created [root@CentOS6 ~]# pvs PV VG Fmt Attr PSize PFree /dev/sda5 lvm2 ---- 10.00g 10.00g /dev/sda6 lvm2 ---- 6.01g 6.01g /dev/sda7 lvm2 ---- 4.01g 4.01g
用已有的三个PV组成一个VG,PE大小为8M:
[root@CentOS6 ~]# vgs [root@CentOS6 ~]# vgcreate -s 8M myvg /dev/sda{5,6,7} Volume group "myvg" successfully created [root@CentOS6 ~]# vgdisplay --- Volume group --- VG Name myvg System ID Format lvm2 Metadata Areas 3 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 3 Act PV 3 VG Size 20.00 GiB PE Size 8.00 MiB Total PE 2560 Alloc PE / Size 0 / 0 Free PE / Size 2560 / 20.00 GiB VG UUID GAca2m-HW4Q-zgIn-9ve2-vbx7-QNTh-EQ5lNx
在myvg中创建逻辑卷LV为5G的mylv1:
[root@CentOS6 ~]# lvs [root@CentOS6 ~]# lvcreate -L 5G -n mylv1 myvg Logical volume "mylv1" created. [root@CentOS6 ~]# lvdisplay --- Logical volume --- LV Path /dev/myvg/mylv1 LV Name mylv1 VG Name myvg LV UUID 0Bdi7m-GBja-lkOl-vipn-jTIy-fkcR-b8yzyr LV Write Access read/write LV Creation host, time CentOS6.8, 2016-10-24 11:26:50 +0800 LV Status available # open 0 LV Size 5.00 GiB Current LE 640 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
对可用分区mylv1格式化并设置开机自动挂载:
[root@CentOS6 ~]# mkfs.ext4 /dev/myvg/mylv1 mke2fs 1.41.12 (17-May-2010) 文件系统标签= 操作系统:Linux 块大小=4096 (log=2) 分块大小=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 327680 inodes, 1310720 blocks 65536 blocks (5.00%) reserved for the super user 第一个数据块=0 Maximum filesystem blocks=1342177280 40 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 正在写入inode表: 完成 Creating journal (32768 blocks): 完成 Writing superblocks and filesystem accounting information: 完成 This filesystem will be automatically checked every 25 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@CentOS6 ~]# tail -n 1 /etc/fstab UUID=29f0e9b2-30a8-49e4-af12-bf5689c291fa /users ext4 defaults,acl 0 0
14、新建用户magedu;其家目录为/users/magedu,而后su切换至此用户,复制多个文件至家目录;
确保/dev/myvg/mylv1挂载已完成:
[root@CentOS6 ~]# reboot [root@CentOS6 ~]# cd /users/ [root@CentOS6 users]# ls lost+found [root@CentOS6 users]# mount /dev/sda2 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) /dev/sda1 on /boot type ext4 (rw) /dev/mapper/myvg-mylv1 on /users type ext4 (rw,acl) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
[root@CentOS6 ~]# useradd -d /users/magedu magedu [root@CentOS6 magedu]# su - magedu [magedu@CentOS6 ~]$ pwd /users/magedu [magedu@CentOS6 ~]$ cp /etc/resolv.conf /etc/httpd/conf/httpd.conf /etc/sysconfig/network-scripts/ifcfg-eth0 . [magedu@CentOS6 ~]$ ls httpd.conf ifcfg-eth0 resolv.conf
15、扩展mylv1至9G,确保扩展完成后原有数据完全可用;
[root@CentOS6 ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 1.5G 27G 6% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 477M 31M 421M 7% /boot /dev/mapper/myvg-mylv1 4.8G 11M 4.6G 1% /users [root@CentOS6 ~]# lvextend -L 9G /dev/myvg/mylv1 Size of logical volume myvg/mylv1 changed from 5.00 GiB (640 extents) to 9.00 GiB (1152 extents). Logical volume mylv1 successfully resized.
扩展文件系统边界适应lv的扩展
[root@CentOS6 ~]# resize2fs /dev/myvg/mylv1 resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/myvg/mylv1 is mounted on /users; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/myvg/mylv1 to 2359296 (4k) blocks. The filesystem on /dev/myvg/mylv1 is now 2359296 blocks long. [root@CentOS6 ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 1.5G 27G 6% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 477M 31M 421M 7% /boot /dev/mapper/myvg-mylv1 8.8G 12M 8.3G 1% /users
16、缩减mylv1至7G,确保缩减完成后原有数据完全可用;
不能联机缩减,要先卸载
[root@CentOS6 ~]# umount /dev/myvg/mylv1
强制检测文件系统并先缩减文件系统的大小
[root@CentOS6 ~]# e2fsck -f /dev/myvg/mylv1 e2fsck 1.41.12 (17-May-2010) 第一步: 检查inode,块,和大小 第二步: 检查目录结构 第3步: 检查目录连接性 Pass 4: Checking reference counts 第5步: 检查簇概要信息 /dev/myvg/mylv1: 23/589824 files (0.0% non-contiguous), 72691/2359296 blocks [root@CentOS6 ~]# resize2fs /dev/myvg/mylv1 7G resize2fs 1.41.12 (17-May-2010) Resizing the filesystem on /dev/myvg/mylv1 to 1835008 (4k) blocks. The filesystem on /dev/myvg/mylv1 is now 1835008 blocks long.
缩小lv的大小并重新挂载
[root@CentOS6 ~]# lvreduce -L 7G /dev/myvg/mylv1 WARNING: Reducing active logical volume to 7.00 GiB. THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce myvg/mylv1? [y/n]: y Size of logical volume myvg/mylv1 changed from 9.00 GiB (1152 extents) to 7.00 GiB (896 extents). Logical volume mylv1 successfully resized. [root@CentOS6 ~]# mount /dev/myvg/mylv1 /users [root@CentOS6 ~]# df -lh Filesystem Size Used Avail Use% Mounted on /dev/sda2 30G 1.5G 27G 6% / tmpfs 491M 0 491M 0% /dev/shm /dev/sda1 477M 31M 421M 7% /boot /dev/mapper/myvg-mylv1 6.8G 12M 6.5G 1% /users
确保文件没有损坏
[root@CentOS6 ~]# cd /users/magedu/ [root@CentOS6 magedu]# cat resolv.conf # Generated by NetworkManager nameserver 192.168.1.1
17、对mylv1创建快照,并通过备份数据;要求保留原有的属主属组等信息;
快照卷和原卷必须在同一个VG上:
[root@CentOS6 ~]# lvcreate -L 20M -s -p r -n mylv1-snap /dev/myvg/mylv1 Rounding up size to full physical extent 24.00 MiB Logical volume "mylv1-snap" created. [root@CentOS6 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv1 myvg owi-aos--- 7.00g mylv1-snap myvg sri-a-s--- 24.00m mylv1 0.05
挂载快照卷并查看:
[root@CentOS6 ~]# mount /dev/myvg/mylv1-snap /mnt mount: block device /dev/mapper/myvg-mylv1--snap is write-protected, mounting read-only [root@CentOS6 ~]# cd /mnt/ [root@CentOS6 mnt]# ls lost+found magedu [root@CentOS6 mnt]# cd magedu/ [root@CentOS6 magedu]# ls httpd.conf ifcfg-eth0 resolv.conf [root@CentOS6 magedu]# cat resolv.conf # Generated by NetworkManager nameserver 192.168.1.1
对原卷中的文件进行修改,快照卷中的文件不会发生改变:
[root@CentOS6 magedu]# cd /users/magedu/ [root@CentOS6 magedu]# ls httpd.conf ifcfg-eth0 resolv.conf [root@CentOS6 magedu]# vim resolv.conf [root@CentOS6 magedu]# cd /mnt/ [root@CentOS6 mnt]# ls lost+found magedu [root@CentOS6 mnt]# cd magedu/ [root@CentOS6 magedu]# cat resolv.conf # Generated by NetworkManager nameserver 192.168.1.1
不需要快照卷后,可以删除这个snap-lv:
[root@CentOS6 ~]# umount /mnt [root@CentOS6 ~]# lvremove /dev/myvg/mylv1-snap Do you really want to remove active logical volume mylv1-snap? [y/n]: y Logical volume "mylv1-snap" successfully removed [root@CentOS6 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert mylv1 myvg -wi-ao---- 7.00g
原创文章,作者:上海-brown,如若转载,请注明出处:http://www.178linux.com/54120