以下は flex を中心としたファイルシステムの理解のために 齋藤が2008.10.9に作成したものである。
LVMを使ってみよう!のページが大変参考になった。感謝する。
[root@flex opt]# vgdisplay -C VG #PV #LV #SN Attr VSize VFree VG 2 6 0 wz--n- 465.66G 153.66G
[root@flex opt]# lvdisplay -C
LV VG Attr LSize Origin Snap% Move Log Copy% Convert LVhome VG -wi-ao 210.00G LVroot VG -wi-ao 10.00G LVrsaito VG -wi-ao 30.00G LVsamba VG -wi-ao 170.00G LVswap VG -wi-ao 2.00G LVwww VG -wi-ao 20.00G
[root@flex rsaito]# lvdisplay --- Logical volume --- LV Name /dev/VG/LVroot VG Name VG LV UUID HwBaP5-T627-4hWH-iRoG-HM1S-SpEN-4f61hQ LV Write Access read/write LV Status available # open 1 LV Size 10.00 GB Current LE 640 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
[root@flex rsaito]# lvextend -L 20G /dev/VG/LVroot [root@flex rsaito]# lvdisplay --- Logical volume --- LV Name /dev/VG/LVroot VG Name VG LV UUID HwBaP5-T627-4hWH-iRoG-HM1S-SpEN-4f61hQ LV Write Access read/write LV Status available # open 1 LV Size 20.00 GB <----- 20GB になった。 Current LE 640 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0
[root@flex rsaito]# df Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/VG-LVroot 10321208 5646440 4150480 58% / [root@flex rsaito]# ext2online /dev/mapper/VG-LVroot ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b 少し時間がかかる。 [root@flex rsaito]# df Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/VG-LVroot 20642428 5651508 13942472 29% /
[root@flex rsaito]# lvreduce -L 30G /dev/VG/LVsamba やってはいけない。
[root@flex /]# lvremove /dev/VG/LVsamba Do you really want to remove active logical volume "LVsamba"? [y/n]: y Logical volume "LVsamba" successfully removed
root@flex /]# lvcreate -L 30G -n LVsamba VG Logical volume "LVsamba" created [root@flex /]# lvdisplay --- Logical volume --- LV Name /dev/VG/LVsamba VG Name VG LV UUID AyaHX0-9n7F-e91Z-zjDM-cnnY-r0qR-lnQXaE LV Write Access read/write LV Status available # open 0 LV Size 30.00 GB Current LE 960 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:2
[root@flex /]# mkfs.ext3 /dev/mapper/VG-LVsamba mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 3932160 inodes, 7864320 blocks 393216 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=8388608 240 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, 1605632, 2654208, 4096000 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 29 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@flex /]# mount -a [root@flex /]# df Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/VG-LVroot 20642428 5651756 13942224 29% / /dev/md0 101018 70139 25663 74% /boot none 2037136 0 2037136 0% /dev/shm /dev/mapper/VG-LVrsaito 30963708 12505368 16885476 43% /rsaito /dev/mapper/VG-LVhome 216745980 201378196 4357736 98% /home /dev/mapper/VG-LVwww 20642428 6448988 13144864 33% /www 172.17.4.129:/pmphdd1 480719072 161010208 295289664 36% /pmphdd /dev/mapper/VG-LVsamba 30963708 77888 29312956 1% /samba
[root@flex opt]# vgdisplay --- Volume group --- VG Name VG System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 17 VG Access read/write VG Status resizable MAX LV 0 Cur LV 6 Open LV 6 Max PV 0 Cur PV 2 Act PV 2 VG Size 465.66 GB PE Size 32.00 MB Total PE 14901 Alloc PE / Size 9984 / 312.00 GB Free PE / Size 4917 / 153.66 GB VG UUID BYvdTx-aZun-99XI-POhe-UMK9-2mck-x9Aets
resize2fs で縮小する。ここでは、削減する前に何も入っていないので中身を退避する必要がないが、通常は退避する必要がある。
[root@flex opt]# umount /dev/mapper/VG-LVsamba [root@flex opt]# fsck.ext3 -f /dev/mapper/VG-LVsamba e2fsck 1.35 (28-Feb-2004) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/mapper/VG-LVsamba: 11/3932160 files (9.1% non-contiguous), 142865/7864320 blocks [root@flex opt]# resize2fs /dev/mapper/VG-L Vsamba 20G resize2fs 1.35 (28-Feb-2004) Resizing the filesystem on /dev/mapper/VG-LVsamba to 5242880 (4k) blocks. The filesystem on /dev/mapper/VG-LVsamba is now 5242880 blocks long.
[root@flex opt]# mount -a [root@flex opt]# df Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/VG-LVroot 20642428 6598612 12995368 34% / /dev/md0 101018 70139 25663 74% /boot none 2037136 0 2037136 0% /dev/shm /dev/mapper/VG-LVrsaito 30963708 12505368 16885476 43% /rsaito /dev/mapper/VG-LVhome 216745980 201378196 4357736 98% /home /dev/mapper/VG-LVwww 20642428 6146096 13447756 32% /www 172.17.4.129:/pmphdd1 480719072 161010208 295289664 36% /pmphdd /dev/mapper/VG-LVsamba 20642428 77888 19515964 1% /samba
[root@flex opt]# lvdisplay -C LV VG Attr LSize Origin Snap% Move Log Copy% Convert LVhome VG -wi-ao 210.00G LVroot VG -wi-ao 20.00G LVrsaito VG -wi-ao 30.00G LVsamba VG -wi-ao 30.00G LVswap VG -wi-ao 2.00G LVwww VG -wi-ao 20.00G
[root@flex opt]# umount /dev/mapper/VG-LVsamba [root@flex opt]# lvreduce -L 20G /dev/VG/LVsamba WARNING: Reducing active logical volume to 20.00 GB THIS MAY DESTROY YOUR DATA (filesystem etc.) Do you really want to reduce LVsamba? [y/n]: y Reducing logical volume LVsamba to 20.00 GB Logical volume LVsamba successfully resized [root@flex opt]# lvdisplay -C LV VG Attr LSize Origin Snap% Move Log Copy% Convert LVhome VG -wi-ao 210.00G LVroot VG -wi-ao 20.00G LVrsaito VG -wi-ao 30.00G LVsamba VG -wi-a- 20.00G LVswap VG -wi-ao 2.00G LVwww VG -wi-ao 20.00G [root@flex opt]# mount -a [root@flex opt]# df Filesystem 1K-ブロック 使用 使用可 使用% マウント位置 /dev/mapper/VG-LVroot 20642428 6598640 12995340 34% / /dev/md0 101018 70139 25663 74% /boot none 2037136 0 2037136 0% /dev/shm /dev/mapper/VG-LVrsaito 30963708 12505368 16885476 43% /rsaito /dev/mapper/VG-LVhome 216745980 201378196 4357736 98% /home /dev/mapper/VG-LVwww 20642428 6146096 13447756 32% /www 172.17.4.129:/pmphdd1 480719072 161010208 295289664 36% /pmphdd /dev/mapper/VG-LVsamba 20642428 77888 19515964 1% /samba [root@flex opt]# cd /samba [root@flex samba]# ls -l 合計 16 drwx------ 2 root root 16384 10月 9 22:33 lost+found