网络

教育改变生活

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1718|回复: 0
打印 上一主题 下一主题

[《【证】linux系统管理与服务》] 磁盘和文件系统管理2-LVM逻辑卷管理

[复制链接]

535

主题

562

帖子

4万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
41581

最佳新人活跃会员热心会员推广达人宣传达人灌水之王突出贡献优秀版主荣誉管理论坛元老

跳转到指定楼层
楼主
发表于 2020-4-2 15:45:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
LVM逻辑卷管理
[root@rhel ~]# fdisk -l
Disk /dev/sda: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x0001a205
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      102400   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              13         274     2097152   82  Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3             274        2611    18770944   83  Linux
Disk /dev/sdb: 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: 0x00000000
Disk /dev/sdc: 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: 0x00000000
[root@rhel ~]# pvscan
  No matching physical volumes found
[root@rhel ~]# 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 0xcef106d2.
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-10443, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443): +20000M
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (2552-10443, default 2552):
Using default value 2552
Last cylinder, +cylinders or +size{K,M,G} (2552-10443, default 10443): +20000M
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (5103-10443, default 5103):
Using default value 5103
Last cylinder, +cylinders or +size{K,M,G} (5103-10443, default 10443): +20000M
Command (m for help): p
Disk /dev/sdb: 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: 0xcef106d2
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2551    20490876   83  Linux
/dev/sdb2            2552        5102    20490907+  83  Linux
/dev/sdb3            5103        7653    20490907+  83  Linux
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): p
Disk /dev/sdb: 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: 0xcef106d2
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        2551    20490876   8e  Linux LVM
/dev/sdb2            2552        5102    20490907+  83  Linux
/dev/sdb3            5103        7653    20490907+  83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xee6543e6.
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-10443, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-10443, default 10443): +20000M
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (2552-10443, default 2552):
Using default value 2552
Last cylinder, +cylinders or +size{K,M,G} (2552-10443, default 10443): +20000M
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (5103-10443, default 5103):
Using default value 5103
Last cylinder, +cylinders or +size{K,M,G} (5103-10443, default 10443): +20000M
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): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@rhel ~]# fdisk -l /dev/sdb
Disk /dev/sdb: 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: 0xcef106d2
[root@rhel ~]# partprobe /dev/sdb
[root@rhel ~]# partprobe /dev/sdc
[root@rhel ~]# fdisk -l /dev/sdb /dev/sdc |grep "LVM"
/dev/sdb1               1        2551    20490876   8e  Linux LVM
/dev/sdc1               1        2551    20490876   8e  Linux LVM
[root@rhel ~]# pvcreate /dev/sdb1 /dev/sdc1
  Physical volume "/dev/sdb1" successfully created
  Physical volume "/dev/sdc1" successfully created
[root@rhel ~]# vgcreate mail_store /dev/sdb1 /dev/sdc1
  Volume group "mail_store" successfully created
[root@rhel ~]# pvdisplay /dev/sdb1
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               mail_store
  PV Size               19.54 GiB / not usable 2.62 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              5002
  Free PE               5002
  Allocated PE          0
  PV UUID               3e7KsE-wl5x-s6Jd-P0I4-Zc2g-f8Vs-vOI0SA
   
[root@rhel ~]# vgdisplay mail_store
  --- Volume group ---
  VG Name               mail_store
  System ID            
  Format                lvm2
  Metadata Areas        2
  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                2
  Act PV                2
  VG Size               39.08 GiB
  PE Size               4.00 MiB
  Total PE              10004
  Alloc PE / Size       0 / 0   
  Free  PE / Size       10004 / 39.08 GiB
  VG UUID               34y6G3-U1rO-S1Lq-vd1z-Z1Lq-FKrP-AezHPF
   
[root@rhel ~]# lvcreate -L 10G -n mail mail_store
  Logical volume "mail" created
[root@rhel ~]# lvcreate -L 10G -n benet mail_store
  Logical volume "benet" created
[root@rhel ~]# lvscan
  ACTIVE            '/dev/mail_store/mail' [10.00 GiB] inherit
  ACTIVE            '/dev/mail_store/benet' [10.00 GiB] inherit
[root@rhel ~]# ls /dev/mail_store/mail /dev/mail_store/benet
/dev/mail_store/benet  /dev/mail_store/mail
[root@rhel ~]# ls /dev/ma
mail_store/ mapper/     
[root@rhel ~]# ls /dev/mapper/mail_store-mail /dev/mapper/mail_store-benet
/dev/mapper/mail_store-benet  /dev/mapper/mail_store-mail
[root@rhel ~]# lvdisplay /dev/mapper/mail_store-mail
  --- Logical volume ---
  LV Path                /dev/mail_store/mail
  LV Name                mail
  VG Name                mail_store
  LV UUID                9xOH34-Qrnu-592R-870r-38qA-13On-lwrw8R
  LV Write Access        read/write
  LV Creation host, time rhel.localdomain, 2013-06-07 04:15:14 +0800
  LV Status              available
  # open                 0
  LV Size                10.00 GiB
  Current LE             2560
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
[root@rhel ~]# mkfs -t ext3 /dev/mail_store/mail
mke2fs 1.41.12 (17-May-2010)
\u6587\u4ef6\u7cfb\u7edf\u6807\u7b7e=
\u64cd\u4f5c\u7cfb\u7edfinux
\u5757\u5927\u5c0f=4096 (log=2)
\u5206\u5757\u5927\u5c0f=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
\u7b2c\u4e00\u4e2a\u6570\u636e\u5757=0
Maximum filesystem blocks=2684354560
80 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, 1605632
\u6b63\u5728\u5199\u5165inode\u8868: \u5b8c\u6210                           
Creating journal (32768 blocks): \u5b8c\u6210
Writing superblocks and filesystem accounting information: \u5b8c\u6210
This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@rhel ~]# lvextend -L +5G /dev/mail_store/mail
  Extending logical volume mail to 15.00 GiB
  Logical volume mail successfully resized
[root@rhel ~]# lvdisplay /dev/mail_store/mail
  --- Logical volume ---
  LV Path                /dev/mail_store/mail
  LV Name                mail
  VG Name                mail_store
  LV UUID                9xOH34-Qrnu-592R-870r-38qA-13On-lwrw8R
  LV Write Access        read/write
  LV Creation host, time rhel.localdomain, 2013-06-07 04:15:14 +0800
  LV Status              available
  # open                 0
  LV Size                15.00 GiB
  Current LE             3840
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
   
[root@rhel ~]# resize2fs /dev/mail_store/mail
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mail_store/mail to 3932160 (4k) blocks.
The filesystem on /dev/mail_store/mail is now 3932160 blocks long.
         
[root@rhel ~]# mkdir /mailbox
[root@rhel ~]# mount /dev/mail_store/mail /mailbox/
[root@rhel ~]# df -hT /mailbox/
\u6587\u4ef6\u7cfb\u7edf    \u7c7b\u578b      \u5bb9\u91cf  \u5df2\u7528  \u53ef\u7528 \u5df2\u7528%% \u6302\u8f7d\u70b9
/dev/mapper/mail_store-mail
              ext3     15G  154M   14G   2% /mailbox
[root@rhel ~]#
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

WEB前端

QQ|手机版|小黑屋|金桨网|助学堂  咨询请联系站长。

GMT+8, 2024-12-22 20:00 , Processed in 0.034670 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表