Re: partition table numberings
Ritesh Raj Sarraf <firstname.lastname@example.org> writes:
> My actual swap was /dev/hda5 and my home dir was /dev/hda6.
> I didn't want to risk my /home partition.
> /usr/local partiton (/dev/hda7) was 4.2 GB which, at least in Debian, is
> just too much, so I thought of resizing it. For that I had to shrink it to
> 2.7GB which gave me a new partition of 1.5GB
> But my root partition was /dev/hda8. So the new swap partition got
> numbered /dev/hda9. I got scared that my root could get screwed so I
> deleted both /dev/hda7 (/usr/local/) and /dev/hda9(the other swap).
> And voila, now a bigger problem. My root changed to /dev/hda7. parted did
> warn me about it.
> Then I went for a cigarette and calmed down.
There is much better solution to your problem than grabbing a
cigarette: It's called Logical Volume Management (LVM). With LVM you
can forget about partitioning completely.
With LVM you would create one single partition covering the whole
disk, setting the partition type to 0x8e (LVM), and create a so called
volume group (VG) in that partition. You can then build logical
volumes (LV) in this volume group, which are normal block devices and
which can be used for your file systems and swap spaces, just like you
use normal partitions now. One advantage of LVM is, that the space,
that a logical volume covers, does not need to be contigous in the
volume group. The volume group's space is organized in fixed length
blocks (something like 4MB or 32MB), so called physical extents (PE),
and your logical volumes can use any number of these block in any
order, as long as there available, i.e. not allocated to another
logical volume. There is mapping table that associates each block in
the logical volume with the corresponding extent in the volume group.
This is similar to paging in memory management.
Since the extents of one logical volume do not need to be contigous,
it's easy to resize a logical volume, i.e. allocate more extents or
freeing extents to make them available for other logical volumes.
Debian already contains everything you need to use LVM and it's easy
to do for a new install. For your existing system, you need to
- back up all your data.
- install kernel/modules for LVM, maybe an initrd if you want to / on
LVM, too (I do this for all my systems), and install LVM on your
disk. The easiest way to do this may be to do a fresh install of
Debian (use dpkg --get-selections and --set-selections to keep your
- restore your data.
This is some work but IMHO definitely pays off since you never again
have to deal with partitioning when resizing your file systems and/or
swap spaces. If you buy a larger disk or a second disk, just create a
volume group on it and add it to your volume group. You can use the
space all all disks in the volume group without worrying on which disk
your data are placed (if you don't want to. Of course, you can
control if you need to). If you want to remove one of your disks,
just move all extents of that disk to the other disks (with only one
command pvmove) and your done.
LVM can make life *so much* easier when resizing, installing or
deinstalling disks, etc. Use it.