5

I'm running kubuntu 16.04. I messed up UEFI (long ago), so it boots without it, but my Windows 10 partition won't boot. I don't care about that at the moment.

root is 30GB on sda4 home is 50GB on sda5.

All that works fine.

I copied root to root2 and home to home2 using rsync. I want to use these new partitions to experiment with upgrading kubuntu while leaving my main system intact.

Later, I want to make another copy of root and home just for backup (in other partitions I have set aside) and I will want that to be bootable as well.

root2 is 30GB on sda6 and home2 is 50GB on sda7.

I modified /etc/fstab on root2 to reflect the new partition LABELs.

When I try to boot using root2 (from my grub menu), I get into an ash shell from busybox and have to reboot to get out of it, so I did something wrong in grub or Linux and it looks like it can't find where or what to boot.

It displays some sort of traceback, but I don't understand it and I don't see it complaining about anything.

I asked almost the same question a few years ago, but never figured it out.

It was suggested in that question that I needed to chroot into the new root partition and run update-grub because I don't have a separate boot partition. I gave that a quick try and found that I don't know how to do that successfully.

What steps should I take to resolve this?


Details:

Root entry in grub (displayed by grub-customizer)

(This is the part that works as is.)

recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_gpt
insmod ext2
set root='hd0,gpt4'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt4 --hint-efi=hd0,gpt4 --hint-baremetal=ahci0,gpt4  a184c235-bbb7-4e0b-86ab-ab8f5d4a2941
else
  search --no-floppy --fs-uuid --set=root a184c235-bbb7-4e0b-86ab-ab8f5d4a2941
fi
        linux   /boot/vmlinuz-4.4.0-112-generic root=UUID=a184c235-bbb7-4e0b-86ab-ab8f5d4a2941 ro  quiet splash $vt_handoff
initrd  /boot/initrd.img-4.4.0-112-generic

/etc/fstab

bigbird@sananda:/etc$ cat fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sda4 during installation
##UUID=a184c235-bbb7-4e0b-86ab-ab8f5d4a2941 /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda5 during installation
##UUID=c81a6925-0631-484c-88d5-245e2e042652 /home           ext4    defaults        0       2
# swap was on /dev/sda10 during installation
##UUID=3ef9528c-1927-40fd-8729-33506d440101 none            swap    sw              0       0
## automount dataspace - JJP
##UUID=eb1774a1-2a44-4f03-8562-26b6339170f0 /media/dataspace  ext4    auto,rw,suid,exec,async,atime 0 1

LABEL=root /               ext4    errors=remount-ro 0       1
# /home was on /dev/sda5 during installation
LABEL=home /home           ext4    defaults        0       2
# swap was on /dev/sda10 during installation
UUID=3ef9528c-1927-40fd-8729-33506d440101 none            swap    sw              0       0
## automount dataspace - JJP
LABEL=dataspace /media/dataspace  ext4    auto,rw,suid,exec,async,atime 0 1

New stuff:

(I did a kernel update in root after I copied it to root2. That's why the versions here are slightly older. Once it boots, I'll fix that.)

insmod part_gpt
insmod ext2
set root='hd0,gpt6'
if [ x$feature_platform_search_hint = xy ]; then
  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt6 --hint-efi=hd0,gpt6 --hint-baremetal=ahci0,gpt6  caf3cb64-a51a-4298-bf34-5f97fa3b1308
else
  search --no-floppy --fs-uuid --set=root caf3cb64-a51a-4298-bf34-5f97fa3b1308
fi
linux /boot/vmlinuz-4.4.0-104-generic root=UUID=caf3cb64-a51a-4298-bf34-5f97fa3b1308 ro quiet splash $vt_handoff
initrd /boot/initrd.img-4.4.0-104-generic

/etc/fstab (on sda6)

bigbird@sananda:/media/work/etc$ cat fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / on /dev/sda6
##UUID=caf3cb64-a51a-4298-bf34-5f97fa3b1308 /               ext4    errors=remount-ro 0       1
# /home on /dev/sda7
##UUID=a75b6be1-5336-4eaf-92db-da1393b3d412 /home           ext4    defaults        0       2
# swap was on /dev/sda10 during installation
##UUID=3ef9528c-1927-40fd-8729-33506d440101 none            swap    sw              0       0
## automount dataspace - JJP
##UUID=eb1774a1-2a44-4f03-8562-26b6339170f0 /media/dataspace  ext4    auto,rw,suid,exec,async,atime 0 1

LABEL=root2 /               ext4    errors=remount-ro 0       1
# /home on /dev/sda7
LABEL=home2 /home           ext4    defaults        0       2
# swap was on /dev/sda10 during installation
UUID=3ef9528c-1927-40fd-8729-33506d440101 none            swap    sw              0       0
## automount dataspace - JJP
LABEL=dataspace /media/dataspace  ext4    auto,rw,suid,exec,async,atime 0 1
bigbird@sananda:/media/work/etc$

