Thursday, March 22, 2012

Extending ext3 filesystems

Ok, so in the above post we created a couple of filesystems on a couple of luns. But we created them at 10Meg each, hardly useful in today's world. We need to extend that to say 5gig, much more useful. Another scour of the Internet turns up little useful. Let's do it here, again Redhat ES4.8. Not you must umount the filesystem first. Also note, if you try the resize2fs first it will tell you to run the e2fsck first, so do that part first as shown below.


[root@somesystem /]# e2fsck -f /dev/testvg1/lvol0
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/testvg1/lvol0: 159/3072 files (1.9% non-contiguous), 10395/12288 blocks
[root@somesystem /]# resize2fs -p /dev/testvg1/lvol0
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/testvg1/lvol0 to 5255168 (1k) blocks.
Begin pass 1 (max = 640)
Extending the inode table     XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/testvg1/lvol0 is now 5255168 blocks long.

[root@somesystem /]# mount /dev/testvg1/lvol0 /vg1
[root@somesystem /]#

Linux logical volumes, volume groups, and resizing ext3 filesystems

Ever scoured the Internet looking for how-to's on dealing with san volumes on Linux? Building new volume groups? Logical volumes? How about resizing an ext3 filesystem? More from our personal cookbook.

Let's start with building some filesystems on new san storage. This assumes you've got luns mapped to your Linux system, and multipath configured. Look for an upcoming blog post on multipathing, all steps here performed on Redhat ES4.8.

#pvcreate /dev/mapper/mpath0

  Physical volume "/dev/mapper/mpath0" successfully created

[root@somesystem /]# vgcreate testvg1 /dev/mapper/mpath0
  Volume group "testvg1" successfully created
[root@somesystem /]# vgcreate testvg1 /dev/mapper/mpath1
  A volume group called 'testvg1' already exists.
[root@somesystem /]# vgcreate testvg2 /dev/mapper/mpath1
  Volume group "testvg2" successfully created
[root@somesystem /]#

lvm> lvcreate -L 10M testvg1
  Rounding up size to full physical extent 12.00 MB
  Logical volume "lvol0" created
lvm> lvcreate -L 10M testvg2
  Rounding up size to full physical extent 12.00 MB
  Logical volume "lvol0" created
lvm>

lvm> lvscan
  ACTIVE            '/dev/testvg2/lvol0' [12.00 MB] inherit
  ACTIVE            '/dev/testvg1/lvol0' [12.00 MB] inherit
lvm>

[root@somesystem /]# mkfs.ext3 /dev/testvg1/lvol0
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
3072 inodes, 12288 blocks
614 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=12582912
2 block groups
8192 blocks per group, 8192 fragments per group
1536 inodes per group
Superblock backups stored on blocks:
        8193

Writing inode tables: done                           
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@somesystem /]#


[root@somesystem /]#
[root@somesystem /]# mount /dev/testvg1/lvol0 /vg1
mount: mount point /vg1 does not exist
[root@somesystem /]# mkdir vg1
[root@somesystem /]# mount /dev/testvg1/lvol0 /vg1
[root@somesystem /]# mkfs.ext3 /dev/testvg2/lvol0
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
3072 inodes, 12288 blocks
614 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=12582912
2 block groups
8192 blocks per group, 8192 fragments per group
1536 inodes per group
Superblock backups stored on blocks:
        8193

Writing inode tables: done                           
Creating journal (1024 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@somesystem /]# mkdir vg2
[root@somesystem /]# mount /dev/testvg2/lvol0 /vg2
[root@somesystem /]#