Web lists-archives.com

Re: Partition information as text file?




On Wed, 30 Jan 2019 09:07:37 -0600
Richard Owlett <rowlett@xxxxxxxxxxx> wrote:


> >   
> >>   I get the following error message:  
> >>> root@fromdell:/home/richard# tune2fs -l /dev/sda
> >>> tune2fs 1.43.4 (31-Jan-2017)
> >>> tune2fs: Bad magic number in super-block while trying to
> >>> open /dev/sda Found a dos partition table in /dev/sda  
> > 
> > You must specify the partition containing the filesystem, not the
> > whole disk.  
> 
> The man pages for fdisk, parted, sfdisk, tune2fs, and dumpe2fs each
> give "device" as a possible parameter. Only the last two balk at it.
> 
> 
> 

On *some* devices. Not all devices have partition tables. I've seen a
few USB sticks come formatted without a partition table, which
strangely, *almost* works. Some software can deal with it, some can't.
I first encountered it when using one to move data between OSes, and
it took me a while to figure out what was going on.

I'm sure you've realised by now, your requirement is to extract
information from two different types of object, partitions and
filesystems. That requires two different utilities. Apparently GParted
will make a stab at displaying free space on unmounted filesystems, but
it either does that by temporarily mounting them or it interprets the
metadata of the filesystem itself, with no guarantee that it always gets
it right. An unmounted filesystem is basically, well, gibberish, a
collection of tables and file fragments. It's only when the filesystem
is mounted that the parts of it that we mortals are allowed to see make
sense.

I suspect that to get exactly what you want, you will need to write a
script that uses basic tools, checking for mounted filesystems and then
temporarily mounting as necessary. 

By the way, you haven't mentioned LVM...

-- 
Joe