Page 1 of 1

partitioning/ filesystem resize

PostPosted: Tue Apr 05, 2005 1:55 pm
by Master of Reality
if im deleting a partition and making another one bigger, how should i go about deleting the data thats on the partition i dont want anymore?

Re: partitioning/ filesystem resize

PostPosted: Tue Apr 05, 2005 3:49 pm
by Void Main
Master of Reality wrote:if im deleting a partition and making another one bigger, how should i go about deleting the data thats on the partition i dont want anymore?


Basically you don't have to. It will just get overwritten as your other file system inode/allocation table will create inodes or entries for the addresses on that location of disk. It will not know or care that there is/was any data there in a previous life. If you just wanted to wipe clean whatever incriminating data you had there though you could always "dd if=/dev/zero of=/dev/hdXX" where XX is the partition number you want to wipe prior to deleting the partition. Operationally there is no need for it though.

PostPosted: Tue Apr 05, 2005 4:07 pm
by Master of Reality
hmmm.... the drive number ( hdb3, hdb5, et cetera) doesnt actually denote where in the drive it is does it?

I need my hdb3 and would like to extend my hdb4, but im not sure i can looking at the partition table now:
Code: Select all
Device Boot      Start         End      Blocks   Id  System
/dev/hdb1               1         729     5855661   83  Linux
/dev/hdb2            4081        4867     6321577+   f  W95 Ext'd (LBA)
/dev/hdb3            2551        4080    12289725   83  Linux
/dev/hdb4             730        2550    14627182+  83  Linux
/dev/hdb5   *        4081        4867     6321546   83  Linux


is there anyway to extend a partition before the beginning of it?

PostPosted: Tue Apr 05, 2005 5:22 pm
by Void Main
No, you can not extend a partition from the beginning. There must be free space *after* the partition you want to resize. If the space is before you must "slide" the partition to be enlarged forward on the disk so the free space is after it. You can do this with qtparted booted from a KNOPPIX CD or from a 3rd party utility like BootitNG, etc.

Now, the names of the partitions (hda1, hda2, etc) are not nearly as important as the starting and ending cylinder numbers because the partitions don't necessarily have to be in order by name on your disk and yours just happen to *not* be in order. In your case the partition order is:

0 - hdb1 - primary
1 - hdb4 - primary
2 - hdb3 - primary
3 - hdb2 - extended container (containing hdb5)
3-A hdb5

Now which one of those did you want to delete in order to make room to enlarge one of the others? And which one of the others did you want to enlarge?

If you want to get rid of hdb4 and incorporate that space into hdb3 then you have to delete the hdb4 partition (I use /sbin/fdisk for this). After you delete that partition you have to slide hdb3 forward on the disk so it starts where hdb4 used to start (starting cylinder of 730). Again, use qtparted or BootitNG to slide the partition without losing your data. Once you have moved the partition (and it's data) you have to delete the partition and recreate it with the new size. In this example you would recreate your hdb3 Linux partition with the starting cylinder of 730 and an ending cylinder of 4080. Again, I prefer to use /sbin/fdisk for this. Now that you have your partition enlarged you still have to enlarge your file system. Use resize2fs to resize it to the full size of the partition (assuming the file system is ext2 or ext3, use appropriate resize tool for whatever file system you are running). I have done this many times and have never lost any data doing it. With the 2.6 kernel you are actually supposed to be able to resize2fs a live file system but I have never tried it. I feel more comfortable booting from alternate media.

PostPosted: Wed Apr 06, 2005 9:22 am
by Calum
i told you to use parted, MoR, but would you listen? would you? hmm?

:roll: ;-)