Ray Arachelian
2012-Aug-13 10:48 UTC
[zfs-discuss] How do I import a zpool with a file as a member device?
While attempting to fix the last of my damaged zpools, there''s one that consists of 4 drives + one 60G file. The file happened by accident - I attempted to add a partition off an SSD drive but missed the cache keyword. Of course, once this is done, there''s no way to remove the new unwanted member. I fixed this by creating a file with mkfile, and adding the file as a mirror of the SSD partition, then removed the SSD partition from the zpool and kept the file around. Over time something went wrong with this zpool and it hung the OS from booting, so I removed it from the machine, but held on to it so I could attempt to recover. I''m trying to recover it now, but when I try to import it without cache and read only, it tells me a member is missing (the file of course). But, how do I pass the file name as a member of the zpool to the import command? Since it''s only 60g, I suppose I could dd the file over to an external USB drive. Would that work? Do I have to write it to slice 0, or a whole volume (slice 2)? I''m guessing this might be the path of least resistance... Or is there some hidden option to zpool import where you can pass it file/device names that I''m no aware of? (Attempting to use zpool online poolname /path/to/file doesn''t work since the zpool isn''t imported yet. Catch 22 there.) :) Otherwise, I do have a backup of the /etc/zfs/zpool.cache that contains references to this zpool, but it seems that this is corrupted and prevents all zpool operations. I''ve tried to replace the zpool members, but it won''t let me. I''ve even used a hex editor to replace the device names in the zpool.cache file with the new device names, but it''s still locked. So I can''t use the zpool cache file as a way to point to the file member. Is there some way to clear the "corrupted" flag in the zpool.cache from allowing zpool commands to work? I''m on oi151a5, but this zpool was created around oi134/135 or so.
Sašo Kiselkov
2012-Aug-13 10:50 UTC
[zfs-discuss] How do I import a zpool with a file as a member device?
On 08/13/2012 12:48 PM, Ray Arachelian wrote:> While attempting to fix the last of my damaged zpools, there''s one that > consists of 4 drives + one 60G file. The file happened by accident - I > attempted to add a partition off an SSD drive but missed the cache > keyword. Of course, once this is done, there''s no way to remove the new > unwanted member. I fixed this by creating a file with mkfile, and > adding the file as a mirror of the SSD partition, then removed the SSD > partition from the zpool and kept the file around. > > Over time something went wrong with this zpool and it hung the OS from > booting, so I removed it from the machine, but held on to it so I could > attempt to recover. > > I''m trying to recover it now, but when I try to import it without cache > and read only, it tells me a member is missing (the file of course). > But, how do I pass the file name as a member of the zpool to the import > command? > > Since it''s only 60g, I suppose I could dd the file over to an external > USB drive. Would that work? Do I have to write it to slice 0, or a > whole volume (slice 2)? I''m guessing this might be the path of least > resistance... > > Or is there some hidden option to zpool import where you can pass it > file/device names that I''m no aware of? (Attempting to use zpool online > poolname /path/to/file doesn''t work since the zpool isn''t imported yet. > Catch 22 there.) :) > > Otherwise, I do have a backup of the /etc/zfs/zpool.cache that contains > references to this zpool, but it seems that this is corrupted and > prevents all zpool operations. I''ve tried to replace the zpool members, > but it won''t let me. I''ve even used a hex editor to replace the device > names in the zpool.cache file with the new device names, but it''s still > locked. So I can''t use the zpool cache file as a way to point to the > file member. Is there some way to clear the "corrupted" flag in the > zpool.cache from allowing zpool commands to work? > > I''m on oi151a5, but this zpool was created around oi134/135 or so.See the -d option to zpool import. -- Saso
Ray Arachelian
2012-Aug-13 12:01 UTC
[zfs-discuss] How do I import a zpool with a file as a member device?
On 08/13/2012 06:50 AM, Sa?o Kiselkov wrote:> See the -d option to zpool import. -- SasoMany thanks for this, it worked very nicely, though the first time I ran it, it failed. So what -d does is to substitute /dev. In order for it to work, you also have to make links to the drive devices in the /dev tree. I did this in the directory where the file-members live (not knowing exactly off the top of my head which types of devices/slices zfs wanted) and then I was able to mount the pool, since the physical devices were c22t0d4-d7: for i in d4 d5 d6 d7; do for dev in /dev/dsk/c22t0${i}*; do echo $dev; ln -s $dev; done; done After this, using the -d option worked beautifully. Thanks for helping me recover my data. :)
Sašo Kiselkov
2012-Aug-13 12:05 UTC
[zfs-discuss] How do I import a zpool with a file as a member device?
On 08/13/2012 02:01 PM, Ray Arachelian wrote:> On 08/13/2012 06:50 AM, Sa?o Kiselkov wrote: >> See the -d option to zpool import. -- Saso > > Many thanks for this, it worked very nicely, though the first time > I ran it, it failed. So what -d does is to substitute /dev. In > order for it to work, you also have to make links to the drive > devices in the /dev tree. > > I did this in the directory where the file-members live (not > knowing exactly off the top of my head which types of > devices/slices zfs wanted) and then I was able to mount the pool, > since the physical devices were c22t0d4-d7: > > for i in d4 d5 d6 d7; do for dev in /dev/dsk/c22t0${i}*; do echo > $dev; ln -s $dev; done; done > > After this, using the -d option worked beautifully. > > Thanks for helping me recover my data. :) >No problem. Btw, the substitution for /dev/dsk is documented in the manpage. But glad it worked. Enjoy ;-) Cheers, -- Saso