Linux逻辑卷的创建与扩容
发布时间:2020-12-14 02:02:41 所属栏目:Linux 来源:网络整理
导读:Logical volume 的创建 磁盘初始化 [[email?protected] ~]# fdisk -lDisk /dev/sda: 53.7 GB,53687091200 bytes,104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal)
Logical volume 的创建
[[email?protected] ~]# fdisk -l Disk /dev/sda: 53.7 GB,53687091200 bytes,104857600 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 label type: dos Disk identifier: 0x000a580e Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 104857599 52222976 8e Linux LVM Disk /dev/sdb: 107.4 GB,107374182400 bytes,209715200 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 /dev/mapper/centos-root: 44.9 GB,44883247104 bytes,87662592 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 /dev/mapper/centos-swap: 8589 MB,8589934592 bytes,16777216 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 [[email?protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 42G 1.6G 41G 4% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.5M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda1 197M 103M 95M 53% /boot tmpfs 799M 0 799M 0% /run/user/0 [[email?protected] ~]# mkdir /data [[email?protected] ~]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only,until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x3bb4b474. Command (m for help): n Partition type: p primary (0 primary,0 extended,4 free) e extended Select (default p): p Partition number (1-4,default 1): First sector (2048-209715199,default 2048): Using default value 2048 Last sector,+sectors or +size{K,M,G} (2048-209715199,default 209715199): Using default value 209715199 Partition 1 of type Linux and of size 100 GiB is set Command (m for help): p Disk /dev/sdb: 107.4 GB,209715200 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 label type: dos Disk identifier: 0x3bb4b474 Device Boot Start End Blocks Id System /dev/sdb1 2048 209715199 104856576 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. [[email?protected] ~]# partprobe Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[[email?protected] ~]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created. [[email?protected] ~]# vgdisplay --- Volume group --- VG Name centos 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 49.80 GiB PE Size 4.00 MiB Total PE 12749 Alloc PE / Size 12749 / 49.80 GiB Free PE / Size 0 / 0 VG UUID uYlfgy-kh0D-YE6a-A3Eq-n4RN-t3QF-C7HBLS [[email?protected] ~]# vgextend centos /dev/sdb1 Volume group "centos" successfully extended [[email?protected] ~]# pvscan PV /dev/sda2 VG centos lvm2 [49.80 GiB / 0 free] PV /dev/sdb1 VG centos lvm2 [<100.00 GiB / <100.00 GiB free] Total: 2 [<149.80 GiB] / in use: 2 [<149.80 GiB] / in no VG: 0 [0 ] > * 逻辑卷创建 [[email?protected] ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID vFM0SF-6giK-lWPg-iCTY-usKM-ywpA-bp5zxd LV Write Access read/write LV Creation host,time xxxx-centos7-template,2018-04-20 13:44:01 +0800 LV Status available # open 2 LV Size 8.00 GiB Current LE 2048 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID mtRvdH-eFlc-3EiS-xQbW-lqfm-y6K5-bAiZrv LV Write Access read/write LV Creation host,2018-04-20 13:44:01 +0800 LV Status available # open 1 LV Size 41.80 GiB Current LE 10701 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 [[email?protected] ~]# lvcreate -L 100G -n data centos Volume group "centos" has insufficient free space (25599 extents): 25600 required. [[email?protected] ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID vFM0SF-6giK-lWPg-iCTY-usKM-ywpA-bp5zxd LV Write Access read/write LV Creation host,2018-04-20 13:44:01 +0800 LV Status available # open 1 LV Size 41.80 GiB Current LE 10701 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 [[email?protected] ~]# lvcreate -L 99G -n data centos Logical volume "data" created. [[email?protected] ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID vFM0SF-6giK-lWPg-iCTY-usKM-ywpA-bp5zxd LV Write Access read/write LV Creation host,2018-04-20 13:44:01 +0800 LV Status available # open 1 LV Size 41.80 GiB Current LE 10701 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/centos/data LV Name data VG Name centos LV UUID Jj7pYx-vlUm-2z9U-UcK0-Wx3m-182t-UeQH25 LV Write Access read/write LV Creation host,2019-03-13 20:50:49 +0800 LV Status available # open 0 LV Size 99.00 GiB Current LE 25344 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2
[[email?protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 42G 1.6G 41G 4% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.5M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda1 197M 103M 95M 53% /boot tmpfs 799M 0 799M 0% /run/user/0 [[email?protected] ~]# mkfs.ext4 -j /dev/centos/data mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks,Stripe width=0 blocks 6488064 inodes,25952256 blocks 1297612 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2174746624 792 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,2654208,4096000,7962624,11239424,20480000,23887872 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [[email?protected] ~]# vim /etc/fstab [[email?protected] ~]# cat /etc/fstab /dev/mapper/centos-root / xfs defaults 0 0 UUID=30d431c7-640e-4431-8850-4a686d553114 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 /dev/centos/data /data ext4 defaults 0 0 [[email?protected] ~]# [[email?protected] ~]# mount -a [[email?protected] ~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/centos-root 42G 1.6G 41G 4% / devtmpfs 3.9G 0 3.9G 0% /dev tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 3.9G 8.5M 3.9G 1% /run tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda1 197M 103M 95M 53% /boot tmpfs 799M 0 799M 0% /run/user/0 /dev/mapper/centos-data 98G 61M 93G 1% /data Logical volume 扩容
lvdisplay lvextend /dev/centos/data /dev/sda3 xfs_growfs /dev/centos/data (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |