Copying boot usb stick to smaller stick fails

I am using NVMe on PCi card for my system but my hardware cannot boot from NVMe so the /boot/ and boot/efi partitions are installed on an USB stick which is installed internally to avoid accidental removal.

This arrangement works well but when I set it up I used a rather large and dual sized USB which I now need back. I have a new smaller USB stick ready to exchange and thought it would be easy but no such luck. Even though the large USB only has two partitions:-

**Disk /dev/sdb: 115.48 GiB, 123992014848 bytes, 242171904 sectors** 
Disk model: DT microDuo 3C   
Units: sectors of 1 * 512 = 512 bytes 
Sector size (logical/physical): 512 bytes / 512 bytes 
I/O size (minimum/optimal): 512 bytes / 512 bytes 
Disklabel type: gpt 
Disk identifier: 8E98043F-0F3D-42DD-862C-987F8C5D23B2 

**Device**     **  Start** **    End** **Sectors** ** Size** **Type** 
/dev/sdb1     2048 1026047 1024000  500M EFI System 
/dev/sdb2  1026048 5220351 4194304    2G Linux filesystem 
alastair@localhost:~> 


The empty space gets in the way and frustrates all my efforts to clone only the actual partitions using dd. I cannot find any suitable examples. Since the efi partition is on a dos format is there also lurking an MBR on the USB?

Please could somebody help me with this. I really do not want to do a new installation at this stage just to create a new boot USB!
Budge.

That shows GPT partitioning.

In any case, it’s not that complicated.

Plug in your new USB, partition it and format it. Maybe use Yast to create the two partitions, but set it to not mount them.

Then manually mount the partitions, and copy the files over. Then unmount again.

Next you should unmount the existing “/boot/efi” and “/boot”. Mount the new partitions in their place. Then run Yast bootloader. Change something in Yast bootloader, maybe change the timeout by 1 second. Yast should then reinstall booting in your new partitions.

Finally, edit “/etc/fstab” for the new device. The UUID of the partitions will be different from what you were using before.

Once that is changed, run “mkinitrd” so that the initrd gets any changed UUID information.

Then try rebooting with the new USB and see how that works.

Hi nrickert, many thanks. There is one issue, to access the internal USB I have to power down and remove fan frame so it is not easy to do the swap.

What I am thinking is to swap the two sticks when machine is off, putting existing USB stick in front USB socket and new USB into the internal slot. I hope that I can then boot the system from the original USB but in a front slot leaving the new USB in the internal position.

If this works I should be OK to do the rest from terminal. Does that sound like the right approach?

I don’t know your hardware, so I cannot be sure of that.

If all mounting is done using UUID, then it should be fine to plug in the new USB on a USB port, and leave the old one where it is. And if that works, check to be sure that the old one is not actually mounted.

After that, try the physical swap of the USBs.

I moved too quickly. I had no trouble booting with the original USB stick in a front slot and with the new USB stick in required internal position. I have embarked upon your task list but have fallen half way through. I thought I had created the new directories on the two new partitions and unmounted the original “/boot/efi” and “/boot” partitions but when I can to try and mount the new partitions I couldn’t mount because the partition couldn’t be found in /etc/fstab. I then had mount point does not exist. I am writin this on my laptop but the subject machine is up and running so will continue this thread from that machine so I can insert code.

So here is what I had when I started:-

alastair@ibmserver3:~> lsblk -l
NAME      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0       7:0    0 260.7M  1 loop /snap/kde-frameworks-5-core18/32
loop1       7:1    0  32.3M  1 loop /snap/snapd/12704
loop2       7:2    0  32.3M  1 loop /snap/snapd/12883
loop3       7:3    0    93M  1 loop /snap/puddletag-snap/3
loop4       7:4    0  55.4M  1 loop /snap/core18/2128
loop5       7:5    0  65.1M  1 loop /snap/gtk-common-themes/1515
sda         8:0    0   5.5T  0 disk 
sda1        8:1    0   5.5T  0 part /mastermedia
sdb         8:16   1  28.9G  0 disk 
sdb1        8:17   1   500M  0 part 
sdb2        8:18   1     2G  0 part 
sdc         8:32   1 115.5G  0 disk 
sdc1        8:33   1   500M  0 part /boot/efi
sdc2        8:34   1     2G  0 part /boot
sr0        11:0    1  1024M  0 rom  
sr1        11:1    1  1024M  0 rom  
nvme0n1   259:0    0   1.8T  0 disk 
nvme0n1p1 259:1    0   1.8T  0 part /var
alastair@ibmserver3:~>

/dev/sdc is the original boot USB stick and /dev/sdb is the new stick with the two new partitions ready.

I then umounted the two original partitions and checked what I had:-

alastair@ibmserver3:~> sudo umount /dev/sdc1
[sudo] password for root: 
alastair@ibmserver3:~> sudo umount /dev/sdc2
alastair@ibmserver3:~> lsblk -l
NAME      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0       7:0    0 260.7M  1 loop /snap/kde-frameworks-5-core18/32
loop1       7:1    0  32.3M  1 loop /snap/snapd/12704
loop2       7:2    0  32.3M  1 loop /snap/snapd/12883
loop3       7:3    0    93M  1 loop /snap/puddletag-snap/3
loop4       7:4    0  55.4M  1 loop /snap/core18/2128
loop5       7:5    0  65.1M  1 loop /snap/gtk-common-themes/1515
sda         8:0    0   5.5T  0 disk 
sda1        8:1    0   5.5T  0 part /mastermedia
sdb         8:16   1  28.9G  0 disk 
sdb1        8:17   1   500M  0 part 
sdb2        8:18   1     2G  0 part 
sdc         8:32   1 115.5G  0 disk 
sdc1        8:33   1   500M  0 part 
sdc2        8:34   1     2G  0 part 
sr0        11:0    1  1024M  0 rom  
sr1        11:1    1  1024M  0 rom  
nvme0n1   259:0    0   1.8T  0 disk 
nvme0n1p1 259:1    0   1.8T  0 part /var
alastair@ibmserver3:~>

I then tried to mount the new partitions and fell down hard!:-

sudo mount /dev/sdb1 
mount: /dev/sdb1: can't find in /etc/fstab.
alastair@ibmserver3:~> sudo mount /dev/sdb2 
mount: /dev/sdb2: can't find in /etc/fstab.
alastair@ibmserver3:~> lsblk -l
NAME      MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0       7:0    0 260.7M  1 loop /snap/kde-frameworks-5-core18/32
loop1       7:1    0  32.3M  1 loop /snap/snapd/12704
loop2       7:2    0  32.3M  1 loop /snap/snapd/12883
loop3       7:3    0    93M  1 loop /snap/puddletag-snap/3
loop4       7:4    0  55.4M  1 loop /snap/core18/2128
loop5       7:5    0  65.1M  1 loop /snap/gtk-common-themes/1515
sda         8:0    0   5.5T  0 disk 
sda1        8:1    0   5.5T  0 part /mastermedia
sdb         8:16   1  28.9G  0 disk 
sdb1        8:17   1   500M  0 part 
sdb2        8:18   1     2G  0 part 
sdc         8:32   1 115.5G  0 disk 
sdc1        8:33   1   500M  0 part 
sdc2        8:34   1     2G  0 part 
sr0        11:0    1  1024M  0 rom  
sr1        11:1    1  1024M  0 rom  
nvme0n1   259:0    0   1.8T  0 disk 
nvme0n1p1 259:1    0   1.8T  0 part /var
alastair@ibmserver3:~> sudo mount /dev/sdb1 /boot/efi
mount: /boot/efi: mount point does not exist.
alastair@ibmserver3:~>

What I do not know is if the contents of the new USB stick partitions is in place. Not sure how to check this but I think I have made several errors. I have not erased anything from the old USB stick or removed either although they are no longer mounted. I shall avoid a reboot and hope I get help in due course. Please let me know what I should do next!

You seem not to understand themount command. One either provides all the parameters needed to the mount command, or one uses a short form like you do, but then all the parameters are to be found in /etc/fstab.

When you do

mount /dev/sdb1

the only parameter provided is the “device”. So how should a command, that is not clairvoyant know: where to mount (mount point), what type of file system, eventual mount options???

This is in

man mount

already explained at the very beginning!

Hi Henk,
You are of course correct and I am sorry if my understanding is lacking. Perhaps you could help me please.

I’d copy your current fstab settings with the working stick.

FWIW, in two dual-boot desktops I have in fstab:


LEAP 15.2: LABEL=boot_sam    /boot/efi                   vfat   codepage=437    0  0
LEAP 15.3: LABEL=efi              /boot/efi    vfat   utf8    0  2

I don’t know why the different parameters.

Note: both desktops have separate SSDs for each OS, thus the label boot_sam, in a samsung SSD in LEAP 15.2.

Hi brunomcl,
I have taken a copy of my existing /etc/fstab which looks like this:-

alastair@ibmserver3:/etc> cat fstab
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /             btrfs  defaults             0  0
UUID=e3e7dd7c-8a84-43d1-82dc-231aa1755401  /boot         ext2   defaults             0  2
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /var          btrfs  subvol=/@/var        0  0
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /usr/local    btrfs  subvol=/@/usr/local  0  0
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /tmp          btrfs  subvol=/@/tmp        0  0
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /srv          btrfs  subvol=/@/srv        0  0
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /root         btrfs  subvol=/@/root       0  0
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /opt          btrfs  subvol=/@/opt        0  0
UUID=b9dfb0de-5005-4002-83d8-fe2223b63133  /home         btrfs  subvol=/@/home       0  0
UUID=87CF-3D40                             /boot/efi     vfat   utf8                 0  2
UUID=ff25e221-489f-454b-a334-1079dbc63ddd  /mastermedia  xfs    defaults             0  0
alastair@ibmserver3:/etc>

What i don’t follow in spite of the advice from Henk is why the two subject mounts, /boot and /boot/efi are still there when I thought I had umounted them. At this rate I shall end up doing a fresh install because I am not even confident the new stick has the right contents and I cannot access it without shutting down. Will start over in the morning.

I’m looking at that “fstab” listing.

Comment out the line for “/boot” and the line for “/boot/efi”
Then make a copy of both lines. The copy should be immediately under the original line.

Change the UUID= parameter in each so that they give the UUID for the new partitions.
Uncomment those changed lines.
Then see if it works.

You can use the “blkid” command to get the UUID. And be sure to use the UUID and not the PARTUUID.

I think I am helping. I point you to the place where to read and understand what the mount command needs to perform it’s task. And where it gets that information from: either from the command only, or the from command combined with the fstab.

I can of course try to provide you with exact commands (when i do understand exactly what you are doing) and you can then copy/paste those commands in your system without knowing if those commands will do what you want or if they will destroy your system (I can make typos or other mistakes) because you never check hem with man pages, etc. to protect yourself (and to learn)

Or I can try to point you to documentation that will make you understand how things work and that will help you now and in the future. And of course you can ask me questions while trying to understand that documentation.

You ever heard of what is said about helping poor people? Something like "you can give a hungry person a fish, so he can eat today. You can also teach him fishing, so he can feed himself and his family in the future.

Did you try to read at least the beginning paragraphs of the man page for mount as I suggested? When not, then you stubbornly refuse to learn fishing.