i think i found the solution (see Step 8)
Step 1:
Erase and format the SSD, GPT, ext4
- Run the following command:
sudo parted /dev/sdX
Step 2:
Mount the SSD
sudo mkdir /mnt/ssd
sudo mount /dev/sdX1 /mnt/ssd
Step 3:
Copy the SD card contents to the SSD using rsync
sudo rsync -aAXv /mnt/sd/ /mnt/sdX1/
Step 4:
Check if the data is copied to the SSD
Step 5:
Find the PARTUUID
sudo blkid
/dev/mmcblk0p1: UUID="2a4e89e0-dde6-4878-b9f6-b2d1962d4263" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="d0f20000-01"
/dev/sda1: UUID="7a08758e-4cdd-48ce-88de-448c54ee0c8a" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="d0f20000-01"
Step 6:
Update the fstab file:
Comment out the old SD card entry and add the UUID of the new SSD below it:
sudo nano /etc/fstab
- Example entry in /etc/fstab:
# PHYSICAL DRIVES
#-----------------------------------------------------------
#old SD card #UUID=2a4e89e0-dde6-4878-b9f6-b2d1962d4263 / ext4 noatime,lazytime,rw 0 1
UUID=7a08758e-4cdd-48ce-88de-448c54ee0c8a / ext4 defaults,nofail 0 1 # new SSD
Step 7:
Update dietpiEnv.txt:
Comment out the SD card and specify the mount point or UUID of the SSD.
sudo nano /boot/dietpiEnv.txt
#rootdev=UUID=2a4e89e0-dde6-4878-b9f6-b2d1962d4263
rootdev=/dev/sda1
Done!
If it doesn’t work:
If after “loading kernel,” all USB devices are disconnected, here’s the solution:
You need to update the initramfs to reset the USB devices during boot.
Step 8:
Create a script in the init-premount directory:
sudo nano /etc/initramfs-tools/scripts/init-premount/usb-reset.sh
Paste the following script:
#!/bin/sh
# USB reset script for initramfs
# Wait a few seconds to ensure all devices are available
sleep 5
# Iterate through USB devices
for device in /sys/bus/usb/devices/*; do
# Check if the device exists
if [ -d "$device" ]; then
# Try to get the bus and device information
busnum=$(cat "$device/busnum" 2>/dev/null)
devnum=$(cat "$device/devnum" 2>/dev/null)
# Check if values were found
if [ -n "$busnum" ] && [ -n "$devnum" ]; then
# Get Vendor and Product ID
vendor_id=$(cat "$device/idVendor" 2>/dev/null)
product_id=$(cat "$device/idProduct" 2>/dev/null)
echo "Resetting USB device $devnum on bus $busnum"
echo "Vendor ID: $vendor_id, Product ID: $product_id"
# Disconnect the device
echo "0" > "$device/authorized" 2>/dev/null
sleep 1 # Wait a moment
# Reconnect the device
echo "1" > "$device/authorized" 2>/dev/null
sleep 1 # Wait a moment
fi
fi
done
# Wait 60 seconds to view the output
echo "Waiting for 60 seconds to view output..."
sleep 60
# Show Vendor and Product IDs for all devices after the reset
echo "Connected USB devices after reset:"
for device in /sys/bus/usb/devices/*; do
if [ -d "$device" ]; then
vendor_id=$(cat "$device/idVendor" 2>/dev/null)
product_id=$(cat "$device/idProduct" 2>/dev/null)
if [ -n "$vendor_id" ] && [ -n "$product_id" ]; then
echo "Vendor ID: $vendor_id, Product ID: $product_id"
fi
fi
done
Step 9:
Make the file executable:
sudo chmod +x /etc/initramfs-tools/scripts/init-premount/usb-reset.sh
Step 10:
Update the initramfs:
sudo update-initramfs -u
Done!
Reboot your system:
sudo reboot