ページ更新: 2005-01-23 (日) (6701日前)
Debian GNU/Linux 3.0 (woody)で、LVMします。 目次 [編集]情報源 #スラッシュドット ジャパン | RedHatが米Sistina社を買収、全技術をオープンソースで提供へ (2003.12.22) Sistina - Products (Logical Volume Manager) lists.sistina.com Mailing Lists LVM2 Resource Page (2004-07-31) The linux-lvm Archives (2004-07-31) JF - Logical Volume Manager HOWTO developerWorks - Linux LVMについて学ぶ、第1回 developerWorks - Linux LVMについて学ぶ: 第2回 developerWorks - アドバンスト・ファイルシステム・インプリメンター・ガイド 第13回 @IT:Linux Square - LVMによる自動バックアップ・システムの構築 ITmedia:エンタープライズ: Linux - 特集:LVMによるディスクパーティションの動的化 (前編) ITmedia:エンタープライズ: Linux - 特集:LVMによるディスクパーティションの動的化 (後編) Software RAID & LVM on Vine linux (2004.02.04 追加)
lvmパッケージを調べる #まずはLVMと名が付くパッケージを検索し、説明を読む。 # apt-cache search ^lvm lvm-common - The Logical Volume Manager for Linux (common files) lvm10 - The Logical Volume Manager for Linux (ちなみに Debian/sargeだと他にもパッケージがある。lvm2ってのはたぶんLVM2.0。) # apt-cache search ^lvm lvm-common - The Logical Volume Manager for Linux (common files) lvm10 - The Logical Volume Manager for Linux lvm2 - The Linux Logical Volume Manager webmin-lvm - lvm control module for webmin # apt-cache show lvm10 Package: lvm10 Status: install ok installed Priority: optional Section: admin Installed-Size: 6015 Maintainer: Patrick Caulfield <patrick@debian.org> Version: 1:1.0.4-4 Provides: lvm-binaries Depends: libc6 (>= 2.2.4-4), lvm-common (>> 1.0), file Conflicts: lvm (<< 1:0) Description: The Logical Volume Manager for Linux LVM includes all of the support for handling read/write operations on physical volumes (hard disks, RAID-Systems, magneto optical, etc., multiple devices (MD), see mdadd(8) or even loop devices, see losetup(8)), creating volume groups from one or more physical volumes and creating one or more logical volumes in volume groups. . This provides the IO protocol version 10 compatible binaries (LVM 0.9.x/1.0.x). ふむふむ。要するにLVM 0.9.x/1.0.x用のパッケージなのだな。特にSuggestsはなし。 # apt-cache show lvm-common Package: lvm-common Status: install ok installed Priority: optional Section: admin Installed-Size: 72 Maintainer: Robert van der Meulen <rvdm@debian.org> Version: 1.5.5 Replaces: lvm Depends: libc6 (>= 2.2.4-4), modutils (>> 2.3.11-2), binutils Recommends: logrotate Suggests: ext2resize Conflicts: lvm, lvm5 (<= 0.8i-4), lvm6 (<= 0.8.final-2), lvm10 (<= 0.9-1) Conffiles: /etc/init.d/lvm 14be25cb73cd6fd7456fed1290434f02 /etc/devfs/conf.d/50lvm c4fe4f81dc2599fec92a898aa06af679 /etc/modutils/lvm-common 512dede474f2d21748e323ab13d0756e /etc/logrotate.d/lvm-common 3e9e6229dbea693db973fb0124062726 Description: The Logical Volume Manager for Linux (common files) LVM includes all of the support for handling read/write operations on physical volumes (hard disks, RAID-Systems, magneto optical, etc., multiple devices (MD), see mdadd(8) or even loop devices, see losetup(8)), creating volume groups from one or more physical volumes and creating one or more logical volumes in volume groups. . This package includes parts of the LVM packaging which do not depend on the particular IO protocol version of the kernel implementation. You need to install in addition one of lvm5, lvm6, or lvm10. こっちが共通部分(=Common)ね。lvm5とかlvm6ってなんだろう。まあいいや。 (Suggestsの ext2resizeは面白そうなので、こちらも調べておく) [編集]lvmパッケージをインストールする ## apt-get install lvm10 Reading Package Lists... Done Building Dependency Tree... Done The following extra packages will be installed: lvm-common The following NEW packages will be installed: lvm-common lvm10 0 packages upgraded, 2 newly installed, 0 to remove and 0 not upgraded. Need to get 0B/1999kB of archives. After unpacking 6233kB will be used. Do you want to continue? [Y/n] : (略)[編集] LVMの構成 #現在のパーティションを確認。すでにLVM用の領域 (/dev/hda4) を用意しておいたもの。 こっちのHDDを起動に使うつもりなので、/ /boot swapの領域も用意してある。 hdaがメインで、hdcが非常用。容量が倍違うので、Software RAID1しないことに。 (後で別途HDD2台用意して、Hardware RAID1にするつもりだし) # fdisk -l /dev/hda Disk /dev/hda: 255 heads, 63 sectors, 2482 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/hda1 1 124 995998+ 82 Linux swap /dev/hda2 * 125 136 96390 83 Linux /dev/hda3 137 634 4000185 83 Linux /dev/hda4 635 2482 14844060 8e Linux LVM # fdisk -l /dev/hdc Disk /dev/hdc: 255 heads, 63 sectors, 4865 cylinders Units = cylinders of 16065 * 512 bytes Device Boot Start End Blocks Id System /dev/hdc1 1 124 995998+ 82 Linux swap /dev/hdc2 * 125 136 96390 83 Linux /dev/hdc3 137 634 4000185 83 Linux /dev/hdc4 635 4865 33985507+ 8e Linux LVM PV(phisical volume) を作成する。念のため、作業前後にpvscan、vgscanなどをしつこく実行する。 # pvscan pvscan -- reading all physical volumes (this may take a while...) pvscan -- ERROR "pv_read(): PV identifier invalid" reading physical volumes pvの一覧が表示できない。存在しないからかな。で、1つ作ってみようとすると、 # pvcreate /dev/hda4 pvcreate -- ERROR: "/etc/lvmtab.d" doesn't exist; please run vgscan vgscanを実行せよ、とな。 # vgscan vgscan -- reading all physical volumes (this may take a while...) vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created vgscan -- WARNING: This program does not do a VGDA backup of your volume group # pvcreate /dev/hda4 pvcreate -- physical volume "/dev/hda4" successfully created # pvcreate /dev/hdc4 pvcreate -- physical volume "/dev/hdc4" successfully created # pvscan pvscan -- reading all physical volumes (this may take a while...) pvscan -- inactive PV "/dev/hda4" is in no VG [14.16 GB] pvscan -- inactive PV "/dev/hdc4" is in no VG [32.41 GB] pvscan -- total: 2 [46.57 GB] / in use: 0 [0] / in no VG: 2 [46.57 GB] 無事作成完了。(pvdisplayも試した方がいいね) VG (Volume Group) を作る。1つのVGには複数のPVを入れられるけど、1つのVGにHDDが異なるPVを入れると、HDDが故障したときに(自分が)混乱しそうなので、それぞれ別のVGを作る。 # vgcreate hd20 /dev/hda4 vgcreate -- INFO: using default physical extent size 4 MB vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte vgcreate -- doing automatic backup of volume group "hd20" vgcreate -- volume group "hd20" successfully created and activated # vgcreate hd40 /dev/hdc4 vgcreate -- INFO: using default physical extent size 4 MB vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte vgcreate -- doing automatic backup of volume group "hd40" vgcreate -- volume group "hd40" successfully created and activated # vgscan vgscan -- reading all physical volumes (this may take a while...) vgscan -- found active volume group "hd20" vgscan -- found active volume group "hd40" vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created vgscan -- WARNING: This program does not do a VGDA backup of your volume groups 無事、2つのVGが作成できた。 で、現在使用しているパーティションはこんなの。 要するに、SCSI-HDD×2を使っていて、sdaが/とswap、sdbが/home, /var, /var/www。 # df Filesystem 1k-blocks Used Available Use% Mounted on /dev/sda2 4040028 753460 3081340 20% / /dev/sdb1 5882244 179216 5404224 4% /home /dev/sdb2 5882276 837264 4746204 15% /var /dev/sdb3 5874424 643080 4932940 12% /var/www 今回は、これらのパーティションのうち、/以外をLVMにするので、次のようにLV(Logical Volume)を作成する。容量は後で増やせるので、とりあえず容量の20%程度が埋まる程度の容量を確保する。 # lvcreate -L 4G -n home /dev/hd20 lvcreate -- doing automatic backup of "hd20" lvcreate -- logical volume "/dev/hd20/home" successfully created # lvcreate -L 4G -n var /dev/hd20 lvcreate -- doing automatic backup of "hd20" lvcreate -- logical volume "/dev/hd20/var" successfully created # lvcreate -L 8G -n varwww /dev/hd40 lvcreate -- doing automatic backup of "hd40" lvcreate -- logical volume "/dev/hd40/varwww" successfully created # lvscan lvscan -- ACTIVE "/dev/hd20/home" [4 GB] lvscan -- ACTIVE "/dev/hd20/var" [4 GB] lvscan -- ACTIVE "/dev/hd40/varwww" [8 GB] lvscan -- 3 logical volumes with 16 GB total in 2 volume groups lvscan -- 3 active logical volumes 無事、LVを作成完了。これらをそれぞれext3でフォーマットする。 # mke2fs -j /dev/hd20/home mke2fs 1.27 (8-Mar-2002) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 524288 inodes, 1048576 blocks 52428 blocks (5.00%) reserved for the super user First data block=0 32 block groups 32768 blocks per group, 32768 fragments per group 16384 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 31 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. # mke2fs -j /dev/hd20/var # mke2fs -j /dev/hd40/varwww LVをマウントしてみる。今回は、/mnt以下にエントリを作ってマウントする。 # mkdir /mnt/home /mnt/var /mnt/varwww # mount /dev/hd20/home /mnt/home # mount /dev/hd20/var /mnt/var # mount /dev/hd40/varwww /mnt/varwww # df Filesystem 1k-blocks Used Available Use% Mounted on /dev/sda2 4040028 755440 3079360 20% / /dev/sdb1 5882244 179224 5404216 4% /home /dev/sdb2 5882276 837588 4745880 16% /var /dev/sdb3 5874424 643396 4932624 12% /var/www /dev/hd20/home 4128448 32828 3885908 1% /mnt/home /dev/hd20/var 4128448 32828 3885908 1% /mnt/var /dev/hd40/varwww 8256952 32828 7804696 1% /mnt/varwww OKなので、旧データをコピーする。 この作業を行うには、(1) Single userモードに移って、よけいなデーモンを止めてから、cp -a でファイルをコピーするか、(2) 別のLinuxを立ち上げて作業するか、のいずれか。 ここではKnoppix 3.2をCD-ROMから起動して作業することにする。楽だし。 |