bigbird@sananda:~/pq$ ls -l /dev/disk/by-label
total 0
lrwxrwxrwx 1 root root 11 Jan 11 21:43 dataspace -> ../../sda12
lrwxrwxrwx 1 root root 10 Jan 11 21:43 ESP -> ../../sda1
lrwxrwxrwx 1 root root 10 Jan 11 21:43 home -> ../../sda5
lrwxrwxrwx 1 root root 10 Jan 11 21:43 home2 -> ../../sda7
lrwxrwxrwx 1 root root 10 Jan 11 21:43 home_bak -> ../../sda9
lrwxrwxrwx 1 root root 10 Jan 11 21:43 root -> ../../sda4
lrwxrwxrwx 1 root root 10 Jan 11 21:43 root2 -> ../../sda6
lrwxrwxrwx 1 root root 10 Jan 11 21:43 root_bak -> ../../sda8
lrwxrwxrwx 1 root root 11 Jan 11 21:43 winbak -> ../../sda11
lrwxrwxrwx 1 root root 10 Jan 11 21:43 Windows10 -> ../../sda3
bigbird@sananda:~/pq$

bigbird@sananda:~/pq$ ls -l /dev/disk/by-uuid
total 0
lrwxrwxrwx 1 root root 11 Jan 11 21:23 3ef9528c-1927-40fd-8729-33506d440101 -> ../../sda10
lrwxrwxrwx 1 root root 10 Jan 11 21:23 4630B96A30B9619B -> ../../sda3
lrwxrwxrwx 1 root root 10 Jan 11 21:23 52B7-E591 -> ../../sda1
lrwxrwxrwx 1 root root 11 Jan 11 21:23 7E8C3007301FA4AD -> ../../sda11
lrwxrwxrwx 1 root root 10 Jan 11 21:23 8f034ecf-5d98-4753-80d1-8099cf3bb641 -> ../../sda9
lrwxrwxrwx 1 root root 10 Jan 11 21:23 a184c235-bbb7-4e0b-86ab-ab8f5d4a2941 -> ../../sda4
lrwxrwxrwx 1 root root 10 Jan 11 21:23 a75b6be1-5336-4eaf-92db-da1393b3d412 -> ../../sda7
lrwxrwxrwx 1 root root 10 Jan 11 21:23 c81a6925-0631-484c-88d5-245e2e042652 -> ../../sda5
lrwxrwxrwx 1 root root 10 Jan 11 21:23 caf3cb64-a51a-4298-bf34-5f97fa3b1308 -> ../../sda6
lrwxrwxrwx 1 root root 10 Jan 11 21:23 cce6b9f2-1dcc-4a53-b15b-73c595c2f6f5 -> ../../sda8
lrwxrwxrwx 1 root root 11 Jan 11 21:23 eb1774a1-2a44-4f03-8562-26b6339170f0 -> ../../sda12
Joe
  • 1,884

2 Answers2

6

Modify /boot/grub/grub.cfg

You can modify the boot configuration file /boot/grub/grub.cfg manually (without getting into chroot). I have done it and I know that it works.

Modfify the file to match the references to the partitions (the UUIDs of the root partition) corresponding to what you did with /etc/fstab. I am not sure that you can use labels, so I suggest that you list the UUIDs with

sudo blkid

and use the values that you find for the second version of root partition.

Get a second drive of at least the same size

You may find it easier to get a second drive of at least the same size and clone from original drive to this second drive. 'Clone the whole drive'. Then you need not modify anything, but you should not boot the computer from any of these drives, when they are both connected.

Download a Clonezilla iso file, create a live drive (USB pendrive or DVD disk), boot from it and clone.

Afterwards you can use the second drive in an external box for backup purposes (using whatever backup method/tool that you want).

