Does deleting a partition below Ubuntu mess up grub?

Colin Law clanlaw at gmail.com
Sun Oct 12 14:49:18 UTC 2014


On 12 October 2014 14:53, Robert Heller <heller at deepsoft.com> wrote:
> At Sun, 12 Oct 2014 14:35:41 +0100 "Ubuntu user technical support,  not for general discussions" <ubuntu-users at lists.ubuntu.com> wrote:
>
>>
>> On 12 October 2014 14:27, William Scott Lockwood III <scott at guppylog.com> wrote:
>> >
>> > On Oct 12, 2014 8:16 AM, "Colin Law" <clanlaw at gmail.com> wrote:
>> >>
>> >
>> >> I want to delete a partition (sda4) which is below the Ubuntu
>> >> partition (sda5).  I seem to remember when I did something similar
>> >> some time ago that it messed up grub and the machine would not boot,
>> >> due to the fact that the sda numbers changed when the partition was
>> >> deleted.  Is that still the case, and if so is there a procedure for
>> >> deleting sda4 that will not cause such problems?  This is Ubuntu
>> >> 12.04.
>> >>
>> >> Cheers
>> >>
>> >> Colin
>> >>
>> >> --
>> >
>> > Mount by UUID rather than device name. Also, there are tools that help you
>> > do this in a sane manor. Any of the gui partition managers should do,this
>> > just fine.
>>
>> Thanks, but I am not sure if that is the problem.  Looking in
>> /boot/grub/grub.cfg it contains direct references to sda numbers, so
>> my memory was that grub looked for the wrong partition.  Perhaps my
>> memory is wrong, however, and it was mounting the drives that caused
>> the problem due to having sda numbers in fstab.
>
> You may have both issues.  Grub does use hard partition numbers to find the
> kernel and initrd files.  There is also the root= kernel parameter, which
> *might* have a direct references to a sda number.  This should be changed to
> either use UUID= or LABEL=.  And yes, you should make sure /etc/fstab is using
> UUIDs or LABELs.

So if I want to delete a partition should I first edit
/boot/grub/grub.cfg, and if so can I assume that all sda numbers above
the deleted one will be decremented?  Or can I run gparted from the
working system, unmount the partition I want to delete (assuming it is
not in use), delete it, and run update-grub before re-booting?  I
suspect that will not do anything as the new partition numbers will
not get allocated until re-boot.

> Also: *often* (but not always) partition #4 is the entended partition,
> containing (logical) partitions 5 and up. Deleting partition #4 *in that case*
> also deletes partitions 5 and up. Make sure this is not what you are doing!

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 wonder why grub does not use UUIDs.

Colin

Cheers

Colin




More information about the ubuntu-users mailing list