Once upon a time, I needed to grow an ext3 filesystem on a partitioned iSCSI volume. Unfortunately, I was unable to use GNU’s parted tool, because newer ext2/3 partitions weren’t supported yet, so here’s what I did to get around that limitation:
1.) First I unmounted the partition and converted it to ext2.
# umount /mnt/sdb1 # /sbin/tune2fs -O ^has_journal /dev/sdb1 tune2fs 1.32 (09-Nov-2002) # /sbin/e2fsck -y /dev/sdb1 e2fsck 1.32 (09-Nov-2002) /dev/sdb1: clean, 179076/10502144 files, 20365394/20974076 blocks
2.) Then I used fdisk to delete my old partiton and immediately recreate a larger one. The important thing to note here is that the new starting block was the same as the old one.
# fdisk /dev/sdb The number of cylinders for this disk is set to 153600. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): p Disk /dev/sdb: 161.0 GB, 161061273600 bytes 64 heads, 32 sectors/track, 153600 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 81930 83896304 83 Linux Command (m for help): d Selected partition 1 Command (m for help): p Disk /dev/sdb: 161.0 GB, 161061273600 bytes 64 heads, 32 sectors/track, 153600 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-153600, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-153600, default 153600): Using default value 153600 Command (m for help): p Disk /dev/sdb: 161.0 GB, 161061273600 bytes 64 heads, 32 sectors/track, 153600 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 153600 157286384 83 Linux Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
3.) Check the partition.
# e2fsck -f /dev/sdb1 e2fsck 1.32 (09-Nov-2002) 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/sdb1: 179076/10502144 files (17.8% non-contiguous), 20365394/20974076 blocks
4.) Now it’s possible to grow the filesystem.
# resize2fs /dev/sdb1 resize2fs 1.32 (09-Nov-2002) The filesystem on /dev/sdb1 is now 39321596 blocks long.
5.) The final step is to convert back to ext3 and remount the partition.
# /sbin/tune2fs -j /dev/sdb1 tune2fs 1.32 (09-Nov-2002) Creating journal inode: done This filesystem will be automatically checked every 39 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. # mount -t ext3 /dev/sdb1 /mnt/iscsi
Thats it! But this process shows why it’s a good idea not to partition your iscsi volumes at all, if you ever intend on making them larger (ie: use /dev/sda instead of /dev/sda1,2,n). That way, you don’t have to mess with fdisk in order to grow the volume.
0 Response to “Resizing an ext3 filesystem on a partitioned iSCSI volume”