八亿电脑网
游戏盒子
当前位置: 首页 > 八亿电脑 > 电脑知识 >

Linux如何创建使用逻辑卷管理LVM(2)

时间:2015-03-01 21:23来源:网络 作者:win8e 点击:
游戏盒子

  LV Name test

  VG Name myvg

  LV UUID wY1YUF-f0o6-jzu1-mtTL-64p0-qvfC-3QfF8y

  LV Write Access read/write

  LV Creation host, time station106.magelinux.com, 2014-02-10 11:18:43 +0800

  LV Status available

  # open 1

  LV Size 15.00 GiB

  Current LE 3840

  Segments 2

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:4

  当扩展完物理边界后你会发现,挂载中的逻辑卷还是本身的大小。

  [root@station106 ~]# df -hT

  Filesystem Type Size Used Avail Use% Mounted on

  /dev/mapper/vg0-root

  ext4 20G 387M 19G 3% /

  tmpfs tmpfs 242M 0 242M 0% /dev/shm

  /dev/sda1 ext4 194M 29M 156M 16% /boot

  /dev/mapper/vg0-usr

  ext4 9.9G 1.9G 7.6G 20% /usr

  /dev/mapper/vg0-var

  ext4 20G 288M 19G 2% /var

  /dev/mapper/myvg-test

  ext4 9.9G 151M 9.2G 2% /mnt

  扩展逻辑边界,逻辑边界指的是挂载后,在使用中的逻辑卷也直接识别了。

  [root@station106 ~]# resize2fs /dev/myvg/test

  resize2fs 1.41.12 (17-May-2010)

  Filesystem at /dev/myvg/test is mounted on /mnt; on-line resizing required

  old desc_blocks = 1, new_desc_blocks = 1

  Performing an on-line resize of /dev/myvg/test to 3932160 (4k) blocks.

  The filesystem on /dev/myvg/test is now 3932160 blocks long.

  [root@station106 ~]# df -hT

  Filesystem Type Size Used Avail Use% Mounted on

  /dev/mapper/vg0-root

  ext4 20G 387M 19G 3% /

  tmpfs tmpfs 242M 0 242M 0% /dev/shm

  /dev/sda1 ext4 194M 29M 156M 16% /boot

  /dev/mapper/vg0-usr

  ext4 9.9G 1.9G 7.6G 20% /usr

  /dev/mapper/vg0-var

  ext4 20G 288M 19G 2% /var

  /dev/mapper/myvg-test

  ext4 15G 153M 14G 2% /mnt

  上述就是扩展逻辑卷部分。

  实例演示:缩小逻辑卷。首先为了测试我去原先挂载的录下创建一些文件,测试一下缩小后会不会导致文件消失。

  缩小逻辑卷的步骤如下:

  1)先卸载之前的挂载,并执行强制检测。

  [root@station106 ~]# umount /mnt/

  [root@station106 ~]# e2fsck -f /dev/myvg/test

  e2fsck 1.41.12 (17-May-2010)

  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/test: 13/983040 files (0.0% non-contiguous), 100864/3932160 blocks

  2)缩减逻辑边界。

  [root@station106 ~]# resize2fs /dev/myvg/test 10G

  resize2fs 1.41.12 (17-May-2010)

  Resizing the filesystem on /dev/myvg/test to 2621440 (4k) blocks.

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

  3)缩减物理边界。

  [root@station106 ~]# lvreduce -L 10G /dev/myvg/test

  WARNING: Reducing active logical volume to 10.00 GiB

  THIS MAY DESTROY YOUR DATA (filesystem etc.)

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

  Reducing logical volume test to 10.00 GiB

  Logical volume test successfully resized

  缩减后查看:

  [root@station106 ~]# lvdisplay /dev/myvg/test

  --- Logical volume ---

  LV Path /dev/myvg/test

  LV Name test

  VG Name myvg

  LV UUID wY1YUF-f0o6-jzu1-mtTL-64p0-qvfC-3QfF8y

  LV Write Access read/write

  LV Creation host, time station106.magelinux.com, 2014-02-10 11:18:43 +0800

  LV Status available

  # open 0

  LV Size 10.00 GiB-》这里又变成了10G。

  Current LE 2560

  Segments 1

  Allocation inherit

  Read ahead sectors auto

  - currently set to 256

  Block device 253:4

  挂载继续使用并且查看文件是否存在。

  [root@station106 ~]# mount /dev/myvg/test /mnt/

  [root@station106 ~]# cd /mnt/

  [root@station106 mnt]# ls

  accp benet lost+found--》查看还是存在。未丢失。

  [root@station106 mnt]# df -hT

  Filesystem Type Size Used Avail Use% Mounted on

  /dev/mapper/vg0-root

  ext4 20G 387M 19G 3% /

  tmpfs tmpfs 242M 0 242M 0% /dev/shm

  /dev/sda1 ext4 194M 29M 156M 16% /boot

  /dev/mapper/vg0-usr

  ext4 9.9G 1.9G 7.6G 20% /usr

  /dev/mapper/vg0-var

  ext4 20G 288M 19G 2% /var

  /dev/mapper/myvg-test

本篇文章标签: 教程 Win10 win7 软件 Win8
发表评论