Grow an ext3 partition to maximum available size
Grow an ext3 partition to maximum available size
This document shows the commands I used and the output for growing an ext3 partition
to the maximum available size.
This procedure was performed after booting using a knoppix CD so that the file systems
are unused. These manual steps were performed because QTParted currently cannot resize an ext3 filesystem.
I have linked each of the commands used to the man pages for the command.
I have highlighted the commands you type in with a yellow background.
I have highlighted some of the output worth noting with a lime background.
Data is not destroyed during this process
Data is not destroyed during this process if no errors are made or encountered, however:
Changing the partition size is a potentially dangerous operation. When fiddling with partitions, there's always a chance that something goes wrong and that you loose all data.
I would strongly suggest a full backup or multiple backups be performed prior to performing this process.
Become the root user - gather some data
If you boot knoppix from CD or USB you can become root without a password
and simulate an initial login easily with the first command below:
knoppix@1[knoppix]$ sudo -i
root@1[~]# fdisk -l
Disk /dev/hda: 5242 MB, 5242503168 bytes
16 heads, 63 sectors/track, 10158 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 1 9092 4582336+ 83 Linux
root@1[~]# fdisk -s /dev/hda1
4582336
Now perform the actual change.
root@1[~]# fsck -n /dev/hda1
fsck 1.39-WIP (09-Apr-2006)
e2fsck 1.39-WIP (09-Apr-2006)
/dev/hda1: clean, 119252/573440 files, 745555/1145584 blocks
root@1[~]# e2fsck -f /dev/hda1
e2fsck 1.39-WIP (09-Apr-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/hda1: 119252/573440 files (2.6% non-contiguous), 712753/1145584 blocks
root@1[~]# fdisk /dev/hda
The number of cylinders for this disk is set to 10158.
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): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-10158, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10158, default 10158):
Using default value 10158
Command (m for help): a
Partition number (1-4): 1
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
root@1[~]# resize2fs /dev/hda1
resize2fs 1.39-WIP (09-Apr-2006)
Resizing the filesystem on /dev/hda1 to 1279900 (4k) blocks.
The filesystem on /dev/hda1 is now 1279900 blocks long.
root@1[~]# tune2fs -j /dev/hda1
tune2fs 1.39-WIP (09-Apr-2006)
Creating journal inode: done
This filesystem will be automatically checked every -1 mounts or
0 days, whichever comes first. Use tune2fs -c or -i to override.
That's all Folks!
I really wanted to do this the simple way with QTParted but the resize option
was greyed out. I did however capture before
and after images of the QTParted view.
I could have gotten the whole process from page 2 of the
How To Resize ext3 Partitions Without Losing Data
pages at HowToForge.com by Falko Timme but I had actually done the process
after reading page 1 which covers
shrinking
an ext3 partition before I noticed the other pages.
His page includes three shutdowns and I found that the entire process can be done
sequentially using the knoppix CD or USB environment without a shutdown.
In my case I was actually growing a partition on a Virtual Hard Drive.
My full process included backing up the Virtual Hard Drive on the host
as well as with dd, fsdisk and partimage, deleting the Virtual Hard Drive
and creating a larger on, then restoring with dd, fsdisk and partimage
prior to this process.
I use a fixed size virtual hard drive in my virtual machine for Linux for
performance reasons.
Last updated: Tuesday, June 9, 2009 @ 9:59:40 PM (Alaska Time)
167 visits (1 today, 1 this week, 23 this
month, 167 this year)
Uptime: 03:22:35 up 4 days, 9:06, 3 users, load average: 0.00, 0.00, 0.00
18.118.24.176 GET from server
z.larrymurakami.com
Sunday, December 22, 2024 @ 3:22:35 AM
z.ServerAdmin@lam1.us