python - Find the superblock on disk -
i have write python script in work. script must print devices meet conditions. 1 of conditions superblock. device must have superblock.
other conditions:
- any partitions not mounted - done
- any partition not in raid - done
- uuid not in fstab - done
- arr uuid in mdadm.conf - done
- device has superblock - ?????
is there has idea how it? have confess dont have any. it's not necessary manage python. there way how check ? :)
thank much.
you can grep output of dumpe2fs device_name
existance of "superblock at".
here's example on centos 5 linux system:
>>> import shlex, subprocess >>> filesystems = ['/dev/mapper/volgroup00-logvol00', '/dev/vda1', 'tmpfs'] >>> fs in filesystems: ... command = '/sbin/dumpe2fs ' + fs ... p = subprocess.popen(shlex.split(command),stdout=subprocess.pipe,stderr=subprocess.stdout) ... output = p.communicate()[0] ... if 'superblock at' in output: ... print "{fs} has superblock".format(fs=fs) ... else: ... print "no superblock found {fs}".format(fs=fs) ... /dev/mapper/volgroup00-logvol00 has superblock /dev/vda1 has superblock no superblock found tmpfs
more information on dumpe2fs:
Comments
Post a Comment