2015年1月30日 星期五

linux extend filesystem

[root@ms2 ~]# fdisk -l

Disk /dev/sda: 290.9 GB, 290984034304 bytes
255 heads, 63 sectors/track, 35376 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       35376   284053297+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdg doesn't contain a valid partition table


[root@ms2 ~]#  cd /proc/scsi/sg
[root@ms2 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
0       2       0       0       0       1       128     0       1
5       0       0       0       0       1       254     0       1
5       0       0       1       0       1       254     0       1
5       0       0       2       0       1       254     1       1
5       0       0       3       0       1       254     0       1
5       0       0       4       0       1       254     0       1
5       0       0       5       0       1       254     0       1
[root@ms2 sg]# echo "- - -" > /sys/class/scsi_host/host5/scan
[root@ms2 sg]# cat device_hdr devices
host    chan    id      lun     type    opens   qdepth  busy    online
0       2       0       0       0       1       128     0       1
5       0       0       0       0       1       254     1       1
5       0       0       1       0       1       254     0       1
5       0       0       2       0       1       254     0       1
5       0       0       3       0       1       254     0       1
5       0       0       4       0       1       254     0       1
5       0       0       5       0       1       254     0       1
5       0       0       6       0       1       254     0       1
5       0       0       7       0       1       254     0       1
5       0       0       8       0       1       254     0       1
[root@ms2 sg]#
[root@ms2 sg]#  fdisk -l

Disk /dev/sda: 290.9 GB, 290984034304 bytes
255 heads, 63 sectors/track, 35376 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14       35376   284053297+  8e  Linux LVM

Disk /dev/sdb: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/sdc: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdc doesn't contain a valid partition table

Disk /dev/sdd: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdd doesn't contain a valid partition table

Disk /dev/sde: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sde doesn't contain a valid partition table

Disk /dev/sdf: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdf doesn't contain a valid partition table

Disk /dev/sdg: 536.8 GB, 536870912000 bytes
255 heads, 63 sectors/track, 65270 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdg doesn't contain a valid partition table

Disk /dev/sdh: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdh doesn't contain a valid partition table

Disk /dev/sdi: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdi doesn't contain a valid partition table

Disk /dev/sdj: 1099.5 GB, 1099511627776 bytes
255 heads, 63 sectors/track, 133674 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdj doesn't contain a valid partition table
原本只有到 sdg 現在多了 h i j 三個 1TB 的 disk

[root@ms2 sg]# pvcreate /dev/sdh
  Physical volume "/dev/sdh" successfully created
[root@ms2 sg]# pvcreate /dev/sdi
  Physical volume "/dev/sdi" successfully created
[root@ms2 sg]# pvcreate /dev/sdj
  Physical volume "/dev/sdj" successfully created
[root@ms2 sg]#
[root@ms2 sg]# pvscan
  PV /dev/sdb    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdc    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdd    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sde    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdf    VG mboxvg          lvm2 [500.00 GB / 0    free]
  PV /dev/sdg    VG mboxvg          lvm2 [500.00 GB / 109.98 GB free]
  PV /dev/sda2   VG VolGroup00      lvm2 [270.88 GB / 110.72 GB free]
  PV /dev/sdh                       lvm2 [1.00 TB]
  PV /dev/sdi                       lvm2 [1.00 TB]
  PV /dev/sdj                       lvm2 [1.00 TB]
  Total: 10 [6.19 TB] / in use: 7 [3.19 TB] / in no VG: 3 [3.00 TB]
[root@ms2 sg]#
[root@ms2 sg]# vgextend mboxvg /dev/sdh
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# vgextend mboxvg /dev/sdi
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# vgextend mboxvg /dev/sdj
  Volume group "mboxvg" successfully extended
[root@ms2 sg]# pvscan
  PV /dev/sdb    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdc    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdd    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sde    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdf    VG mboxvg       lvm2 [500.00 GB / 0    free]
  PV /dev/sdg    VG mboxvg       lvm2 [500.00 GB / 109.98 GB free]
  PV /dev/sdh    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sdi    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sdj    VG mboxvg       lvm2 [1024.00 GB / 1024.00 GB free]
  PV /dev/sda2   VG VolGroup00   lvm2 [270.88 GB / 110.72 GB free]
  Total: 10 [6.19 TB] / in use: 10 [6.19 TB] / in no VG: 0 [0   ]
[root@ms2 sg]#
[root@ms2 sg]# vgdisplay
  --- Volume group ---
  VG Name               mboxvg
  System ID
  Format                lvm2
  Metadata Areas        9
  Metadata Sequence No  17
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                9
  Act PV                9
  VG Size               5.93 TB
  PE Size               4.00 MB
  Total PE              1554423
  Alloc PE / Size       739840 / 2.82 TB
  Free  PE / Size       814583 / 3.11 TB
  VG UUID               Xtfhe3-APFS-MFzs-wZq0-QNeE-aqEo-1CK1YV

  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                4
  Open LV               4
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               270.88 GB
  PE Size               32.00 MB
  Total PE              8668
  Alloc PE / Size       5125 / 160.16 GB
  Free  PE / Size       3543 / 110.72 GB
  VG UUID               LOAoah-0vIN-pWRq-sLkP-A9mG-zypc-uyLcGa

[root@ms2 sg]#
[root@ms2 sg]# lvdisplay

  --- Logical volume ---
  LV Name                /dev/mboxvg/mbox01
  VG Name                mboxvg
  LV UUID                G15z3j-lomU-encc-LQnS-BNq3-3zyl-qzhiqJ
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                2.82 TB
  Current LE             739840
  Segments               6
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4


[root@ms2 sg]#
[root@ms2 sg]# lvresize -l +100%FREE /dev/mboxvg/mbox01
  Extending logical volume mbox01 to 5.93 TB
  Logical volume mbox01 successfully resized
[root@ms2 sg]# lvdisplay
  --- Logical volume ---
  LV Name                /dev/mboxvg/mbox01
  VG Name                mboxvg
  LV UUID                G15z3j-lomU-encc-LQnS-BNq3-3zyl-qzhiqJ
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                5.93 TB
  Current LE             1554423
  Segments               9
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:4

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol00
  VG Name                VolGroup00
  LV UUID                iYqCos-T3g8-Sf00-5GTb-UkQQ-fTeD-qTge70
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                39.06 GB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol03
  VG Name                VolGroup00
  LV UUID                fTrr9M-46ZG-Hi2X-18wf-jkCm-CpYk-OXGtXx
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                39.06 GB
  Current LE             1250
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol02
  VG Name                VolGroup00
  LV UUID                XlBlhu-inCm-6vsL-OsGw-zuuA-UBUZ-fr1qIj
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                78.12 GB
  Current LE             2500
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2

  --- Logical volume ---
  LV Name                /dev/VolGroup00/LogVol01
  VG Name                VolGroup00
  LV UUID                6edOs6-pyle-Bbn3-4FQT-UCyW-Ud5q-LcSWHS
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                3.91 GB
  Current LE             125
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:3

[root@ms2 sg]#
[root@ms2 sg]# resize2fs /dev/mapper/mboxvg-mbox01
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/mapper/mboxvg-mbox01 is mounted on /home01; on-line resizing required
Performing an on-line resize of /dev/mapper/mboxvg-mbox01 to 1591729152 (4k) blocks.
The filesystem on /dev/mapper/mboxvg-mbox01 is now 1591729152 blocks long.
[root@ms2 sg]# df -g
df: invalid option -- g
Try `df --help' for more information.
[root@ms2 sg]# df -g
df: invalid option -- g
Try `df --help' for more information.
[root@ms2 sg]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       38G  9.5G   27G  27% /
/dev/mapper/VolGroup00-LogVol03
                       38G  177M   36G   1% /tmp
/dev/mapper/VolGroup00-LogVol02
                       76G  9.6G   63G  14% /var
/dev/sda1              99M   19M   76M  20% /boot
tmpfs                 2.0G     0  2.0G   0% /dev/shm
/dev/mapper/mboxvg-mbox01
                      5.9T  1.7T  3.9T  31% /home01
[root@ms2 sg]#

REF:
http://linux.vbird.org/linux_basic/0420quota.php#lvm_whatis

http://linux.vbird.org/linux_basic/0230filesystem.php#fdisk

http://www.thegeekstuff.com/2011/04/identify-file-system-type/

http://linternux.com/2009/06/adding-san-disk/

http://www.milliondollarserver.com/add-new-hard-drive-in-centosrheloel-without-reboot/

http://setaoffice.com/2010/03/28/resizing-an-ext3-filesystem-mounted-on-a-logical-volume-in-a-linux/