Pages

Sunday, November 28, 2010

How To Resize ext3 Partitions Without Losing Data

Assuming this is your partition table:

Dev Type Mount Size
sda1 nt40 nt40 1992M
sda2 linux / 1498M
sda3 swap 117M
sda4 extended 5036M
sda5 swap 117M
sda6 home /home 4910M


-backup your /home on to your tape drive.

-check and make sure the backup worked

-use fdisk to delete the home partition and create several smaller partitions:(make /dev/sda6 about 800 megs)

fdisk /dev/sda

-create a file system on /dev/sda6:

mke2fs /dev/sda6

-mount it and copy all files in /usr to sda6:

mount /dev/sda6 /mnt
cd /usr
ls (sanity check)
cp -a * /mnt
cd /mnt
ls (sanity check)

-change fstab to mount /usr/ as /dev/sda6:

/dev/sda6 /usr ext2 defaults 1 2

Don't leave this one there:

/dev/sda6 /home ext2 defaults 1 2

-reboot and check that everything is okay

mount (Did sda6 appear mounted on /usr?)
startx (Did X start up?)

-reboot into single user mode, umount /usr, and erase the /usr file on sda2:

init 1
cd /
umount /usr (if this doesn't work "fuser -k /usr" and then try again.)
mount (sanity check)
cd /usr
ls (sanity check)
rm -rf *

-reboot and check that disk space
df (or df -h)

No comments:

Post a Comment