2008年11月20日 星期四

Linux System - File Systems.. LVM management

# ls -la /dev/rootvg/
/dev/rootvg/LogVol00 -> /dev/mapper/rootvg-LogVol00
/dev/rootvg/LogVol01 -> /dev/mapper/rootvg-LogVol01
/dev/rootvg/LogVolVM01 -> /dev/mapper/rootvg-LogVolVM01

# ls -la /dev/mapper/
total 0
control
rootvg-LogVol00
rootvg-LogVol01
rootvg-LogVolVM01

# lvdisplay /dev/rootvg/LogVol00
--- Logical volume ---
LV Name /dev/rootvg/LogVol00
VG Name rootvg
LV UUID SYotdp-V3oQ-Gc5p-wDjv-txyz-Q09p-7cgsXz
LV Write Access read/write
LV Status available
# open 1
LV Size 200.00 GB
Current LE 6400
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:0

# lvdisplay /dev/rootvg/LogVol01
--- Logical volume ---
LV Name /dev/rootvg/LogVol01
VG Name rootvg
LV UUID 8MT67X-WpcY-Nyw3-MA57-jKKn-ryq6-9dMWcD
LV Write Access read/write
LV Status available
# open 1
LV Size 1.94 GB
Current LE 62
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:1

# lvdisplay /dev/rootvg/LogVolVM01
--- Logical volume ---
LV Name /dev/rootvg/LogVolVM01
VG Name rootvg
LV UUID e9LYTF-yFRz-RdC1-KC8q-wAN1-2UiM-8dILP5
LV Write Access read/write
LV Status available
# open 0
LV Size 50.00 GB
Current LE 1600
Segments 1
Allocation inherit
Read ahead sectors 0
Block device 253:2


How to enlarge an exsiting partition, here is my experience.
1. First umount the file system
# umount /vm

2. Then use lvextend to extend the logical volumn to the specified volumn size
# lvextend -L80G /dev/rootvg/LogVolVM01

3. Then run the e2fsck to check the new file system
# e2fsck -f /dev/rootvg/LogVolVM01

4. Use resize2fs to reorgnize the new logical volumn
# resize2fs /dev/rootvg/LogVolVM01

5. mount the logical volumn to the file sytem
# mount /dev/rootvg/LogVolVM01 /vm

http://www.kume.idv.tw/read-226.html

首先,我要說明一下。我用的是Fedora Code 5。所以我以下所用到的指令,全部都有。不需要download 與build任何東西。

第一件事就是載入LVM所需要的module
% modprobe dm-mod ==> 我的不work, 可能是沒有module

接著就是找出partiton中的VG(Volume Group),以我的狀況為例,我將硬碟以usb連接到電腦後,由dmesg可以知道有 /dev/sda1, /dev/sda2兩個patitons,在以 fdisk -l /dev/sda 可以知道/dev/sda2是LVM格式。接著,我就執行:
% pvscan ==> Fedora Rescue disc 沒有包含這個程式
PV /dev/sda2 VG VolGroup00 lvm2 [18.50 GB / 32.00 MB free]
Total: 1 [18.50 GB] / in use: 1 [18.50 GB] / in no VG: 0 [0 ]

從以上結果,我可以知道我有一個VG,叫做VolGroup00,他的PV(Physical Volume)是 /dev/sda2

接著我就執行:
% vgchange -ay VolGroup00 ==>我測試是不用加VolGroup00 參數, 只要% cgchange -ay 就會在/dev/ 下面產生一個VolGroup00 folder, 並且在這個目錄下產生該有的device(其實是link到/dev /mapper下)。
% ls /dev/VolGroup00/
LogVol00 LogVol01

這時候vgchange會在/dev下產生一個VolGroup00的目錄,並且在這個目錄下產生該有的device(其實是link到/dev /mapper下)。然後我利用 ls就可以知道VolGroup00這個VG下有兩個LV(Logical Volume)。分別是LogVol00 與 LogVol01。然後我只要mount我要的就可以了。
% mkdir /mnt/usb
% mount /dev/VolGroup00/LogVol00 /mnt/usb/ ==> 在/dev/VolGroup00/ folder下面會有兩個file, 分別表示LVM的2個檔案, 包含有 /dev/VolGroup00/LogVol00, /dev/VolGroup00/LogVol01, 這裡的例子是將第一個LVM mount 到/mnt/usb 這個logic folder 下, 然後就可以直接存取 /mnt/usb 這個路徑去抓LVM 1的data了


Q. How to rescue the HD with LVM file system?
A.
1. Insert the Fedora disc 1, enter rescue mode.
2. Issue the following commands to find the LVM partitions
# lvm vgscan
# lvm vgchange -ay
# lvm lvs

// e2fsck -y==>all questions response "yes", -c==>fix bad block file system
# e2fsck -y -c /dev/VolGroup00/LogVol00
# e2fsck -y -c /dev/VolGroup00/LogVol01

沒有留言: