2016-04-01

LVM ADD NEW HARDDISK

#15:36 2016.04.01
#################
#################STATUS:
#####################################
root@srv152bk:~# df -h
Filesystem                     Size  Used Avail Use% Mounted on
udev                           2.0G  4.0K  2.0G   1% /dev
tmpfs                          396M  748K  395M   1% /run
/dev/sdb1                       46G   26G   18G  60% /
none                           4.0K     0  4.0K   0% /sys/fs/cgroup
none                           5.0M     0  5.0M   0% /run/lock
none                           2.0G     0  2.0G   0% /run/shm
none                           100M     0  100M   0% /run/user
/dev/mapper/vg_srv152-lv01     7.2T  6.7T  127G  99% /disk1

#####################################root@srv152bk:~# lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
NAME                      FSTYPE        SIZE MOUNTPOINT LABEL
sda                                     5.5T           
sdb                                     1.8T           
+-sdb1                    ext4         46.6G /         
+-sdb2                                    1K           
+-sdb5                    swap          7.5G [SWAP]    
+-sdb6                    LVM2_member   1.8T           
  +-vg_srv152-lv01 (dm-0) ext4          7.2T /disk1    
sdc                                     5.5T           
+-sdc1                    LVM2_member   5.5T           
  +-vg_srv152-lv01 (dm-0) ext4          7.2T /disk1    
sdd                                     1.8T           
+-sdd1                    ntfs          1.8T            2tb_2016.03.29
#####################################

root@srv152bk:~# fdisk -l | grep dev

WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/sda doesn't' contain a valid partition table

#Thông tin LVM:
Disk /dev/mapper/vg_srv152-lv01 doesn't contain a valid partition table

#Ổ cứng rời, 2TB, cài OS: WD RED:
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
/dev/sdb1   *        2048    97656831    48827392   83  Linux
/dev/sdb2        97658878  3907028991  1904685057    5  Extended
/dev/sdb5        97658880   113281023     7811072   82  Linux swap / Solaris
/dev/sdb6       113283072  3907028991  1896872960   83  Linux

#Ổ cứng rời, 6TB, 64MB CACHE: SEAGATE:
Disk /dev/sdc: 6001.2 GB, 6001175126016 bytes
/dev/sdc1               1  4294967295  2147483647+  ee  GPT

#Ổ cứng rời, 6TB/128MB CACHE: WD RE:
Disk /dev/sda: 6001.2 GB, 6001175126016 bytes
Disk /dev/mapper/vg_srv152-lv01: 7938.5 GB, 7938475294720 bytes

#Ổ cứng di động:
Disk /dev/sdd: 2000.4 GB, 2000365289472 bytes
/dev/sdd1            2048  3906963455  1953480704    7  HPFS/NTFS/exFAT
root@srv152bk:~#




root@srv152bk:~# pvs
  PV         VG        Fmt  Attr PSize PFree
  /dev/sdb6  vg_srv152 lvm2 a--  1.77t 4.74g
  /dev/sdc1  vg_srv152 lvm2 a--  5.46t    0


root@srv152bk:~# pvscan
  PV /dev/sdc1   VG vg_srv152   lvm2 [5.46 TiB / 0    free]
  PV /dev/sdb6   VG vg_srv152   lvm2 [1.77 TiB / 4.74 GiB free]
  Total: 2 [7.22 TiB] / in use: 2 [7.22 TiB] / in no VG: 0 [0   ]


root@srv152bk:~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sdc1
  VG Name               vg_srv152
  PV Size               5.46 TiB / not usable 0  
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              1430791
  Free PE               0
  Allocated PE          1430791
  PV UUID               ORpKCw-wJca-7yK1-hzEU-Tb4B-HxMO-cZuyMh
  
  --- Physical volume ---
  PV Name               /dev/sdb6
  VG Name               vg_srv152
  PV Size               1.77 TiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              463103
  Free PE               1214
  Allocated PE          461889
  PV UUID               wSCZ7y-S3lW-n68t-kotl-o8Ti-ihL4-sR9vFh


root@srv152bk:~# vgs
  VG        #PV #LV #SN Attr   VSize VFree
  vg_srv152   2   1   0 wz--n- 7.22t 4.74g


root@srv152bk:~# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_srv152" using metadata type lvm2


root@srv152bk:~# vgdisplay
  --- Volume group ---
  VG Name               vg_srv152
  System ID            
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               7.22 TiB
  PE Size               4.00 MiB
  Total PE              1893894
  Alloc PE / Size       1892680 / 7.22 TiB
  Free  PE / Size       1214 / 4.74 GiB
  VG UUID               8yZ5zn-zOPo-YIeB-9hsF-9l4n-ApiR-qgA2uP


root@srv152bk:~# lvs
  LV   VG        Attr      LSize Pool Origin Data%  Move Log Copy%  Convert
  lv01 vg_srv152 -wi-ao--- 7.22t    


