TL;DR:
According to the man pages, only sfdisk can do so (not gparted, nor cfdisk nor fdisk)
DEVICE is the device or your drive. Cave! All partitions of that disk drive should be umounted (and swapoff'd) during this operation. Valid DEVICE is e.g. /mnt/sdb not /mnt/sdb1 !
Code: Select all
sfdisk --disk-id DEVICE
Code: Select all
sfdisk --disk-id DEVICE ID
Like so:
Code: Select all
sfdisk --disk-id /dev/sdd 0x7be907a5
I checked two of my similar blue HAMA 8 GB USB thumbdrives.
One has the "Disk identifier" set
Code: Select all
root@rava:/# fdisk -l /dev/sdc
Disk /dev/sdc: 7.47 GiB, 8016363520 bytes, 15656960 sectors
Disk model: USB Flash Disk
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: dos
Disk identifier: 0x7ae803a4
Device Boot Start End Sectors Size Id Type
/dev/sdc1 * 32 15656959 15656928 7.5G b W95 FAT32
Code: Select all
root@rava:/# fdisk -l /dev/sdd
Disk /dev/sdd: 7.47 GiB, 8016363520 bytes, 15656960 sectors
Disk model: USB Flash Disk
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: dos
Disk identifier: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sdd1 32 15656959 15656928 7.5G b W95 FAT32
Then I manually searched all appropriate man pages :
Code: Select all
guest@rava:/usr/man/man8$ ls -l *fdisk* gparted*
-rw-r--r-- 1 root root 8218 2022-02-15 19:37 cfdisk.8
-rw-r--r-- 1 root root 17217 2022-02-15 19:37 fdisk.8
-rw-r--r-- 1 root root 2408 2021-07-20 20:44 gparted.8
-rw-r--r-- 1 root root 26620 2022-02-15 19:37 sfdisk.8
And as you can see, at least according to the man pages only sfdisk can do so:
not gparted, nor cfdisk nor fdisk:
Code: Select all
guest@rava:/usr/man/man8$ grep -i identifier *fdisk* gparted*
sfdisk.8:Change the disk identifier. If \fIid\fP is not specified, then print the
current identifier. The identifier is UUID for GPT or unsigned integer for MBR.
sfdisk.8:Specify the partition table identifier. It should be a hexadecimal number
(with a 0x prefix) for MBR and a UUID for GPT.
Let's copy the relevant [ code ] directly from man sfdisk to get rid of the inserted code for bold or underlined highlighting you get when just grep'ing the man page via the terminal:
Code: Select all
--disk-id device [id]
Change the disk identifier. If id is not specified, then print the
current identifier. The identifier is UUID for GPT or unsigned
integer for MBR.
To get the disk identifier for drive /dev/sdc:
Code: Select all
sfdisk --disk-id /dev/sdc
Code: Select all
root@rava:~# mount /mnt/sdc1/
1. umount all partitions of /mnt/sdc (there is only one partition: /mnt/sdc1/ ) and swapoff all swap partitions that could be on /mnt/sdc (there is no swap partition on /mnt/sdc; using a USB2 thumbdrive for swap would be quite silly)
2. list the current disk identifier
3. set the new disk identifier to "0x7be907a5"
4. list the current disk identifier
Code: Select all
root@rava:~# umount /mnt/sdc1/
root@rava:~# sfdisk --disk-id /dev/sdc
0x00000000
root@rava:~# sfdisk --disk-id /dev/sdc 0x7be907a5
Disk identifier changed from 0x00000000 to 0x7be907a5.
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
root@rava:~# sfdisk --disk-id /dev/sdc
0x7be907a5