Page 2 of 2 FirstFirst 12
Results 11 to 16 of 16

Thread: Changing the UUID of a FAT32 or NTFS Partition

  1. #11
    Join Date
    Apr 2011
    Beans
    8

    Re: Changing the UUID of a FAT32 or NTFS Partition

    i want change my usb disk uuid. but i dont understand the risk!
    it means if i changed , it may not working?

  2. #12
    Join Date
    Nov 2006
    Location
    東京
    Beans
    168
    Distro
    Xubuntu Development Release

    Re: Changing the UUID of a FAT32 or NTFS Partition

    Quote Originally Posted by Bouki View Post
    i want change my usb disk uuid. but i dont understand the risk!
    it means if i changed , it may not working?
    Changing the UUID won't break the disk or make it unreadable. Some software might check UUIDs to try and detect unauthorised copying.

    The risk I was referring to was the risk of making a mistake when running 'sudo dd' to read or write the superblock. That could definitely make the disk unreadable.

    If it's that important, I suggest you backup the usb disk using gparted before changing the UUID. Please also read the dd manual page so you know what you're doing.
    Code:
    man dd

    PS: To the thread moderator, my thanks.
    This item has not yet been configured

  3. #13
    Join Date
    Sep 2011
    Beans
    1

    Re: Changing the UUID of a FAT32 or NTFS Partition

    Thank you! It worked perfectly for me on ubuntu 11.04
    -strudel

  4. #14
    Join Date
    May 2012
    Beans
    1

    Re: Changing the UUID of a FAT32 or NTFS Partition

    I wrote a script to automate this process for NTFS partitions and to avoid overwriting anything that isn't NTFS (or at least reduce the risks). I'm sure one could modify it to work with FAT as well, but it's a starting point.

    Code:
    #!/bin/dash
    IFS=""
    
    # echo with exit for error termination
    exho(){
        echo "error: $1"
        exit 1
    }
    
    # convert hexidecimal UUID to binary characters
    uuid2bin(){
        STBF="$1"
        while [ -n "$STBF" ]; do
            BYTE="${STBF%??}"
            BYTE="${STBF#$BYTE}"
            STBF="${STBF%$BYTE}"
            BYTE="$(printf "%u\n" "0x$BYTE")"
            echo -n "$BYTE" | awk '{printf("%c",$0)}'
        done
        return 0
    }
    
    # usage help
    if [ $# != 2 ]; then
        echo "$0 <UUID> <device>"
        exit 1
    fi
    
    # test the input UUID for validity
    UUID_NEW="$(echo -n "$1" | tr [a-f] [A-F])"
    STBF="${UUID_NEW#[0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F][0-9A-F]}"
    if [ -n "$STBF" ]; then
        exho "invalid UUID format"
    fi
    if [ "$UUID_NEW" = 0000000000000000 ]; then
        exho "UUID cannot be empty"
    fi
    
    # get current/old UUID value via system tool
    UUID_OLD="$(blkid -c /dev/null -s UUID -o value "$2" 2>/dev/null)"
    if [ -z "$UUID_OLD" ]; then
        exho "could not read old UUID using blkid on $2"
    fi
    
    # get current/old UUID value via raw read
    STBF="$(dd bs=1 skip=72 count=8 if="$2" 2>/dev/null | hexdump -ve '1/1  "%02X"')"
    if [ ${#STBF} != 16 ]; then
        exho "could not read old UUID using dd on $2"
    fi
    
    # reorder the hex digits since they are reversed
    UUID_RAW=""
    while [ -n "$STBF" ]; do
        BYTE="${STBF%??}"
        BYTE="${STBF#$BYTE}"
        STBF="${STBF%$BYTE}"
        UUID_RAW="$UUID_RAW$BYTE"
    done
    
    # matching UUIDs confirm NTFS structure
    if [ "X$UUID_RAW" != "X$UUID_OLD" ]; then
        exho "$2 invalid NTFS device"
    fi
    
    # write UUID to device
    if ! uuid2bin "$UUID_NEW" | dd bs=1 seek=72 count=8 of="$2" 2>/dev/null && sync; then
        exho "could not write UUID to $2"
    fi
    
    # verify UUID
    UUID_RAW="$(blkid -c /dev/null -s UUID -o value "$2" 2>/dev/null)"
    if [ "X$UUID_RAW" != "X$UUID_NEW" ]; then
        exho "verification of new UUID failed"
    fi
    
    # status information
    echo "DEVICE:\t\t$2"
    echo "OLD UUID:\t$UUID_OLD"
    echo "NEW UUID:\t$UUID_NEW"

  5. #15
    Join Date
    Apr 2010
    Beans
    78

    Re: Changing the UUID of a FAT32 or NTFS Partition

    I have used this many times now and it works perfectly:
    http://ubuntuforums.org/showpost.php...8&postcount=10

  6. #16
    Join Date
    Sep 2008
    Beans
    41
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Changing the UUID of a FAT32 or NTFS Partition

    Quote Originally Posted by dcstar View Post
    This should patch the NTFS UUID with 8 random bytes (substitute the obvious with your actual NTFS partition designation, and all those spaces are required):

    Code:
    sudo dd if=/dev/urandom bs=80 count=1 | xxd -l 80 -c 8 | tail -1 | xxd -r - /dev/sd-NTFS-Partition
    This works great. Thanks.

Page 2 of 2 FirstFirst 12

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •