Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UUID
- #!/bin/bash
- # Get the device name of the disk
- #read -p "Enter the device name of the disk (e.g. /dev/sda): " disk
- disk='/dev/sdX'
- # Generate new UUIDs for all partitions on the disk
- partitions=($(lsblk -no NAME $disk | grep -v '^$'))
- for part in "${partitions[@]}"
- do
- new_uuid=$(uuidgen)
- tune2fs -U $new_uuid $disk$part
- done
- echo "UUIDs changed successfully for all partitions on $disk"
- --------------------------
- To change the UUID of the source disk in Linux, you can use the tune2fs command. Here's how you can do it:
- First, make sure the source disk is unmounted. You can check if it's mounted by using the mount command.
- Find out the device name of the source disk. You can use the lsblk command to list all block devices and their attributes.
- Once you have the device name (e.g. /dev/sda1), you can use the tune2fs command to change the UUID. Run the following command, replacing /dev/sda1 with your device name:
- sudo tune2fs -U random /dev/sda1
- This will generate a new random UUID for the source disk. You can also specify a specific UUID by replacing random with the desired UUID in the format XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX.
- Once the command has executed successfully, you can remount the source disk and verify that the UUID has been changed by running the blkid command.
- By following these steps, you can change the UUID of the source disk in Linux after cloning it using dd.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement