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

Re: changing partition names



On 15/02/16 05:49 AM, Jonathan Dowland wrote:
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.


  I already use UUIDS.

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.


I have the space back already. Maybe I didn't explain it clearly enough but I used Gparted to delete the partition and to enlarge the Debian partition. That's how I ended up with these mis-named partition...i.e. sda1 sda2 sda4.

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.

If I don't touch the beginning or ending of the partitions there should be no problem, right ?


This is probably something that (g)parted (or partition magic)
can do, but here be dragons, etc.

  No neither can handle what I need...but apparently sfdisk can.


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.


Too late for LVM. Next time I reinstall from scratch, I'll take a look at it as it seems to make life more simple.



Thanks


Reply to: