Klaas: You've done all of this before.. You shouldn't have any significant problems.. Just ask if anything is worrying you.
Worked example: Recreate a clean partition structure without losing anything:
I'll assume here that you are going to use a flashdrive for this:
Prepare flashdrive: Perform this action from your main computer:
Insert flashdrive and run gparted.
If there are any partitions shown, right click on each one in turn and "Unmount" (or "Swapoff" if there is a swap partition present).
In gparted, select the flashdrive. Now under "Device" click on "Create Partition Table". A partition table type of MSDOS is fine.
Click "Apply".
Under "Partition", "New" create an EXT4 partition for the capacity of the flashdrive (the default).
Under "Edit", "Apply All Operations" and click on "Apply" to confirm.. Let the flashdrive format.. and click on "Close"
Close Gparted.
Use your File Manager to find the allocated flashdrive designation. Hover your cursor over the flashdrive icon to see the flashdrive identity.
I'll assume it's sdb1.
In a terminal, as root:
Code:
mount /dev/sdb1 /mnt
touch /mnt/backuplocation.txt
The touch command creates an empty file in the named location.
At this stage you have prepared the flashdrive for use as your backup device. It is formatted EXT4 and you have created a zero length "marker file"
You'll see why I've done this later.
Now in your terminal, cursor up to the "mount ... " command
Cursor to the beginning of the line and add a letter "u" and press enter when ready. You are now using the bash shell command history.
The line should now be this:
Code:
umount /dev/sdb1 /mnt
This unmounts the flashdrive partition. Remove the flashdrive from the computer.
Backup the Leonovo eMMC:
Boot the computer from your AntiX flashdrive. When the system is ready, insert your backup flashdrive.
Find your backup flashdrive partition designation: I'll assume here it's sdd1. Use your file manager to access this partition and check that you can see the "marker file" backuplocation.txt . This proves that you are looking at the correct partition.
Open a terminal and, as root:
Code:
mkdir /mnt1 /mnt2 /mnt3
mount /dev/mmcblk0p1 /mnt1
mount /dev/mmcblk0p2 /mnt2
mount /dev/sdd1 /mnt3
Here, the eMMC EFI partition is on /mnt1. The eMMC system partition is on /mnt2 and the flashdrive partition is on /mnt3
Code:
cp -a /mnt2/. /mnt3/
mkdir /mnt3/myEFI
cp -a /mnt1/. /mnt3/myEFI/
umount /mnt1 /mnt2
Ignore any "permissions" warnings..
Here, we've copied the system drive (mmcblk0p2) to the flashdrive. You then created a directory in which you have placed the contents of the eMMC EFI partition (mmcblk0p1). Finally you've unmounted the two eMMC partitions.
Wipe and recreate eMMC partitions:
Run Gparted. Select the eMMC drive and in turn (as before), ensure that each partition is unmounted (use "swapoff" if required).
Now under "Device" click on "Create Partition Table". Choose a partition table type of GPT.
Click "Apply".
(Sizes are approximate, I've just used the sizes from your gparted screenshot of your existing layout.)
Under "Partition", "New" create a Fat32 primary partition 255MiB in size. Click on "Add"
Under "Partition", "New" create an EXT4 primary partition 26.84GiB in size. Click on "Add"
Under "Partition", "New" create a Linux-swap partition using the remaining space. Click on "Add"
Under "Edit", "Apply All Operations" and click on "Apply" to confirm.. Let the eMMC format..
Now click on "Close".
Now Right click on the Fat32 partition and select "Manage Flags". Here, select "boot" and "esp" and click on "close". The boot flags are now set.
Close Gparted.
Create a list of your UUID's:
Code:
blkid | grep mmcblk0p > newUUIDs.txt
This file will be created in your current working directory.
Copy everything back:
Code:
mount /dev/mmcblk0p1 /mnt1
mount /dev/mmcblk0p2 /mnt2
Your backup flashdrive partition should still be mounted on /mnt3 .
Code:
cp -a /mnt3/. /mnt2/
cp -a /mnt3/myEFI/. /mnt1/
Ignore any "permissions" warnings..
**Remember to delete /myEFI and contents when the system has booted.**
At this stage, you have copied back everything to the system and EFI partitions.
Modify configuration files:
If you want to use xed, start it from another terminal with
Inital grub.cfg: Currently at /mnt1/EFI/ubuntu/grub.cfg
Change the UUID to the new UUID of mmcblk0p2. Copy & paste from the newUUIDs.txt file.
Sample /mnt1/EFI/ubuntu/grub.cfg
Code:
search.fs_uuid {your mmcblk0p2 UUID here.} root hd0,gpt2
set prefix=($root)'/boot/grub'
configfile $prefix/grub.cfg
Replace the main grub.cfg (currently at /mnt2/boot/grub/grub.cfg) with
Code:
insmod gzio
insmod part_gpt
insmod ext2
menuentry "Mint 19.2 update me" {
set root='hd0,gpt2'
linux /boot/vmlinuz-5.2.4-050204-generic root=UUID={your mmcblk0p2 UUID here} ro $vt_handoff
initrd /boot/initrd.img-5.2.4-050204-generic }
Use the kernel version that you are most happy with at the moment.
Modify fstab: Currently at /mnt2/etc/fstab
Code:
# / was on /dev/mmcblk0p2 during installation
UUID={Your mmcblk0p2 UUID here} / ext4 noatime,errors=remount-ro 0 1
# /boot/efi was on /dev/mmcblk0p1 during installation
UUID={Your mmcblk0p1 UUID here} /boot/efi vfat umask=0077 0 1
# swap was on /dev/mmcblk0p3 during installation
UUID={Your mmcblk0p3 UUID here} none swap sw 0 0
Nearly there.. Now to add the resume settings: Thanks to colorpurple21859 for reminding me of this.
In your first terminal:
Code:
touch /mnt2/etc/initramfs-tools/conf.d/resume
Now edit /mnt2/etc/initramfs-tools/conf.d/resume and add the line
Code:
RESUME=UUID={your mmcblk0p3 UUID here.}
Save the file and close the editor.
The system should use the default swap partition for this automatically, but it's often a good idea to manually force this.
I don't use any resume functionality at all, but I appreciate that others do.
Now power down and remove any connected flashdrives.
Restart, and the system should boot from the temporary grub.cfg
Update Grub:
Open a terminal and run:
Restart again, this time you have a fully updated grub.cfg.
Good luck!
Bodge99