|
출처: http://kbase.redhat.com/faq/docs/DOC-3175
ONLINE상에서 가능하다
그러나 사실 이 방법은 그리 권장하지는 않는듯하다.
아래의 문서를 보면 미리 데이타를 백업해두면 좋고, resize 후에도 UMOUNT 하고 e2fsck등으로 파일시스템을 체크할 것을 권장하고 있다.
왠만하면 파일시스템을 umount 한 후에 정상적인 상황에서 resize하는 것을 권장하겠다.
Release Found: Red Hat Enterprise Linux 4
It is recommended that a resizing procedure be tested before performing it on a filesystem that contains critical data. It is also strongly recommended that data backups are created and verified before resizing filesystems. To assist the reader in becoming familiar with the resizing procedure, the rest of this article describes a scenario in which un-partitioned disk space is used to test logical volume and ext3 filesystem resizing.
In this test procedure, first we create a new partition (/dev/hda2) using un-partitioned disk space. A new volume group (TestVG) and logical volume (TestLV) are then created using a physical volume created on the partition. An ext3 filesystem is then created on the logical volume, it is checked, and then mounted. A new physical volume (/dev/hda3) using the rest of the un-partioned disk space is then created and added to the volume group and logical volume. Finally, the filesystem on the logical volume is increased, and the integrity of the filesystem is checked.
In this test procedure, the parted, lvm, mount, mkfs.ext3, df, e2fsck and ext2online programs are used. The reader is encouraged to become familiar with these programs by consulting the manual pages. For example:
# man parted
PARTED(8) GNU Parted Manual PARTED(8)
NAME
GNU Parted - a partition manipulation program
SYNOPSIS
parted [options] [device [command [options...]...]]
...
The parted and lvm programs can be run in either interactive or non-interactive mode. This article restricts all the examples to non-interactive modes. The reader is also encouraged to consult the parted and lvm online help available for all their built in commands to understand the command syntax for these programs.
The parted program can be used to verify that un-partitioned disk space is available using the print command:
# parted /dev/hda print
Disk geometry for /dev/hda: 0.000-76318.054 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot
4 31118.093 76316.594 extended
5 31220.099 76316.594 logical ext3 lvm
Information: Don't forget to update /etc/fstab, if necessary.
In this case the output of the parted print command shows that there is unallocated space between 101.975 (At the end of partition 1) to 31118.093 (The beginning of partition 4) on the /dev/hda device.
A new partition is created using only some of the available disk space, using the parted mkpart command, then the printcommand is used to verify:
# parted /dev/hda "mkpart primary 101.976 2500"
Information: Don't forget to update /etc/fstab, if necessary.
# parted /dev/hda print
Disk geometry for /dev/hda: 0.000-76318.054 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot
2 101.975 2502.312 primary ext3
4 31118.093 76316.594 extended
5 31220.099 76316.594 logical ext3 lvm
Information: Don't forget to update /etc/fstab, if necessary.
After the new partition is created, the partition table must be re-read by the kernel before the new partition can be utilized. This can be done by either rebooting the system or by running the partprobe command.
The lvm program is used to manipulate LVM2 volume groups, logical volumes and physical volumes. First use the lvm pvscommand to list the physical volumes already present. Then the pvcreate command is used to create the new physical volume using the new partition, and the pvs command again to verify the new physical volume:
# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hda5 VolGroup00 lvm2 a- 44.03G 0
# lvm pvcreate /dev/hda2
Physical volume "/dev/hda2" successfully created
# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 lvm2 -- 2.34G 2.34G
/dev/hda5 VolGroup00 lvm2 a- 44.03G 0
When creating a new volume group, at least one physical volume must be available. That physical volume must be used to create the new volume group. Notice that a volume group called VolGrouop00 already exists:
# lvm vgs
VG #PV #LV #SN Attr VSize VFree
VolGroup00 1 2 0 wz--n 44.03G 0
# lvm vgcreate TestVG /dev/hda2
Volume group "TestVG" successfully created
# lvm vgs
VG #PV #LV #SN Attr VSize VFree
TestVG 1 0 0 wz--n 2.34G 2.34G
VolGroup00 1 2 0 wz--n 44.03G 0
Note that new volume groups must be activated using the lvm vgchange -a y command:
# lvm vgchange -a y TestVG
0 logical volume(s) in volume group "TestVG" now active
Now there is a new directory in /dev for the volume group:
# ls -ld /dev/TestVG
drwx------ 2 root root 60 Jan 17 17:48 /dev/TestVG
In this case I wish to allocate all of the volume group's physical extents (available disk space) to a new logical volume. First, use the lvm vgdisplay command to show details of the TestVG volume group:
# lvm vgdisplay TestVG
--- Volume group ---
VG Name TestVG
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 2.34 GB
PE Size 4.00 MB
Total PE 598
Alloc PE / Size 0 / 0
Free PE / Size 598 / 2.34 GB
VG UUID ebStj9-3KYx-asoc-JBt3-N9kU-vONW-4VdpTB
The total free physical extent of the volume group is "Free PE / Size 598 / 2.34 GB". Use the value 598 in the lvm lvcreatecommand to create the new logical volume:
# lvm lvs
LV VG Attr LSize Origin Snap% Move Copy%
LogVol00 VolGroup00 -wi-ao 43.03G
LogVol01 VolGroup00 -wi-ao 1.00G
# lvm lvcreate -l598 TestVG -nTestLV
Logical volume "TestLV" created
# lvm lvs
LV VG Attr LSize Origin Snap% Move Copy%
TestLV TestVG -wi-a- 2.34G
LogVol00 VolGroup00 -wi-ao 43.03G
LogVol01 VolGroup00 -wi-ao 1.00G
Now a new device has been added to the /dev/TestVG directory:
# ls -l /dev/TestVG
total 0
lrwxrwxrwx 1 root root 25 Jan 17 17:48 TestLV -> /dev/mapper/TestVG-TestLV
The new device is in fact a symbolic link to /dev/mapper/TestVG-TestLV which is the device node created by the device mapper.
The new file system on the logical volume is created by using the mkfs.ext3 program:
# mkfs.ext3 /dev/TestVG/TestLV
mke2fs 1.35 (28-Feb-2004)
max_blocks 627048448, rsv_groups = 19136, rsv_gdb = 149
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
306432 inodes, 612352 blocks
30617 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=629145600
19 block groups
32768 blocks per group, 32768 fragments per group
16128 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Writing inode tables: done
inode.i_blocks = 7160, i_size = 4243456
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
Then check the file system using e2fsck program:
# e2fsck -f /dev/TestVG/TestLV
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/TestVG/TestLV: 11/306432 files (9.1% non-contiguous), 18728/612352 blocks
Before mounting the new file system , create a new mount point, then mount the new logical volume's file system on that mount point. After mounting the file system, run the df program to verify the disk space available:
# mkdir /mnt/test
# mount /dev/TestVG/TestLV /mnt/test
# df -h /mnt/test
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/TestVG-TestLV
2.3G 36M 2.2G 2% /mnt/test
This is the general procedure to increase a filesystem. Begin by adding a new physical volume.
Using parted as before, run the print command to view the partitions, and then mkpart to create a new partition, and runpartprobe to reload the partition table:
# parted /dev/hda print
Disk geometry for /dev/hda: 0.000-76318.054 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot
2 101.975 2502.312 primary ext3
4 31118.093 76316.594 extended
5 31220.099 76316.594 logical ext3 lvm
Information: Don't forget to update /etc/fstab, if necessary.
There is un-partitioned disk space available between 2502.312 (The end of partition 2) and 31118.093 (The beginning of partition 4):
# parted /dev/hda "mkpart primary 2502.313 31118.092"
Information: Don't forget to update /etc/fstab, if necessary.
# parted /dev/hda print
Disk geometry for /dev/hda: 0.000-76318.054 megabytes
Disk label type: msdos
Minor Start End Type Filesystem Flags
1 0.031 101.975 primary ext3 boot
2 101.975 2502.312 primary ext3
3 2502.312 31118.093 primary
4 31118.093 76316.594 extended
5 31220.099 76316.594 logical ext3 lvm
Information: Don't forget to update /etc/fstab, if necessary.
# partprobe
The new physical volume is created as before, by running the lvm pvcreate command. The new physical volume will be on/dev/hda3:
# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 TestVG lvm2 a- 2.34G 0
/dev/hda5 VolGroup00 lvm2 a- 44.03G 0
# lvm pvcreate /dev/hda3
Physical volume "/dev/hda3" successfully created
# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 TestVG lvm2 a- 2.34G 0
/dev/hda3 lvm2 -- 27.94G 27.94G
/dev/hda5 VolGroup00 lvm2 a- 44.03G 0
The physical volume is added to the TestVG volume group using the lvm vgextend command:
# lvm vgextend TestVG /dev/hda3
Volume group "TestVG" successfully extended
# lvm pvs
PV VG Fmt Attr PSize PFree
/dev/hda2 TestVG lvm2 a- 2.34G 0
/dev/hda3 TestVG lvm2 a- 27.94G 27.94G
/dev/hda5 VolGroup00 lvm2 a- 44.03G 0
As before, first look at the physical extent of the volume group using the lvm vgdisplay command. It shows that TestVG has 7153 free extents in "Free PE / Size 7153 / 27.94 GB":
# lvm vgdisplay TestVG
--- Volume group ---
VG Name TestVG
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 3
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 30.28 GB
PE Size 4.00 MB
Total PE 7751
Alloc PE / Size 598 / 2.34 GB
Free PE / Size 7153 / 27.94 GB
VG UUID ebStj9-3KYx-asoc-JBt3-N9kU-vONW-4VdpTB
To use all the free physical extents on the volume group, use the lvm lvextend command with the option -l+7153. This adds the 7153 free extents to the logical volume:
# lvm lvextend -l+7153 /dev/TestVG/TestLV
Extending logical volume TestLV to 30.28 GB
Logical volume TestLV successfully resized
The file system now has space on the logical volume in which to grow.
After extending the volume group and the logical volume, it is now possible to increase the file system. This is done usingext2online. First, verify the file system size, perform the resize, and then verify the size again:
# df -h /mnt/test
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/TestVG-TestLV
2.3G 36M 2.2G 2% /mnt/test
# ext2online /dev/TestVG/TestLV
ext2online v1.1.18 - 2001/03/18 for EXT2FS 0.5b
# df -h /mnt/test
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/TestVG-TestLV
30G 39M 29G 1% /mnt/test
The file system should be un-mounted before doing a file system check:
# e2fsck -f /dev/TestVG/TestLV
e2fsck 1.35 (28-Feb-2004)
/dev/TestVG/TestLV is mounted.
WARNING!!! Running e2fsck on a mounted filesystem may cause
SEVERE filesystem damage.
Do you really want to continue (y/n)? no
check aborted.
# umount /mnt/test
# e2fsck -f /dev/TestVG/TestLV
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/TestVG/TestLV: 11/3919104 files (9.1% non-contiguous), 132827/7937024 blocks
The procedure to test online resizing of filesystems is quite complex. It is important to practice the procedure and become familiar with the programs and commands. Once this is done, and reasonable precautions such as backing up important data are taken, it should be safe to resize your filesystems.