LVM练习题

1、创建一个由两个物理卷组成大小为20G的卷组myvg,要求PE大小16M;而后新建 大小为7 G逻辑卷mylv1,要求其文件系统为ext4,块大小为2048,且开机能自动挂载至/users;


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

[[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 0xa360fa76.

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-6527, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-6527, default 6527): +10G

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 2

First cylinder (1307-6527, default 1307):

Using default value 1307

Last cylinder, +cylinders or +size{K,M,G} (1307-6527, default 6527): +10G

Command (m for help): t

Partition number (1-4): 1

Hex code (type L to list codes): 8e

Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): t

Partition number (1-4): 2

Hex code (type L to list codes): 8e

Changed system type of partition 2 to 8e (Linux LVM)

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[[email protected] ~]# pvcreate myvg /dev/sdb{1,2}

  Device myvg not found (or ignored by filtering).

  Physical volume "/dev/sdb1" successfully created

  Physical volume "/dev/sdb2" successfully created

[[email protected] ~]# vgcreate -s 16MB myvg /dev/sdb{1,2}

  Volume group "myvg" successfully created

[[email protected] ~]# lvcreate -L 7G -n mylv1 myvg

  Logical volume "mylv1" created

[[email protected] ~]# mke2fs -t ext4 -b 2048 /dev/myvg/mylv1

mke2fs 1.43-WIP (20-Jun-2013)

Filesystem label=

OS type: Linux

Block size=2048 (log=1)

Fragment size=2048 (log=1)

Stride=0 blocks, Stripe width=0 blocks

458752 inodes, 3670016 blocks

183500 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=541065216

224 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

Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done

[[email protected] ~]# mkdi

mkdict  mkdir

[[email protected] ~]# mkdir /users

[[email protected] ~]# blkid /dev/myvg/mylv1

/dev/myvg/mylv1: UUID="2cf83771-e51e-4e86-a5a3-53309f13ba32" TYPE="ext4"

[[email protected] ~]# echo ‘/dev/myvg/mylv1 /users ext4 defaults 1 4‘ >> /etc/fstab

[[email protected] ~]# mount -a

[[email protected] ~]# mount

/dev/mapper/vg_demo-lv_root 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/sr0 on /mnt type iso9660 (ro)

none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

/dev/mapper/myvg-mylv1 on /users type ext4 (rw)

[[email protected] ~]# cd /users/

[[email protected] users]# ls

lost+found

2、缩减mylv1至5G大小;确保其数据没有丢失;


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

[[email protected] ~]# ls /users

init.d      rc     rc1.d  rc3.d  rc5.d  rc.local

lost+found  rc0.d  rc2.d  rc4.d  rc6.d  rc.sysinit

