Ubuntu: lsblk partuuid not recognized command



Question:

I'm trying to find out where the partitions start for my USB using the

lsblk -o name,label,partuuid  

It's giving me an output of:

lsblk: unknown column: partuuid  

I believe "partuuid" is not a permitted command for Ubuntu. Any idea on how i can find this information out?


Solution:1

From the manual page (in a terminal type man lsblk):

-o, --output list Specify which output columns to print. Use --help to get a list of all supported columns.

So lsblk --help should give you, among other things, a list of supported colums.

To list partition uuids use the command blkidinstead of lsblk.

I am not at my Ubuntu machine right now to verify it, but please try it anyway.


Solution:2

The way i found the UUID was by first identifying what partition of the USB i wanted to boot from, i did this by typing

lsblk  

It gave me a dev tree, so outlining SDB1, SDB2 and SDB3. I knewi wanted to boot from SDB2, because this was the root file system.

I wrote a small script, passing /dev/sdb as the variable through it.

    #!/bin/sh  sudo dd if=/dev/$1 bs=4 skip=110 count=1 | hexdump  

It gave me the PARTUUID in the wrong endian format, so i just swapped it around. So the UUID for SDB2 is xxxxxxxx-02


Solution:3

To just see the UUID and PARTUUID you can just use ls:

  • ls -l /dev/disk/by-partuuid/ to see all partition's partuuid's

  • ls -l /dev/disk/by-partuuid/ to see all partition's uuid's


The right label for UUID is just uuid, so replace "partuuid" with "uuid" in your command.

lsblk -o name,label,uuid  

You'll probably need sudo to read the UUID too.


But really, if you're trying to find out where the partitions start for my USB you probably want to use something else, like fdisk or cfdisk or parted or probably best gparted.


Solution:4

If the goal is to identify the partition via a "partuuid" (really a GUID), you can get the partition unique GUID via GPT fdisk (gdisk, sgdisk, or cgdisk). If you need it from a script or a one-line command, sgdisk is the best bet. You'd do something like this:

$ sudo sgdisk -i 2 /dev/sda | grep unique  Partition unique GUID: 4D72D277-2E94-4760-8B38-8A487615E2E3  

This example gets the partition's unique GUID ("partuuid") from partition 2 (-i 2 on /dev/sda -- that is, /dev/sda2. This example pipes the output through grep simply to isolate the one line that's relevant -- this particular sgdisk command returns seven lines of output with various types of information on the partition.

To match the GUID to a known value, you'd need to loop through all the partitions, doing further processing on the output. This is likely to be awkward compared to something like viewing the contents of /dev/disk/by-partuuid/, but depending on the broader goal, it might be helpful or necessary. For instance, if you're trying to collect assorted data on the partitions (but not the filesystems they contain), sgdisk presents more than just the partition's GUID -- as I said, there are seven lines of output from the -i option:

$ sudo sgdisk -i 2 /dev/sda  Partition GUID code: 0FC63DAF-8483-4772-8E79-3D69D8477DE4 (Linux filesystem)  Partition unique GUID: 4D72D277-2E94-4760-8B38-8A487615E2E3  First sector: 1128448 (at 551.0 MiB)  Last sector: 2664447 (at 1.3 GiB)  Partition size: 1536000 sectors (750.0 MiB)  Attribute flags: 0000000000000000  Partition name: 'Unused /boot'  

If you want to show all that summary data, or even just three or four lines of it, then it may be better to use sgdisk than to try to piece it together from other sources.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »