0

is it possible to capture the UUID number before creating file system on disk?

if yes how - by which command ?

blkid ( before run mkfs.ext4  on sdb disk )

<no output>


blkid ( after run mkfs.ext4  on sdb disk )

/dev/sdb: UUID="9bb52cfa-0070-4824-987f-23dd63efe120" TYPE="ext4"

Goal - we want to capture the UUID number on the Linux machines disks before creation the file system

  • 1. I recommend using partitions, not raw disks. Even if there's only ever going to be one partition spanning the entire disk. 2. An unformatted disk (or partition) won't have a UUID. If it has a partition table, it should have a PTUUID. If it is a partition, it should have a PARTUUID. – cas Jan 5 '18 at 7:20
  • so final answer is no? – yael Jan 5 '18 at 7:21
  • 1
    well, you can't capture a UUID if it doesn't exist. – cas Jan 5 '18 at 7:22
7

No and yes.

The command to create the filesystem is the one that generates the UUID. So, before running it there is no UUID to use to name the filesystem.

However, it is posible to use an specific UUID to create the filesystem:

$ uuid=$(uuidgen)
$ echo "$uuid"
9a7d78e5-bc6c-4b19-94da-291122af9cf5
$ mkfs.ext4 -U "$uuid" 

The uuidgen program which is part of the e2fsprogs package

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.