pantz.org banner
Resizing an ext3 filesystem
Posted on 04-28-2006 00:23:00 UTC | Updated on 04-28-2006 00:23:00 UTC
Section: /software/ext3filesystem/ | Permanent Link

Using the program partimage you can make backups of many kinds of os partitions. Think of it as a free Norton Ghost. Well when you make a image of a partition with partimage you take a snapshot of the partition at a certian size. Using fdisk (the linux fdisk) you can see how man blocks of space the partition is using on the disk and what area they start at and end on. If you use the same disk to put your image back on it already has the partitions setup so you just restore it and away you go. Well when you want to restore your image to a new disk with no partition info on it you have to make sure your create a partition with equal to or more blocks than the orginal image. This is so your old image will fit into the new partition your creating.

I had a partition image that took up a total of 5 Gig of space on one partition. I wanted to put it on a new disk with a partition that was 250 Gig. Now this will work because the old image will fit into the new partition with room to spare. The problem is that the filesystem on the image was created using only 5 Gig of space. So that's all it knows about. So when you put 5 Gig partition image back into a 250 Gig partition the operating system only sees 5 Gig. Even though the partition is 250 Gig. So what are we to do?

We need to create the 250 Gig partition on the new disk. Put the 5 Gig partition image onto the new disk. Then resize the filesystem to it's new size. I had to do this with an ext3 filesystem. But there are no ext3 filesystem resizing programs. Well there is a way around that. This was done from a bootable linux distro. On an PATA harddrive. Below are the steps do it.

Make a partition on the new hd. Bigger than the one from the image. That's the whole point of this. I'm using parted to partition.

parted -s /dev/hda mkpart primary ext3 0 250G

Make a swap partition

parted -s /dev/hda mkpart primary linux-swap 250G 251G

Make partition 1 bootable

parted -s /dev/hda set 1 boot on

Create the swap area.

mkswap /dev/hda2

Use partimage to put your smaller partition image back. I have a partimage server setup to distribute images.

partimage -b restore --server=192.168.1.1 /dev/hda1 imagename.000

Now that the image is back on the partition we need to remove the ext3 journal essentially creating an ext2 fs.

tune2fs -O ^has_journal /dev/hda1

Do a file system check and fix.

e2fsck -f -y /dev/hda1

Resize the filesystem with resize2fs. In debian it's part of the e2fsprogs package.

resize2fs -p /dev/hda1

Make the ext2 fs an ext3 fs again.

tune2fs -j /dev/hda1

This is only if you need to put a boot loader like grub on. Just type "grub" and do the following commands. PATA hd's are hda SATA hd's are sda.

device (hd0) /dev/hda
root (hd0,0)
setup (hd0)
makeactive
quit

Reddit!

Related stories


RSS Feed RSS feed logo

About


3com

3ware

alsa

alsactl

alsamixer

amd

android

apache

areca

arm

ati

auditd

awk

badblocks

bash

bind

bios

bonnie

cable

carp

cat5

cdrom

cellphone

centos

chart

chrome

chromebook

cifs

cisco

cloudera

comcast

commands

comodo

compiz-fusion

corsair

cpufreq

cpufrequtils

cpuspeed

cron

crontab

crossover

cu

cups

cvs

database

dbus

dd

dd_rescue

ddclient

debian

decimal

dhclient

dhcp

diagnostic

diskexplorer

disks

dkim

dns

dos

dovecot

drac

dsniff

dvdauthor

e-mail

echo

editor

emerald

encryption

ethernet

expect

ext3

ext4

fat32

fedora

fetchmail

fiber

filesystems

firefox

firewall

flac

flexlm

floppy

flowtools

fonts

format

freebsd

ftp

gdm

gmail

gnome

google

gpg

greasemonkey

greylisting

growisofs

grub

hacking

hadoop

harddrive

hba

hex

hfsc

html

html5

http

https

hulu

idl

ie

ilo

intel

ios

iperf

ipmi

iptables

ipv6

irix

javascript

kde

kernel

kickstart

kmail

kprinter

krecord

kubuntu

kvm

lame

ldap

linux

logfile

lp

lpq

lpr

maradns

matlab

memory

mencoder

mhdd

mkinitrd

mkisofs

moinmoin

motherboard

mouse

movemail

mplayer

multitail

mutt

myodbc

mysql

mythtv

nagios

nameserver

netflix

netflow

nginx

nic

ntfs

ntp

nvidia

odbc

openbsd

openntpd

openoffice

openssh

openssl

openvpn

opteron

parted

partimage

patch

perl

pf

pfflowd

pfsync

photorec

php

pop3

pop3s

ports

postfix

power

procmail

proftpd

proxy

pulseaudio

putty

pxe

python

qemu

r-studio

raid

recovery

redhat

router

rpc

rsync

ruby

saltstack

samba

schedule

screen

scsi

seagate

seatools

sed

sendmail

sgi

shell

siw

smtp

snort

solaris

soundcard

sox

spam

spamd

spf

spotify

sql

sqlite

squid

srs

ssh

ssh.com

ssl

su

subnet

subversion

sudo

sun

supermicro

switches

symbols

syslinux

syslog

systemd

systemrescuecd

t1

tcpip

tcpwrappers

telnet

terminal

testdisk

tftp

thttpd

thunderbird

timezone

ting

tls

tools

tr

trac

tuning

tunnel

ubuntu

unbound

vi

vpn

wget

wiki

windows

windowsxp

wireless

wpa_supplicant

x

xauth

xfree86

xfs

xinearama

xmms

youtube

zdump

zeromq

zic

zlib