22.03.2010

LVM grubundan dolu bir diski-partitionu cikarmak

Kullandigim disk bolutlemesinde /home  directory'im bana yetmemeye basladi.
Buyutmek istedim., hatta yapmisken LVM'e gecireyim dedim.

Oncelikle mevcut lvm'lerimdeki disklerimi ve kullanim oranlarini gorelim:


uileri:~ # lvscan
  ACTIVE            '/dev/vg0/quotafs' [175.00 GB] inherit
uileri:~ # lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg0/quotafs
  VG Name                vg0
  LV UUID                Gt9D32-qwWY-QNVF-si8g-onBw-0XY4-OmgYlX
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                175.00 GB
  Current LE             44800
  Segments               3
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     1024
  Block device           253:0
  
uileri:~ # pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda8
  VG Name               vg0
  PV Size               51.59 GB / not usable 3.07 MB
  Allocatable           yes (but full)
  PE Size (KByte)       4096
  Total PE              13205
  Free PE               0
  Allocated PE          13205
  PV UUID               oeqv2w-DS17-BEZU-mNXp-6QxB-9XRA-b1nZy3
  
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg0
  PV Size               18.64 GB / not usable 1.00 MB
  Allocatable           yes (but full)
  PE Size (KByte)       4096
  Total PE              4771
  Free PE               0
  Allocated PE          4771
  PV UUID               r80jwe-gQVj-tF8j-AjFg-9J3V-URKK-Z7WNdC
  
  --- Physical volume ---
  PV Name               /dev/sdb2
  VG Name               vg0
  PV Size               3.73 GB / not usable 4.14 MB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              954
  Free PE               954
  Allocated PE          0
  PV UUID               SnQims-A61U-anEZ-lSfk-zADI-mH5W-ToU2Yo
  
  --- Physical volume ---
  PV Name               /dev/sdb3
  VG Name               vg0
  PV Size               126.64 GB / not usable 970.00 KB
  Allocatable           yes
  PE Size (KByte)       4096
  Total PE              32420
  Free PE               5596
  Allocated PE          26824
  PV UUID               1f1Bf6-3FAT-psTT-cPo6-nfRw-h1wH-sIwXPY
  
uileri:~ # df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda5             9.7G  6.4G  2.9G  70% /
udev                  999M  3.0M  996M   1% /dev
/dev/sda1              99M   19M   75M  20% /boot
/dev/sda7             9.4G  7.1G  1.9G  80% /home
/dev/mapper/vg0-quotafs
                      173G   47G  117G  29% /lvm
/dev/sda6             9.4G  1.9G  7.2G  21% /x.home
/dev/sda2              29G   14G   14G  50% /yedek


Goruldugu gibi, vg0 VolumeGroup'um icerisinde /dev/sdb1 bolutum benim istedigim kriterlere uygun gibi.
O yuzden /dev/sdb1'i vg0 dan dolayisiyla quotafs'ten ayirmak istedim.

vgreduce ile bu isi yapabilecegimi dusundum, ancak sonuc ortada

 uileri:~ # vgreduce vg0 /dev/sdb1
  Physical volume "/dev/sdb1" still in use

Simdi, eger bolut-ya da disk kullaniliyorsa ne yapmak lazim?

Komutumuz, pvmove

uileri:~ # lvm
lvm> help
  Available lvm commands:
  Use 'lvm help ' for more information
  
  dumpconfig      Dump active configuration
  formats         List available metadata formats
  help            Display help for commands
  lvchange        Change the attributes of logical volume(s)
  lvconvert       Change logical volume layout
  lvcreate        Create a logical volume
  lvdisplay       Display information about a logical volume
  lvextend        Add space to a logical volume
  lvmchange       With the device mapper, this is obsolete and does nothing.
  lvmdiskscan     List devices that may be used as physical volumes
  lvmsadc         Collect activity data
  lvmsar          Create activity report
  lvreduce        Reduce the size of a logical volume
  lvremove        Remove logical volume(s) from the system
  lvrename        Rename a logical volume
  lvresize        Resize a logical volume
  lvs             Display information about logical volumes
  lvscan          List all logical volumes in all volume groups
  pvchange        Change attributes of physical volume(s)
  pvresize        Resize physical volume(s)
  pvck            Check the consistency of physical volume(s)
  pvcreate        Initialize physical volume(s) for use by LVM
  pvdata          Display the on-disk metadata for physical volume(s)
  pvdisplay       Display various attributes of physical volume(s)
  pvmove          Move extents from one physical volume to another
  pvremove        Remove LVM label(s) from physical volume(s)
  pvs             Display information about physical volumes
  pvscan          List all physical volumes
  segtypes        List available segment types
  vgcfgbackup     Backup volume group configuration(s)
  vgcfgrestore    Restore volume group configuration
  vgchange        Change volume group attributes
  vgck            Check the consistency of volume group(s)
  vgconvert       Change volume group metadata format
  vgcreate        Create a volume group
  vgdisplay       Display volume group information
  vgexport        Unregister volume group(s) from the system
  vgextend        Add physical volumes to a volume group
  vgimport        Register exported volume group with system
  vgmerge         Merge volume groups
  vgmknodes       Create the special files for volume group devices in /dev
  vgreduce        Remove physical volume(s) from a volume group
  vgremove        Remove volume group(s)
  vgrename        Rename a volume group
  vgs             Display information about volume groups
  vgscan          Search for all volume groups
  vgsplit         Move physical volumes into a new or existing volume group
  version         Display software and driver version information

