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

Re: Help: disk swap



On Thu 28 Jul 2022 at 14:29:32 (+0100), tony van der Hoff wrote:
> Thanks for your help. Sadly, I'm not getting very far with this. I
> guess I'm not understanding your instructions too well:
> 
> On 27/07/2022 16:07, Jude DaShiell wrote:
> > Have the running linux system on the machine.  Run lsblk to locate the
> > name of the boot partition.
> 
> I'll call the disk from the backup machine "B", and the disk I want to
> use "A".
> 
> 
> OK, on disk B:  lsblk sda9 /boot
> >  Once you have the name run blkid and copy the
> 
> sudo blkid
> /dev/sda9: LABEL="boot" UUID="3fe30767-f7d7-4e6d-b48e-f80eef2d4b71"
> 
> Now I'm lost.
> 
> Remove disk B, install disk A
> Boots into grub rescue.

The methodology below is unsuitable for you because you don't have
both disks in the machine at the same time.

> > uuid for use in the end of /etc/fstab and put in the path to the boot
> > device, the disk format ext4, defaults,nofail 1 2 on an fstab entry.
> > Next, run update-grub and you should get a new boot entry in grub.  If you
> > boot the machine on the boot screen hit down-arrow followed by enter and
> > your other disk should boot up.
> > I got a new computer with no sata tray in it and have a sata caddy and
> > some older sata disks and that's how I got those to boot.  hth.

You'd need to provide more information about both your computers and
how they boot in order to get better help. That would include whether
each one boots with EFI or the BIOS, and whether the disks are MBR
or GPT. It would help to know whether A's disk has a separate /boot
partition like B's does.

In the meantime, you could try the following commands from the Grub
Rescue prompt. It's not straightforward as only a subset of commands
will work. It's very likely to fail if the two computers boot in
different ways. All the disk and partition numbers below are just
examples: substitute according to what Grub finds present.

grub rescue> set pager=1

  in case you type a command that produces more than a page of output.

grub rescue> set

  will list the environment. The interesting ones are prefix and root,
  as these are the ones you might need to change.

grub rescue> ls

  should tell you what Grub calls your disk. It might look like:

  (hd0) (hd0,msdos4) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)

  or ditto with msdos→gpt. If you only see:

  (hd0)

  then you should see the partitions by typing:

grub rescue> ls (hd0)

  If you know the partition layout of the disk, and where
  /boot is, then you can type:

grub rescue> set prefix=(hd0,msdos3)/grub
grub rescue> set prefix=(hd0,msdos2)/boot/grub

  The first is where /boot is separate and on the 3rd partition,
  whereas the second is where boot is in the root filesystem on
  the 2nd.

  Similarly, you need to set the root partition by typing:

grub rescue> set root=(hd0,msdos2)

  You'll notice that that would be appropriate for the second example
  above, where /boot was in the root filesystem.

  Say you don't know the layout of your disk. Then you have to poke
  around with ls, using commands like:

grub rescue> ls (hd0,msdos1)

  which, for a root filesystem, should show bin dev etc lib and so on.

  Once the prefix is set, you should be able to get more of Grub
  loaded by typing these two lines:

grub rescue> insmod normal
grub rescue> normal

  I can't remember if the prompt changes, but you should have more
  commands available now.

  At a minimum you need, for a system where /boot is not separate,
  but in the root (and first) partition:

grub> insmod linux
grub> linux /boot/vmlinuz-… root=/dev/sda1 ro single
grub> initrd /boot/initrd.img-…
grub> boot

  Filename completion should word at …, and note that the kernel
  root parameter uses kernel notation, not Grub's. (Fortunately,
  both count partitions from 1 nowadays.)

  It's possible that you need to insmod more modules, so report
  at which step it fails.

Cheers,
David.


Reply to: