3

I inserted a USB stick on my laptop and it automount the partition. I then did a umount /dev/sdb* to allow me to DD an image to it. Once DD is done, I do sync then physically unplug the USB then plug it back to get the 2 partitions mounted.

my question is how can I avoid to physically unplug the USB and plug it back again?

2 Answers2

2

Unmount

You can unmount all partitions without trying to unmount the device itself with

sudo umount /dev/sdx?*

Replace the device letter x with the relevant device letter, for example b

Clone

It is a good idea to use a cloning tool with a final checkpoint,

Accidentally did dd /dev/sda

Scroll down to 'Safer tools to create USB boot drives with Ubuntu'

Sync, Partprobe, Mount

sync
sudo partprobe

Try mounting after creating the new system on the USB stick

This command line should work with one or more partitions,

for i in $(lsblk -l -o name|grep -E "sdx.{1,}");do sudo mkdir -p /media/$USER/"$i";sudo mount /dev/"$i" /media/$USER/"$i";done

Replace the device letter x with the relevant device letter, for example b

sudodus
  • 47,684
1

If remember correctly you need to run one command after sync:

sudo partprobe

From its man-page:

NAME
partprobe - inform the OS of partition table changes

DESCRIPTION
partprobe is a program that informs the operating system kernel of par- tition table changes.

N0rbert
  • 103,263