[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to reclaim space on hard drive not partitioned fully initially?



Mitchell Laks wrote:
Long ago, in a galaxy far away, I partitioned my 120GB hard drive.
I think that I did not allocate all the space to used partitions.

i mounted /boot at /dev/hda1
	  /     at /dev/hda2
	  /home at /dev/hda3
swap at /dev/hda5.

me:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda2              19G   16G  1.7G  91% /
tmpfs                 507M  4.0K  507M   1% /dev/shm
/dev/hda1              89M   24M   60M  29% /boot
/dev/hda3              19G   17G  557M  97% /home
tmpfs                 507M  148K  507M   1% /dev


Not that I see only 39GB used here.

Now I am running out of room and I want to use the rest of the space on the disk.

fdisk /dev/hda

p

Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
   /dev/hda1   *           1          12       96358+  83  Linux
   /dev/hda2              13        2444    19535040   83  Linux
   /dev/hda3            2445        4876    19535040   83  Linux
   /dev/hda4            4877        5119     1951897+   5  Extended
   /dev/hda5            4877        5119     1951866   82  Linux swap

You have a total of 14593 tracks, of which 51120 are allocated,
or about 1/3. Incidentally, (120GB)*(1/3) ~ 40GB.

   Command (m for help): n
   No free sectors available

This is correct. You have no free sectors available. With
normal partitioning schemes, you get no more than 4 partitions.
You have used all your PT entries up, so no more allocation
can be done.

Why does fdisk find no free space?

Well, not exactly finding no free space. It told you what you
have. It didn't say nothing was free, it said nothing free
was available. Not quite the same thing.

When I run qtparted it says

number partition type status size used space start end label
04 /dev/hda4 extended   1.86GB
05 /dev/hda5 linux-swap 1.86GB
06 /dev/hda-1 free    72.57GB     N/A   39.21GB   111.79

Perhaps a better way to think of this is not so much that the
space is "free" as "unallocated". It is also, in this case,
"unallocatable". Is something which is not allocatable free?

Sectors on discs using standard partitioning schemes actually have
three states: (1) allocated, (2) allocatable, and (3) unallocatable.

For example, the MBR is always unallocatable, and can never be
part of any partition.

You have unallocatable sectors for another reason, you have run
out of allocation entries.

It seems I left out alot of space from the logical (extended) partition - how do I reclaim it? Also can someone tell me where I can read more about this issue?

Reclaim is a strong term. It has not been lost, so it cannot be
reclaimed. The easiest route from here is to enlarge the extended
partition, and create one or more logical volumes in there (I'm
not referring to LVM).

Step one: Backup, and verify the backup. Be sure to include
everything you may need to get back in case of total failure.

Step two: Backup your MBR, including your PT, and also
the first sector of each of the partitions you have created
onto separate medium. I like to use a floppy disc. It is
a good idea not to use a CDROM if you have only one, because
you may need it later when there is a rescue disc in the
CDROM drive. I like floppies because they always work.
A USB flash drive... well, that involves a lot more iffy
(IMO) interactions between software and hardware. Put
a sticker on that floppy (or whatever) and plainly mark
it for what it contains.

REMOVE THAT FLOPPY FROM THE MACHINE, WRITE PROTECT IT, AND STORE IT IN
A SAFE PLACE.

Print a hard copy of your current partition information, using
fdisk and mount. I want to emphasize hard copy. You may also
use the floppy (or whatever). You might also want a hard
copy of /etc/fstab. Use this hard copy as the start of a
written log of all your actions. As you perform each action,
write down the date and time, what the action was, and what the
results were, including any messages or other displays,
as well as what prompted you to perform the action, i.e,
what you hoped to accomplish.

Step three: Boot using a rescue type disc (I like KNOPPIX)
and try expanding the extended partition. QTPARTED may be
able to do what you want. Partition Magic may also be useful.
I'm not an expert with Linux partition management tools.

Step four: Build one or more logical volumes inside
the enlarged extended partition. You may need to recreate
the swap partition. Nice to have that hard copy on hand...

Step five: Remove the rescue disc, and reboot from the
modified hard drive.

If success...

Step six: Ensure that each of the new parititions shows up,
and run mkfs on each to install the file system(s) of
your choice.

Step seven: Do manual mounts, and verify that files can be
created and manipulated.

Step eight: Add entries into /etc/fstab for the new partition(s).

Step nine: Reboot, and verify that all partitions you wanted
auto-mounted get mounted.

Step ten: Enjoy having 3x as much disc space as before!

If failure...

Step six: Boot a rescue disc, and restore the MBR
from the backups you made to floppy (or whatever).

Step seven: Reboot, hopefully to your old configuration.

If that fails...

Step eight: Boot a rescue disc, and compare the
BRs of each partition with those you saved on floppy
(or whatever) and try to explain the differences you
encounter, and restore any which look clobbered, using
your floppy (or whatever). Then return to Step six.
You may want to go easy, and restore the BR for the
extended partition, and go back. If it still fails,
then restore the BR for the logical partition used
for swap. If that fails, then look at doing others.

If that fails...

Step nine: Reload from backup.

The last step is to make a permanent notebook (I
like to use looseleaf, but use what works for you)
with that written log in it. Add to this log, and
keep it near your machine at all times. Any time you
make changes, hardware, software, configuration, etc,
make entries in the log. Keep your floppy around for
a few weeks before recycling it into the floppy pile.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!



Reply to: