1. 程式人生 > >linux根目錄擴容

linux根目錄擴容

auto memory create alter all 8.0 art vol logic

1、查看新添加的磁盤,如下: /dev/sde為新添加磁盤 可用如下腳本進行掃描 echo ‘ - - - ‘ > /sys/class/scsi_host/host0/scan [[email protected] ~]# 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: 0x00028c6a Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 2611 20765696 8e Linux LVM Disk /dev/sde: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 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/mapper/vg_rac01-LogVol01: 12.7 GB, 12670992384 bytes 255 heads, 63 sectors/track, 1540 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/mapper/vg_rac01-LogVol00: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 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 2、對磁盤進行分區,將其劃分為一個主分區,並創建PV
[[email protected] ~]# fdisk /dev/sde Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x6751fd38. 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 #n為新建一個分區
Command action e extended p primary partition (1-4) p #p為新建一個primary partition,即主分區 Partition number (1-4): Value out of range. Partition number (1-4): 1 #分區序號為1 First cylinder (1-1044, default 1): #默認從第一個柱面開始 Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-1044, default 1044): #默認到最後一個柱面結束
Using default value 1044 Command (m for help): t #改變分區格式為8e 即Linux LVM邏輯卷格式 Selected partition 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. 3、查看創建情況 [[email protected] ~]# 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: 0x00028c6a Device Boot Start End Blocks Id System /dev/sda1 * 1 26 204800 83 Linux Partition 1 does not end on cylinder boundary. /dev/sda2 26 2611 20765696 8e Linux LVM Disk /dev/sde: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 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: 0x6751fd38 Device Boot Start End Blocks Id System /dev/sde1 1 1044 8385898+ 8e Linux LVM Disk /dev/mapper/vg_rac01-LogVol01: 12.7 GB, 12670992384 bytes 255 heads, 63 sectors/track, 1540 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/mapper/vg_rac01-LogVol00: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 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 4、創建物理卷組 [[email protected] ~]# pvcreate /dev/sde1 Physical volume "/dev/sde1" successfully created [[email protected] ~]# pvdisplay #查看物理卷組情況 --- Physical volume --- PV Name /dev/sda2 VG Name vg_rac01 PV Size 19.80 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 5069 Free PE 0 Allocated PE 5069 PV UUID vHMLej-bAqh-yugI-UbFf-OyTC-31Yt-xouKeY "/dev/sde1" is a new physical volume of "8.00 GiB" --- NEW Physical volume --- PV Name /dev/sde1 VG Name PV Size 8.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID 7axfPk-Xxfg-HWQS-gBjj-GD0Q-xFgU-e9apR7 5、查看物理卷組 [[email protected] ~]# pvscan PV /dev/sda2 VG vg_rac01 lvm2 [19.80 GiB / 0 free] PV /dev/sde1 lvm2 [8.00 GiB] Total: 2 [27.80 GiB] / in use: 1 [19.80 GiB] / in no VG: 1 [8.00 GiB] 6、擴展物理卷 [[email protected] ~]# vgextend vg_rac01 /dev/sde1 Volume group "vg_rac01" successfully extended [[email protected] ~]# vgdisplay --- Volume group --- VG Name vg_rac01 System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 27.80 GiB PE Size 4.00 MiB Total PE 7116 Alloc PE / Size 5069 / 19.80 GiB Free PE / Size 2047 / 8.00 GiB VG UUID z1Fila-7Cwx-8m9K-XQMG-UK4a-4iLq-kibPv2 7、查看邏輯卷 [[email protected] ~]# lvdisplay --- Logical volume --- LV Path /dev/vg_rac01/LogVol01 LV Name LogVol01 VG Name vg_rac01 LV UUID mnT2Gu-OfUY-sBvc-mbU3-P1gZ-BJcC-S1QXcl LV Write Access read/write LV Creation host, time rac01, 2017-03-07 14:40:50 +0800 LV Status available # open 1 LV Size 11.80 GiB Current LE 3021 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 --- Logical volume --- LV Path /dev/vg_rac01/LogVol00 LV Name LogVol00 VG Name vg_rac01 LV UUID OJGG6E-dGBl-RBWB-pWcH-Utu2-sT3i-kvVt9k LV Write Access read/write LV Creation host, time rac01, 2017-03-07 14:40:55 +0800 LV Status available # open 1 LV Size 8.00 GiB Current LE 2048 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:1 9、查看情況 [[email protected] ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_rac01 2 2 0 wz--n- 27.80g 8.00g [[email protected] ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert LogVol00 vg_rac01 -wi-ao---- 8.00g LogVol01 vg_rac01 -wi-ao---- 11.80g 10、擴展邏輯卷 全部擴展 [[email protected] ~]# lvextend -l +100%FREE /dev/mapper/vg_rac01-LogVol01 Size of logical volume vg_rac01/LogVol01 changed from 11.80 GiB (3021 extents) to 19.80 GiB (5068 extents). Logical volume LogVol01 successfully resized [[email protected] ~]# vgs VG #PV #LV #SN Attr VSize VFree vg_rac01 2 2 0 wz--n- 27.80g 0 [[email protected] ~]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert LogVol00 vg_rac01 -wi-ao---- 8.00g LogVol01 vg_rac01 -wi-ao---- 19.80g [[email protected] ~]# resize2fs /dev/mapper/vg_rac01-LogVol01 resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/mapper/vg_rac01-LogVol01 is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 2 Performing an on-line resize of /dev/mapper/vg_rac01-LogVol01 to 5189632 (4k) blocks. The filesystem on /dev/mapper/vg_rac01-LogVol01 is now 5189632 blocks long.

linux根目錄擴容