安哥网络 发表于 2018-1-8 23:28:54

LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block wh...

LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while) 2015-09-04 11:28:01



分类: Linux



LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)
给某个硬盘增加分区之后
# df -h
Filesystem                            SizeUsed Avail Use% Mounted on
/dev/mapper/vg_mysql0121366-LogVol027.7G2.6G4.8G36% /
tmpfs                                 495M   0495M   0% /dev/shm
/dev/sda1                           194M   29M155M16% /boot
/dev/mapper/vg_mysql0121366-LogVol018.0G3.1G5.0G38% /data
这里增加/data大小
# fdisk -l /dev/sda

Disk /dev/sda: 40.8 GB, 40802189312 bytes
heads, 63 sectors/track, 4960 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: 0x000eb81f

   Device Boot      Start         End      Blocks   IdSystem
/dev/sda1   *         1          26      204800   83Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2            26      2350    18668544   8eLinux LVM

进行分区
# fdisk /dev/sda

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): 3
First cylinder (2350-4960, default 2350):
Using default value 2350
Last cylinder, +cylinders or +size{K,M,G} (2350-4960, default 4960):
Using default value 4960

Command (m for help): p

Disk /dev/sda: 40.8 GB, 40802189312 bytes
heads, 63 sectors/track, 4960 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: 0x000eb81f

   Device Boot      Start         End      Blocks   IdSystem
/dev/sda1   *         1          26      204800   83Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2            26      2350    18668544   8eLinux LVM
/dev/sda3            2350      4960    20966832   83Linux

Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

重启服务器或者 partprobe
创建物理卷
# pvcreate /dev/sda3
Physical volume "/dev/sda3" successfully created
使用vgscan查询物理卷
# vgscan
Reading all physical volumes.This may take a while...
Found volume group "vg_mysql0121366" using metadata type lvm2
使用新增物理卷扩展vg
# vgextend vg_mysql0121366 /dev/sda3
Volume group "vg_mysql0121366" successfully extended
# vgscan
Reading all physical volumes.This may take a while...
Found volume group "vg_mysql0121366" using metadata type lvm2
查询vg
# vgdisplay
--- Volume group ---
VG Name               vg_mysql0121366
System ID            
Format                lvm2
Metadata Areas      2
Metadata Sequence No5
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                3
Open LV               3
Max PV                0
Cur PV                2
Act PV                2
VG Size               37.79 GiB
PE Size               4.00 MiB
Total PE            9675
Alloc PE / Size       4557 / 17.80 GiB
FreePE / Size       5118 / 19.99 GiB
VG UUID               Zy2PVv-xSsx-NEAv-L6ba-G8Oy-tBBq-5zXKQm
查询lv
# lvdisplay
--- Logical volume ---
LV Path                /dev/vg_mysql0121366/LogVol01
LV Name                LogVol01
VG Name                vg_mysql0121366
LV UUID                5znkJ2-wdeZ-Y2o1-ECDS-gzzl-PqaS-qo2yZR
LV Write Access      read/write
LV Creation host, time Mysql01-213-66, 2015-08-30 20:42:13 +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:2
   
--- Logical volume ---
LV Path                /dev/vg_mysql0121366/LogVol00
LV Name                LogVol00
VG Name                vg_mysql0121366
LV UUID                b1FV1n-iKyK-kZ23-glRO-opFh-gDRp-TzWNcL
LV Write Access      read/write
LV Creation host, time Mysql01-213-66, 2015-08-30 20:42:14 +0800
LV Status            available
# open               1
LV Size                2.00 GiB
Current LE             512
Segments               1
Allocation             inherit
Read ahead sectors   auto
- currently set to   256
Block device         253:0
   
--- Logical volume ---
LV Path                /dev/vg_mysql0121366/LogVol02
LV Name                LogVol02
VG Name                vg_mysql0121366
LV UUID                eoVdk3-cbcP-9PlI-kZBL-6pY2-Jpbl-1WI2uH
LV Write Access      read/write
LV Creation host, time Mysql01-213-66, 2015-08-30 20:42:14 +0800
LV Status            available
# open               1
LV Size                7.80 GiB
Current LE             1997
Segments               1
Allocation             inherit
Read ahead sectors   auto
- currently set to   256
Block device         253:1
   
# df -h
Filesystem                            SizeUsed Avail Use% Mounted on
/dev/mapper/vg_mysql0121366-LogVol027.7G2.6G4.8G35% /
tmpfs                                 495M   0495M   0% /dev/shm
/dev/sda1                           194M   29M155M16% /boot
/dev/mapper/vg_mysql0121366-LogVol018.0G3.1G5.0G38% /data
扩展lv
# lvextend -L +19G /dev/mapper/vg_mysql0121366-LogVol01
Extending logical volume LogVol01 to 27.00 GiB
Logical volume LogVol01 successfully resized
# df -h
Filesystem                            SizeUsed Avail Use% Mounted on
/dev/mapper/vg_mysql0121366-LogVol027.7G2.6G4.8G35% /
tmpfs                                 495M   0495M   0% /dev/shm
/dev/sda1                           194M   29M155M16% /boot
/dev/mapper/vg_mysql0121366-LogVol018.0G3.1G5.0G38% /data
若不是xfs我们可以用resize2fs,这里报错了
# resize2fs -f /dev/mapper/vg_mysql0121366-LogVol01
resize2fs 1.41.12 (17-May-2010)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/vg_mysql0121366-LogVol01
Couldn't find valid filesystem superblock.
# xfs_growfs /dev/mapper/vg_mysql0121366-LogVol01
meta-data=/dev/mapper/vg_mysql0121366-LogVol01 isize=256    agcount=4, agsize=524288 blks
         =                     sectsz=512   attr=2, projid32bit=0
data   =                     bsize=4096   blocks=2097152, imaxpct=25
         =                     sunit=0      swidth=0 blks
naming   =version 2            bsize=4096   ascii-ci=0
log      =internal               bsize=4096   blocks=2560, version=2
         =                     sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 2097152 to 7077888
# df -h
Filesystem                            SizeUsed Avail Use% Mounted on
/dev/mapper/vg_mysql0121366-LogVol027.7G2.6G4.8G35% /
tmpfs                                 495M   0495M   0% /dev/shm
/dev/sda1                           194M   29M155M16% /boot
/dev/mapper/vg_mysql0121366-LogVol01   27G3.1G   24G12% /dataLVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block while)
页: [1]
查看完整版本: LVM XFS增加硬盘分区容量(resize2fs: Bad magic number in super-block wh...