[pkg-cryptsetup-devel] Bug#838001: parsing "zpool list" maybe better than parsing "zpool status"

Andras Korn korn-debbugs at elan.rulez.org
Tue Jun 26 09:40:50 BST 2018


Hi,

I saw your discussion about parsing the output of "zpool status" to find out
what devices a zpool needs.

I think parsing the output of "zpool list -PvHp" might be less error-prone.

This is a complex example:

# zpool list -PvHp
backup	1924145348608	1671564828672	252580519936	-	64	86	1.55	ONLINE	-
	/dev/disk/by-serial/MN1220FA057Y6D_2000TB_hdd-part5	1924145348608	1671564828672	252580519936	-	64	86
cache      -      -      -         -      -      -
	/dev/disk/by-serial/S2R6NX0J725133M_250GB_ssd-part5	21337997312	5375048192	15962949120	-	0	25
	/dev/disk/by-serial/S2R6NX0J725688Z_250GB_ssd-part5	21337997312	5703546880	15634450432	-	0	26
ssd	35701915648	19918471168	15783444480	-	81	55	1.00	ONLINE	-
	mirror	35701915648	19918471168	15783444480	-	81	55
	/dev/disk/by-id/wwn-0x5002538d421a92fb-part7	-	-	-	-	-	-
	/dev/disk/by-id/wwn-0x5002538d421a95b7-part7	-	-	-	-	-	-
spare      -      -      -         -      -      -
	/dev/disk/by-id/wwn-0x5000cca36ac1fa2d-part4	-	-	-	-	-	-
	/dev/disk/by-id/wwn-0x5000cca36ac232e8-part4	-	-	-	-	-	-
	/dev/disk/by-id/wwn-0x5000cca36ac24219-part4	-	-	-	-	-	-
	/dev/disk/by-id/wwn-0x5000cca36ac263ab-part4	-	-	-	-	-	-
zroot	1924145348608	1818994868224	105150480384	-	69	94	1.78	ONLINE	-
	mirror	1924145348608	1818994868224	105150480384	-	69	94
	/dev/sdb5	-	-	-	-	-	-
	/dev/sdd5	-	-	-	-	-	-
	/dev/sde5	-	-	-	-	-	-
log      -      -      -         -      -      -
	mirror	503316480	5541888	497774592	-	10	1
	/dev/sda3	-	-	-	-	-	-
	/dev/sdc3	-	-	-	-	-	-
cache      -      -      -         -      -      -
	/dev/sda6	42944954368	20906727936	22038226432	-	0	48
	/dev/sdc6	42944954368	21442340352	21502614016	-	0	49

Lines with a non-tab at the beginning of the line are pool names or "cache"
or "log" or "spare". Lines that start with a tab introduce member devices
(vdevs), which are either a path to a device or a special string like
"mirror" or "raidz".

To find what devices are needed for the rootfs and swap, you'd read this
list until you find the name of the root pool, then grab the 2nd field of
all lines that start with '\t/' (with TAB as the field separator) until
either EOF or a new pool name is read. This includes spares, but that's as
it should be.

If you also pass in the -L option to 'zpool list', it automatically follows
symlinks in device names.

You can also pass it the name of a pool, and then it'll only list that pool;
e.g.

# zpool list -PvHp gehenna
gehenna	231928233984	169009733632	62918500352	-	59	72	1.00	ONLINE	-
	/dev/mapper/crypt_sda4	231928233984	169009733632	62918500352	-	59	72

That said, I'm not sure it's worth the effort to support zfs fully
automatically.

I hope this helps.

Best regards,

AndrĂ¡s

-- 
                     The 'S' in 'IoT' stands for Security.



More information about the pkg-cryptsetup-devel mailing list