root@srv152bk:~# lvscan
  ACTIVE            '/dev/vg_srv152/lv01' [7.22 TiB] inherit


root@srv152bk:~# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg_srv152/lv01
  LV Name                lv01
  VG Name                vg_srv152
  LV UUID                HWnoX4-SVm6-KoQp-zP00-P1cJ-yaK6-HQ2T6P
  LV Write Access        read/write
  LV Creation host, time srv152bk, 2015-08-22 16:32:46 +0700
  LV Status              available
  # open                 1
  LV Size                7.22 TiB
  Current LE             1892680
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0
  
#CHUAN BI CAU HINH LVM:

#CHUAN BI CAU HINH LVM:
fdisk /dev/sda #KHONG AP DUNG DUOC VI FDISK CHI NHAN MAX 2TB:
#p       print the partition table
#n       add a new partition
#p       primary partition (1-4)
#1       Partition number (1-4):
#enter   First cylinder (1-130, default 1):
#enter   Last cylinder, +cylinders or +size{K,M,G} (1-130, default 130):
#w (write)
 


#CHUYEN SANG GPT:

#__________________________________To create a partition start GNU parted as follows:
#root@srv152bk:~# parted /dev/sda
GNU Parted 2.3
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.


#Creates a new GPT disklabel i.e. partition table:
#(parted) mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No?Yes


#Next, set the default unit to TB, enter:
#(parted) unit TB


#To create a 3TB partition size, enter:
#(parted) mkpart primary 0 0
OR
#(parted) mkpart primary 0.00TB 6.00TB #(CHOOSE THIS COMMAND), Ổ CỨNG 6TB



#To print the current partitions, enter:
#(parted) print                                                           
Model: ATA WDC WD6001FSYZ-0 (scsi)
Disk /dev/sda: 6.00TB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt

Number  Start   End     Size    File system  Name     Flags
 1      0.00TB  6.00TB  6.00TB               primary



#Quit and save the changes, enter:
#(parted) quit
Information: You may need to update /etc/fstab



#root@srv152bk:~# fdisk -l | grep dev
WARNING: GPT (GUID Partition Table) detected on '/dev/sda'! The util fdisk doesn't support GPT. Use GNU Parted.
Disk /dev/mapper/vg_srv152-lv01 doesn't contain a valid partition table
Disk /dev/sda: 6001.2 GB, 6001175126016 bytes
/dev/sda1               1  4294967295  2147483647+  ee  GPT #<<GPT




#Use the mkfs.ext4 command to format the file system, enter:
#root@srv152bk:~# mkfs.ext4 /dev/sda1
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
183144448 inodes, 1465130240 blocks
73256512 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
44713 block groups
32768 blocks per group, 32768 fragments per group
4096 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
#

########

####################
root@srv152bk:/opt/script# pvcreate /dev/sda1
  Physical volume "/dev/sda1" successfully created

root@srv152bk:/opt/script# pvs
  PV         VG        Fmt  Attr PSize PFree
  /dev/sda1            lvm2 a--  5.46t 5.46t
  /dev/sdb6  vg_srv152 lvm2 a--  1.77t 4.74g
  /dev/sdc1  vg_srv152 lvm2 a--  5.46t    0

root@srv152bk:/opt/script# vgs
  VG        #PV #LV #SN Attr   VSize VFree
  vg_srv152   2   1   0 wz--n- 7.22t 4.74g

root@srv152bk:/opt/script# vgextend  vg_srv152 /dev/sda1
  Volume group "vg_srv152" successfully extended


  VG Size               12.68 TiB

root@srv152bk:~# vgdisplay
  --- Volume group ---
  VG Name               vg_srv152
  System ID            
  Format                lvm2
  Metadata Areas        3
  Metadata Sequence No  8
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                3
  Act PV                3
  VG Size               12.68 TiB
  PE Size               4.00 MiB
  Total PE              3324685
  Alloc PE / Size       1892680 / 7.22 TiB (Dung lượng hiện tại)
  Free  PE / Size       1432005 / 5.46 TiB (FREE, chưa add vào LVM)
  VG UUID               8yZ5zn-zOPo-YIeB-9hsF-9l4n-ApiR-qgA2uP
  
  
root@srv152bk:~# lvscan
  ACTIVE            '/dev/vg_srv152/lv01' [7.22 TiB] inherit

root@srv152bk:~# lvresize -L+5.46TB /dev/vg_srv152/lv01
  Rounding size to boundary between physical extents: 5.46 TiB
  Extending logical volume lv01 to 12.68 TiB
  Logical volume lv01 successfully resized


root@srv152bk:~# resize2fs /dev/vg_srv152/lv01
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/vg_srv152/lv01 is mounted on /disk1; on-line resizing required
old_desc_blocks = 463, new_desc_blocks = 812
The filesystem on /dev/vg_srv152/lv01 is now 3403762688 blocks long.

#KẾT QUẢ:

    

No comments:

Post a Comment