[[email protected] ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_demo-lv_root

                       45G  2.8G   40G   7% /

tmpfs                 866M     0  866M   0% /dev/shm

/dev/sda1             477M   64M  385M  15% /boot

/dev/sr0              3.6G  3.6G     0 100% /mnt

/dev/mapper/myvg-mylv1

                      6.9G   12M  6.5G   1% /users

[[email protected] ~]# umount /users

[[email protected] ~]# e2fsck -f /dev/myvg/mylv1

e2fsck 1.43-WIP (20-Jun-2013)

Pass 1: Checking inodes, blocks, and sizes

Pass 2: Checking directory structure

Pass 3: Checking directory connectivity

Pass 4: Checking reference counts

Pass 5: Checking group summary information

/dev/myvg/mylv1: 253/458752 files (0.0% non-contiguous), 96357/3670016 blocks

[[email protected] ~]# resize2fs /dev/myvg/mylv1 5G

resize2fs 1.43-WIP (20-Jun-2013)

Resizing the filesystem on /dev/myvg/mylv1 to 2621440 (2k) blocks.

The filesystem on /dev/myvg/mylv1 is now 2621440 blocks long.

[[email protected] ~]# lvreduce -L 5G /dev/myvg/mylv1

  WARNING: Reducing active logical volume to 5.00 GiB

  THIS MAY DESTROY YOUR DATA (filesystem etc.)

Do you really want to reduce mylv1? [y/n]: y

  Size of logical volume myvg/mylv1 changed from 7.00 GiB (448 extents) to 5.00 GiB (320 extents).

  Logical volume mylv1 successfully resized

[[email protected] ~]# mount /dev/myvg/mylv1 /users

[[email protected] ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_demo-lv_root

                       45G  2.8G   40G   7% /

tmpfs                 866M     0  866M   0% /dev/shm

/dev/sda1             477M   64M  385M  15% /boot

/dev/sr0              3.6G  3.6G     0 100% /mnt

/dev/mapper/myvg-mylv1

                      4.9G   12M  4.6G   1% /users

[[email protected] ~]# ls /users

init.d      rc     rc1.d  rc3.d  rc5.d  rc.local

lost+found  rc0.d  rc2.d  rc4.d  rc6.d  rc.sysinit

4、对mylv1创建快照卷snap-mylv1,并通过其备份数据至/tmp/user.tar.bz2;


1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

[[email protected] ~]# lvcreate -s -L 2G -n mylv1-snap -p r /dev/myvg/mylv1

  Logical volume "mylv1-snap" created

[[email protected] ~]# mount /dev/myvg/mylv1-snap /mnt

mount: block device /dev/mapper/myvg-mylv1--snap is write-protected, mounting read-only

[[email protected] ~]# ls /mnt/

init.d      rc     rc1.d  rc3.d  rc5.d  rc.local

lost+found  rc0.d  rc2.d  rc4.d  rc6.d  rc.sysinit

[[email protected] ~]# tar -jcf /tmp/user.tar.bz2 /mnt/*

tar: Removing leading `/‘ from member names

[[email protected] ~]# ls /tmp/

pulse-iUvjqtKWN6fB  user.tar.bz2  yum.log

[[email protected] ~]# umount /mnt

[[email protected] ~]# 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

来自为知笔记(Wiz)

时间: 2024-11-05 19:38:00

LVM练习题的相关文章

逻辑卷LVM的实现

LVM(logical volume manager ,逻辑卷管理) 可以实现将多块硬盘的分区整合在一起,当做一块硬盘使用,而且LVM 不像传统分区那样,一旦分区完成,分区的大小就不可以再进行调整,包括可以重新设定文件系统的大小,而且允许在多个物理设备间重新组织文件系统. 通过几道练习题来说明LVM的实现 1.创建一个至少有两个PV组成的大小为20G的名为testvg的VG:要求PE大小为16MB, 而后在卷组中创建大小为5G的逻辑卷testlv:挂载至/users目录 2. 新建用户archl

lvm——应用

LVM2: LVM:logical  Volume Manager,Version(版本号):2 逻辑卷管理器的主要作用在于: 与我们前面讲过的软RAID很近似,使用纯软件的方式来组织一个或多个底层硬件设备为一个抽象的逻辑设备使用的一种解决方案.LVM类似于前面讲过的RAID,不过他们的驱动刚好相反,RAID用到的是内核的md模块,而LVM用到的是dm模块, dm:device  mapper 设备映射组件 功能:将一个或多个底层的块设备,组织成一个逻辑设备的模块: 逻辑卷的核心就是dm,dm除

深入剖解linux逻辑卷LVM

一.LVM概念 LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性.通过LVM系统管理员可以轻松管理磁盘分区,如:将若干个磁盘分区连接为一个整块的卷组(volume group),形成一个存储池.管理员可以在卷组上随意创建逻辑卷组(logical volumes),并进一步在逻辑卷组上创建文件系统.管理员通过LVM可以方便的调整存储卷组的大小,并且可以对

RHCE7.0练习题汇总[转]

RHCE7.0练习题汇总38 RHCSA部分 关于密码破解,在上午的考试中需要我们自己安装图形化界面和破解root密码,root的密码按照题目的要求来进行修改.可以使用单用户模式或者使用上课讲的re.break都可以. re.break方法: 删除 console=ttys0,115200n8这句话 在最后加入rd.break 进入交换模式以后输入下列指令: 1 2 3 4 5 mount -o remount,rw /sysroot chroot /sysroot passwd #密码 tou

lvm 2(逻辑卷管理)基础详解

目录 ◆ 什么是逻辑卷(lvm)及其有什么优点 ◆ 逻辑卷的组成和基础概念 ◆逻辑卷原理图 ◆ lvm的实现流程 ◆ 放大lV容量 ◆ 缩小lv容量 ◆ LVM的系统快照 ◆ 练习题 *什么是逻辑卷? LVM是Logical Volume Manager(逻辑卷管理器)的简写.是Linux核心所提供的逻辑卷管理(Logical Volume Management)功能.它在硬盘的硬盘分区之上,又创建了一个逻辑层以方便系统管理硬盘分区系统.LVM的做法是将任何块设备(分区,硬盘,raid)通过软件

02.第一次练习题:磁盘&网络

第一部分:磁盘 一.硬盘主引导记录MBR数据在硬盘的那个位置存放,占用多少个字节?其中boot loader站用多少个字节?分区表占用多少字节(面试)? 硬盘主引导记录MBR数据在硬盘的0柱面.0磁头.1扇区,即主引导扇区(也叫主引导记录MBR). 它由三个部分组成,主引导程序.硬盘分区表DPT(Disk Partition table)和分区有效标志(55AA),占用512个字节:其中boot loader站用446个字节,分区表占用64字节. 二.请写出常见的RAID级别,并阐述期原理(面试

LVM系统快照

上一章写了LVM的创建.扩展.缩小(上一章链接http://bella41981.blog.51cto.com/10603572/1794365).还差一点没弄明白,那就是LVM的快照,有一个小小的弯没有绕过来,今天终于弄明白了,整理出来和大家分享一下. 2.0.LVM快照 添加磁盘 [[email protected] ~]# vgdisplay ---Volume group --- VGName               vbirdvg System ID Format         

Linux Lvm创建详解

Disk管理 LVM(Logical Volume Manager)逻辑卷管理建立在硬盘和分区之上,文件系统之下的逻辑层,能在保持原有数据不变的状况下动态调整磁盘容量/boot分区不能创建在逻辑卷上(跟启动引导相关)必须独立出来 LVM概念  创建时在硬盘头部预留一个块,用于保存LVM属性PV物理卷--->VG卷组--->LV逻辑卷--->格式化--->挂载使用文件系统 2.LVM管理命令功能          物理卷          卷组          逻辑卷scan(扫描

LVM基本应用 扩展及缩减实现

LVM: Logical Volume Manage 首先: pv管理工具:  pvs:简要pv信息显示  pvdisplay:显示pv的详细信息 pvcreate /dev/DEVICE: 创建pv vg管理工具:  vgs  vgdisplay vgcreate  [-s #[kKmMgGtTpPeE]] VolumeGroupName  PhysicalDevicePath [PhysicalDevicePath...]  vgextend  VolumeGroupName  Physic