sudodus
  • 46,324
  • 5
  • 88
  • 152
  • Great answer! That's what I love about Stack Overflow: giving an answer to exactly the asker's question, then offering advice for how to do the same thing better. (Especially the part about using the disk for backups later on) – one_new_message Feb 24 '18 at 23:38
  • +1 for the KISS approach "Get a second drive of at least the same size" – Elder Geek Feb 25 '18 at 17:03
  • Unfortunately, I have a notebook and booting from an external drive that might get physically disconnected during operation is not an attractiiipve proposition. I keep hearing good things about clonezilla, but the last time I tried it (a long time ago), it didn't seem that easy to use. – Joe Feb 26 '18 at 07:13
  • So, essentially, you're saying that my approach didn't miss anything, just something in one of the steps I took is wrong. I used grub-customizer to do exactly what you recommend, but it didn't work for some reason. That's why I included so much grub detail. I started out with just UUIDs and no LABELS. I still ended up in initramfs/ash with nowhere to go. – Joe Feb 26 '18 at 07:21
  • You can but need not boot from an external drive (except during the cloning operation, but that is only an alternative method). Is it possible for you to unplug the internal drive (in order to replace it with a cloned copy)? I have been using Clonezilla during several years, and I find it quite useful, but I understand from your answer, that you prefer to stay within the internal drive. I think it will work to modify /boot/grub/grub.cfg unless something has been damaged along the road. – sudodus Feb 26 '18 at 07:29
  • Given that everything necessary to make it work should be displayed in the code blocks above - including the grub entries that I did modify as you suggest - before I asked this question, can you see anything specific that I got wrong? If there's anything else you need to see I'll gladly provide it. – Joe Feb 26 '18 at 07:30
  • @Joe, Is set root='hd0,gpt4' correct? You mention that your root2 is sda6. Maybe it should be 'hd0,gpt5' (because I think it starts with gpt0). – sudodus Feb 26 '18 at 07:36
  • My notebook is one of the annoying new ones with no user accessible drive bays. I have to take the whole thing apart to replace the drive. What I was ultimately hoping to do was to get a new version working in the new partitions then switch those to be the default partitions and start the whole process over using the old root and home as the new test partitions. I don't want to do this just once. I seriously hesitate to disassemble my notebook. I'm not known for my manual dexterity. – Joe Feb 26 '18 at 07:39
  • I see. So we must focus on the internal drive. Tampering with it is potentially risky - you might damage the original operating system. So you should backup at least all the files that you cannot afford to lose, but it is a good idea to backup the whole drive, if you can. And with a good backup you can even test your modifications in the original operating system. If you break it you can easily restore it from the backup. – sudodus Feb 26 '18 at 07:46
  • I don't speak grub. That's why I use grub-customizer. However, the current / that works is on sda4 and that entry says gpt4. So I extrapolated from that and since the new / partition is sda6, I put in gpt6 for it. I don't know if that's right or not. – Joe Feb 26 '18 at 07:48
  • Did this help OP? Only 2 hours of bounty left – Mark Kirby Mar 03 '18 at 16:39
  • @MarkKirby, I don't know. The last contact was in the chat room, which you can check yourself. If the OP does not reply, you have to decide yourself (if you think the problem is solved). – sudodus Mar 03 '18 at 17:11
  • @Joe, did you solve the problem? And in that case, was this answer useful? – sudodus Mar 03 '18 at 17:12
  • No. Both answers are good in general, but were things I already knew. Sudous gave me some ideas in chat, but I'm still working on it. – Joe Mar 03 '18 at 19:27
  • This is the closest answer because the other answer assun – Joe Mar 03 '18 at 19:29
  • ... assumes it's an xy problem when it is not – Joe Mar 03 '18 at 19:30
  • @Joe I went through a migration to a new laptop myself end of 2017 (https://askubuntu.com/questions/967010/cloning-a-ubuntu-installation-including-repositories-held-packages-keys). I understand how complications arise. When you reach your destination would you mind updating your question with the steps it takes? It will help others contemplating the same journey . – WinEunuuchs2Unix Mar 04 '18 at 23:38
  • @sudodus Labels can be used in /etc/fstab. The line would start with /dev/disk-by-label/label instead of UUID=..... I really prefer this way, it is less confusing, no need to bother with UUID's. – mook765 Mar 10 '18 at 05:14
  • @mook765, You are right, labels can be used in /etc/fstab, and they are easier to identify 'with the human eye'. I prefer UUIDs in /etc/fstab because they are more likely to be unique. But I use labels anyway to help identify partitions with other tools, file browsers, sudo lsblk -f etc. – sudodus Mar 10 '18 at 07:56
2

Rather than copying OS install it

I would install Kubuntu to sda6 rather than copying sda4 to sda6 and patching things here and there. The advantage is grub will automatically setup the triple boot for you.

After OS installation copy the package list and reinstall packages. There are a few Q&A's describing how to automate the process:

After automatic installation of packages then copy sda5 (/home) over top of sda7 (/home). If you did this before package installation some data / configurations files could be overwritten.

As far as UEFI being broken you could post that as a separate question.

  • A clean install takes me over two weeks of clock time to put everything back the way I want it (if I can remember what I did). The whole point of this question is to avoid having to do that. I appreciate your links. I rolled my own package restore script the last time I did a new clean install on my previous notebook. – Joe Feb 28 '18 at 02:59
  • I like your "two weeks of clock time" unit of measure. An interesting contrast to "man hours". I have a hard time remember what I did to so I have a spreadsheet that goes out and catalogs everything along with running commands through shell interface. Helpful counter-balance to my bad memory. – WinEunuuchs2Unix Feb 28 '18 at 03:11