This assumes you have done [[howto:install_debian]] already and want
to set up LVM on it.L et's get LVM running now. We will install lvm2
first:
server:~# apt-get install lvm2
Now create the volume group from /dev/md1:
server:~# pvcreate /dev/md1
Physical volume "/dev/md1" successfully created
server:~# vgcreate vg0 /dev/md1
Volume group "vg0" successfully created
Once we have a volume group, we can create logical volumes from it.
Let create a 10GB volume for /home:
server:~# lvcreate -L 10G -n home vg0
Logical volume "home" created
server:~# vi /etc/fstab
Add a line:
/dev/vgo/home /home ext3 defaults 0 2
Now create the filesystem and mount it:
server:~# mke2fs -j /dev/vg0/home
server:~# mount /home
kjournald starting. Commit interval 5 seconds
EXT3 FS on dm-0, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
The nice thing about LVM is that it's very flexible. We can create as
many logical volumes as we like from the volume group. If one is too
small, we can make it bigger. For instance, suppose we need to make
/home 20GB. We can do the following:
server:~# umount /home
server:~# lvresize -L20G /dev/vg0/home
Extending logical volume home to 20.00 GB
Logical volume home successfully resized
server:~# e2fsck -f /dev/vg0/home
e2fsck 1.40-WIP (14-Nov-2006)
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/vg0/home: 11/1310720 files (9.1% non-contiguous), 79697/2621440 blocks
server:~# resize2fs /dev/vg0/home
resize2fs 1.40-WIP (14-Nov-2006)
Resizing the filesystem on /dev/vg0/home to 5242880 (4k) blocks.
The filesystem on /dev/vg0/home is now 5242880 blocks long.
server:~# mount /home
kjournald starting. Commit interval 5 seconds
EXT3 FS on dm-0, internal journal
EXT3-fs: mounted filesystem with ordered data mode.
server:~#
If we get a newer kernel running on this thing, we will be able to
increase the size without unmounting the volume. You can also
decrease the size if you like, but that's more difficult as you have
to calculate carefully, decrease the filesystem size first, then decrease
the logical volume size.