Re: changing partition names
On Sun, Feb 14, 2016 at 03:42:33PM -0500, Frank McCormick wrote:
> I have deleted a partition from my HD containing a distro I no longer use.
> As a result, my partitions on /dev/sda are numbered sda1. sda2 (windows) and
> sda4. sda3 contained the distro I dumped.
>
> Can I just use fdisk or fsdisk to dump the existing partition record
> edit the file to change sda4 to sda3 and then use fdisk or sfdisk to
> read the file and create a properly named partition record ?
If it's the names you are concerned about, then I would recommend not
referencing partition numbers or device names directly if at all possible (e.g.
sda3 or sdb). Instead label your filesystems (e2label /dev/sda3 MY_LABEL) and
refer to the labels (/dev/disk/by-label/MY_LABEL) or use UUIDs. These are more
robust against partition changes or disk renumberings.
If you want the space back, well, you can try to do some partition surgery but
make sure you've got good backups first. For fresh setups I'd always recommend
using LVM. If you were already using LVM, you could just reformat the unwanted
partition as an LVM PV, add it to your VG and the space could be re-used,
without having to muck with the partition table at all.
If you are mucking about with the partition tables, bear in mind that the table
itself is like a bunch of pointers; so if you dump the table, edit it and
re-load it, no data itself will have moved: so if the new table points at
different places, you will have lost your filesystems. If you want sda4 to begin
where sda3 used to be, you need to move the filesystem as well as rewrite the
partition table. This is probably something that (g)parted (or partition magic)
can do, but here be dragons, etc.
If the now-spare sda3 was large enough, and you were not already using LVM, I'd
recommend formatting sda3 as an LVM PV and create a new LVM VG, then an LVM LV;
then migrate your data from sda4 into that LV; then format sda4 as an LVM PV and
add that into the VG, so you end up with all the space being available, again
without changing the partition table at all.
--
Jonathan Dowland
Please do not CC me, I am subscribed to the list.
Reply to: