Does deleting a partition below Ubuntu mess up grub?

Colin Law clanlaw at gmail.com
Sun Oct 12 16:12:31 UTC 2014


On 12 October 2014 16:49, Robert Heller <heller at deepsoft.com> wrote:
> At Sun, 12 Oct 2014 15:49:18 +0100 "Ubuntu user technical support,  not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:
>
> Colin wrote:
>>
>> I mis-typed, it is actually sda3 I want to delete.  However, when I
>> look at the partition numbering it looks a bit strange, so I am not
>> sure how to predict what the sda numbers will be after deleting sda3.
>> I have
>>
>> /dev/sda1          Windows
>> /dev/sda3          To be deleted
>> /dev/sda4          /home
>> /dev/sda2  Extended
>>     /dev/sda5      /
>>     /dev/sda6      Swap
>>
>> Perhaps the easiest thing is just to shrink sda3 down small and leave
>> it, but that seems like admitting defeat.
>
> I would *guess* that /dev/sda4 might become /dev/sda3.  If /home is mounted
> using its UUID or LABEL, you should be OK.  I would guess /dev/sda2 would not
> change and /dev/sda5 and /dev/sda6 might not change either, but I don't know
> for sure.  They might become 4 and 5, but maybe not.

Nils' email suggests that sda3 should not change as it is a primary partition.

>
> If *I* had installed Linux on this machine, I would NOT have used /dev/sda4 for
> /home.  Instead I would have opted for something like this:

Neither did I when it was first installed, but over the years things
get messy as new versions of ubuntu are installed in new partitions,
old versions get obsoleted, and so on.  Plus of course LVM was not
generally in use then.

>  [snip lots of interesting stuff]
>>
>> I wonder why grub does not use UUIDs.
>
> UUIDs refer to *file systems* (not partition numbers) and are handled by udev
> -- the initramdisk fires up udev which scans all of the available devices and
> partitions (and LVM volume groups, etc.) and collects all of the UUIDs and
> LABELs it finds and populates the /dev/disk/by-{id,label,path,uuid}/
> directories with symlinks. Then mount, etc. can then do 'lookups' by UUID or
> LABEL by looking in /dev/disk/by-uuid or /dev/disk/by-label and use the
> symlinks there. Grub does not have udev available for this scanning process
> and functions at a much lower level and uses the hard partition numbers to
> find the file systems.

OK, thanks.

>
> If I was dealing with this, I'd make sure I had a live / rescue boot disk (or
> USB stick) on hand in case of trouble -- one can then boot the live / rescue
> system and then edit grub.cfg as needed to repair things (in case you
> mis-'guess' what will happen to the partition numbers). All of the
> kernel/linux level mappings (eg /etc/fstab and the kernel's root= parameter)
> can be done in advance (eg set to use UUID= or LABEL=).

Certainly.

I was about to say that I will take the easy way out and shrink the
partition to virtually nothing rather than delete it, but I have just
read Nils' email saying that the partition numbers of primary
partitions should not change, so perhaps I will just delete it and see
what happens.

Thanks for the help.

Colin




More information about the ubuntu-users mailing list