创建LV与挂载

在虚拟中添加一块盘

[root@test ~]# fdisk -l

 

Disk /dev/sda: 33.7 GB, 33693843456 bytes

255 heads, 63 sectors/track, 4096 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: 0×00073991

 

   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        4097    32390144   8e  Linux LVM

 

Disk /dev/sdb: 5626 MB, 5626736640 bytes

255 heads, 63 sectors/track, 684 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: 0×00000000

 

 

 

发现 Disk /dev/sdb

 

1、  创建pv

[root@test ~]# pvcreate /dev/sdb

  Physical volume "/dev/sdb" successfully created

[root@test ~]# pvscan

  PV /dev/sda2   VG vg_hca1         lvm2 [30.89 GiB / 0    free]

  PV /dev/sdb                       lvm2 [5.24 GiB]

  Total: 2 [36.13 GiB] / in use: 1 [30.89 GiB] / in no VG: 1 [5.24 GiB]

 

 

2、  创建vg

[root@test ~]# vgcreate -s 32M vg_hca2  /dev/sdb

  Volume group "vg_hca2" successfully created

[root@test ~]# vgscan

  Reading all physical volumes.  This may take a while…

  Found volume group "vg_hca2" using metadata type lvm2

  Found volume group "vg_hca1" using metadata type lvm2

 

  查看可用磁盘

[root@test ~]# vgdisplay

  — Volume group —

  VG Name               vg_hca2

  System ID            

  Format                lvm2

  Metadata Areas        1

  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                1

  Act PV                1

  VG Size               5.22 GiB

  PE Size               32.00 MiB

  Total PE              167

  Alloc PE / Size       0 / 0  

  Free  PE / Size       167 / 5.22 GiB

  VG UUID               HDv7Me-bdZB-Xmd0-cIph-X8Mb-5v1d-3Lu5iy

  

  — Volume group —

  VG Name               vg_hca1

  System ID            

  Format                lvm2

  Metadata Areas        1

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                2

  Open LV               2

  Max PV                0

  Cur PV                1

  Act PV                1

  VG Size               30.89 GiB

  PE Size               4.00 MiB

  Total PE              7907

  Alloc PE / Size       7907 / 30.89 GiB

  Free  PE / Size       0 / 0  

  VG UUID               MjeesJ-n67P-nl3i-tGEF-ArEX-6RBm-tC5S5y

 

3、  创建LV

[root@test ~]# lvcreate -L 2G -n lv_db vg_hca2

  Logical volume "lv_db" created

[root@test ~]# lvscan

  ACTIVE            '/dev/vg_hca2/lv_db' [2.00 GiB] inherit

  ACTIVE            '/dev/vg_hca1/lv_root' [26.95 GiB] inherit

  ACTIVE            '/dev/vg_hca1/lv_swap' [3.94 GiB] inherit

 

 

4、  建立文件系统

[root@test ~]# mkfs -t ext3 /dev/vg_hca2/lv_db

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

131072 inodes, 524288 blocks

26214 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=536870912

16 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912

 

Writing inode tables: done                           

Creating journal (16384 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 38 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

 

 

 

5、  格式化

Make2fs –j /dev/vg_hca2/lv_db

写入 /etc/fstab

文件中加入

/dev/vg_hca2/lv_db      /db     ext3            defaults        1 1

 

6、  刷新mount

mount –a

7、  建立挂载点

Mkdir /db

 

 

8、  挂载 mount /dev/vg_hca2/lv_db /db

[root@test ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_hca1-lv_root

                       27G   12G   15G  44% /

tmpfs                 940M   72K  940M   1% /dev/shm

/dev/sda1             485M   37M  423M   9% /boot

/dev/mapper/vg_hca2-lv_db

                      2.0G   68M  1.9G   4% /db

 

 

 

 

二、创建扩展分区,并建立逻辑分区

fdisk -cu /dev/sdc

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.

 

 

Command (m for help): m

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

       x   extra functionality (experts only)

 

Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

选择e 扩展分区

e

Partition number (1-4): 2 

First sector (2048-6909219, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-6909219, default 6909219):

Using default value 6909219

将所有空间赋予扩展分区

Command (m for help): N 

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

选择L 逻辑分区

l

First sector (4096-6909219, default 4096):

Using default value 4096

Last sector, +sectors or +size{K,M,G} (4096-6909219, default 6909219): +500M

 

Command (m for help): N

Command action

   l   logical (5 or over)

   p   primary partition (1-4)

l

First sector (1030144-6909219, default 1030144):

Using default value 1030144

Last sector, +sectors or +size{K,M,G} (1030144-6909219, default 6909219): +400M

 

查看已经创建好的分区

Command (m for help): p

 

Disk /dev/sdc: 3537 MB, 3537520640 bytes

255 heads, 63 sectors/track, 430 cylinders, total 6909220 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0×00000000

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc2            2048     6909219     3453586    5  Extended

/dev/sdc5            4096     1028095      512000   83  Linux

/dev/sdc6         1030144     1849343      409600   83  Linux

 

 

保存

Command (m for help): w

The partition table has been altered!

 

Calling ioctl() to re-read partition table.

Syncing disks.

 

格式化分区

[root@test ~]# mkfs.ext4 /dev/sdc5

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

128016 inodes, 512000 blocks

25600 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67633152

63 block groups

8192 blocks per group, 8192 fragments per group

2032 inodes per group

Superblock backups stored on blocks:

        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

 

Writing inode tables: done                           

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 29 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

[root@test ~]# mkfs.ext4 /dev/sdc6

mke2fs 1.41.12 (17-May-2010)

Filesystem label=

OS type: Linux

Block size=1024 (log=0)

Fragment size=1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

102400 inodes, 409600 blocks

20480 blocks (5.00%) reserved for the super user

First data block=1

Maximum filesystem blocks=67633152

50 block groups

8192 blocks per group, 8192 fragments per group

2048 inodes per group

Superblock backups stored on blocks:

        8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409

 

Writing inode tables: done                           

Creating journal (8192 blocks): done

Writing superblocks and filesystem accounting information: done

 

This filesystem will be automatically checked every 25 mounts or

180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

 

建立挂载点

[root@test ~]# mkdir /sdc5

[root@test ~]# mkdir /sdc6

 

 

查看分区的UUID

[root@test ~]# blkid /dev/sdc5

/dev/sdc5: UUID="d9996894-4d4b-4884-8105-e697df2769e5" TYPE="ext4"

[root@test ~]# blkid /dev/sdc6

/dev/sdc6: UUID="2a833edf-e97b-4763-82ee-2d1e729d705f" TYPE="ext4"

 

 

写入/etc/fstab

[root@test ~]# vi /etc/fstab

 

#

# /etc/fstab

# Created by anaconda on Mon Jul 25 16:46:14 2016

#

# Accessible filesystems, by reference, are maintained under '/dev/disk'

# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info

#

/dev/mapper/vg_hca1-lv_root /                       ext4    defaults        1 1

UUID=4fdc0797-a0b0-46e6-8e88-b95aa1d612b4 /boot                   ext4    defaults        1 2

/dev/mapper/vg_hca1-lv_swap swap                    swap    defaults        0 0

/dev/vg_hca2/lv_db      /db     ext3            defaults        1 1

tmpfs                   /dev/shm                tmpfs   defaults        0 0

devpts                  /dev/pts                devpts  gid=5,mode=620  0 0

sysfs                   /sys                    sysfs   defaults        0 0

proc                    /proc                   proc    defaults        0 0

UUID=d9996894-4d4b-4884-8105-e697df2769e5 /sdc5 ext4    defaults        0 0

UUID=2a833edf-e97b-4763-82ee-2d1e729d705f /sdc6 ext4    defaults        0 0

 

 

刷新mount

[root@test ~]# mount -a

[root@test ~]# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/vg_hca1-lv_root

                       27G   12G   15G  44% /

tmpfs                 940M   72K  940M   1% /dev/shm

/dev/sda1             485M   37M  423M   9% /boot

/dev/mapper/vg_hca2-lv_db

                      2.0G   68M  1.9G   4% /db

/dev/sdc5             485M   11M  449M   3% /sdc5

/dev/sdc6             388M   11M  358M   3% /sdc6

 

 

 




Related posts

coded by nessus
分享:  DeliciousGReader鲜果豆瓣CSDN网摘
Trackback

no comment untill now

Add your comment now

无觅相关文章插件