lvm> pvck /dev/sdb1
  Found label on /dev/sdb1, sector 1, type=LVM2 001
  Found text metadata area: offset=4096, size=192512

lvm> pvmove /dev/sdb1
  /dev/sdb1: Moved: 1.3%
  /dev/sdb1: Moved: 2.6%
  /dev/sdb1: Moved: 3.9%
  /dev/sdb1: Moved: 5.2%
  /dev/sdb1: Moved: 6.4%
  /dev/sdb1: Moved: 7.7%
  /dev/sdb1: Moved: 9.0%
  /dev/sdb1: Moved: 10.4%
  /dev/sdb1: Moved: 11.8%
  /dev/sdb1: Moved: 13.2%
  /dev/sdb1: Moved: 14.6%
  /dev/sdb1: Moved: 16.0%
  /dev/sdb1: Moved: 17.4%
  /dev/sdb1: Moved: 18.8%
  /dev/sdb1: Moved: 20.1%
  /dev/sdb1: Moved: 21.4%
  /dev/sdb1: Moved: 22.7%
  /dev/sdb1: Moved: 24.0%
  /dev/sdb1: Moved: 25.3%
  /dev/sdb1: Moved: 26.6%
  /dev/sdb1: Moved: 27.9%
  /dev/sdb1: Moved: 29.2%
  /dev/sdb1: Moved: 30.5%
  /dev/sdb1: Moved: 31.8%
  /dev/sdb1: Moved: 33.1%
  /dev/sdb1: Moved: 34.4%
  /dev/sdb1: Moved: 35.7%
  /dev/sdb1: Moved: 37.0%
  /dev/sdb1: Moved: 38.4%
  /dev/sdb1: Moved: 39.8%
  /dev/sdb1: Moved: 41.1%
  /dev/sdb1: Moved: 42.4%
  /dev/sdb1: Moved: 43.6%
  /dev/sdb1: Moved: 44.9%
  /dev/sdb1: Moved: 46.1%
  /dev/sdb1: Moved: 47.3%
  /dev/sdb1: Moved: 48.6%
  /dev/sdb1: Moved: 49.8%
  /dev/sdb1: Moved: 51.1%
  /dev/sdb1: Moved: 52.3%
  /dev/sdb1: Moved: 53.6%
  /dev/sdb1: Moved: 54.9%
  /dev/sdb1: Moved: 56.3%
  /dev/sdb1: Moved: 57.7%
  /dev/sdb1: Moved: 59.0%
  /dev/sdb1: Moved: 60.4%
  /dev/sdb1: Moved: 61.7%
  /dev/sdb1: Moved: 62.9%
  /dev/sdb1: Moved: 64.3%
  /dev/sdb1: Moved: 65.5%
  /dev/sdb1: Moved: 66.8%
  /dev/sdb1: Moved: 68.1%
  /dev/sdb1: Moved: 69.3%
  /dev/sdb1: Moved: 70.6%
  /dev/sdb1: Moved: 71.8%
  /dev/sdb1: Moved: 73.1%
  /dev/sdb1: Moved: 74.3%
  /dev/sdb1: Moved: 75.6%
  /dev/sdb1: Moved: 76.8%
  /dev/sdb1: Moved: 78.0%
  /dev/sdb1: Moved: 79.3%
  /dev/sdb1: Moved: 80.5%
  /dev/sdb1: Moved: 81.7%
  /dev/sdb1: Moved: 83.0%
  /dev/sdb1: Moved: 84.3%
  /dev/sdb1: Moved: 85.5%
  /dev/sdb1: Moved: 86.7%
  /dev/sdb1: Moved: 87.9%
  /dev/sdb1: Moved: 89.0%
  /dev/sdb1: Moved: 90.2%
  /dev/sdb1: Moved: 91.4%
  /dev/sdb1: Moved: 92.6%
  /dev/sdb1: Moved: 93.9%
  /dev/sdb1: Moved: 95.1%
  /dev/sdb1: Moved: 96.4%
  /dev/sdb1: Moved: 97.6%
  /dev/sdb1: Moved: 98.7%
  /dev/sdb1: Moved: 99.9%
  /dev/sdb1: Moved: 100.0%
  Unable to deact, open_count is 1
  Unable to deact, open_count is 1

lvm> vgreduce vg0 /dev/sdb1
  Removed "/dev/sdb1" from volume group "vg0"

lvm> vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "vg0" using metadata type lvm2
lvm> pvscan
  PV /dev/sda8   VG vg0             lvm2 [51.58 GB / 0    free]
  PV /dev/sdb2   VG vg0             lvm2 [3.73 GB / 3.73 GB free]
  PV /dev/sdb3   VG vg0             lvm2 [126.64 GB / 3.22 GB free]
  PV /dev/sdb1                      lvm2 [18.64 GB]
  Total: 4 [200.59 GB] / in use: 3 [181.95 GB] / in no VG: 1 [18.64 GB]

Artik /dev/sdb1'im serbest onunla yepyeni bir LVM Volume olusturabilirim