Re: Partition information as text file?
- Date: Fri, 1 Feb 2019 16:23:04 +0100
- From: <tomas@xxxxxxxxxx>
- Subject: Re: Partition information as text file?
On Fri, Feb 01, 2019 at 09:00:06AM -0600, Richard Owlett wrote: > On 02/01/2019 08:22 AM, Thomas Schmitt wrote: [...] > >So you need one or more scripts ... Then the script[s] would put out > >the retrieved numbers in the text format which you desire. > > The need for *ME* to write a script was a BASIC assumption to my > asking about commands relevant to my task. Perhaps the humble command "file" could be an ally in that. It's not a complete solution, though... Remember: "file" looks (with some exceptions, see below) into the contents of a file and tries to find out what it is, by looking for "magic numbers" (more precisely patterns) stored in a file (/usr/share/misc/magic). Here's a small session from my box (with some elisions marked as [...] tomas@trotzki:~$ mount /dev/sda1 on /boot type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl) /dev/mapper/trotzki-root on / type ext4 (rw,relatime,errors=remount-ro,data=ordered) /dev/mapper/trotzki-usr on /usr type ext4 (rw,relatime,data=ordered) /dev/mapper/trotzki-home on /home type ext4 (rw,relatime,data=ordered) /dev/mapper/trotzki-var on /var type ext4 (rw,relatime,data=ordered) [...] (Note: my "partitions" are, with exception of /dev/sda1, which is the boot partition, LVM volumes which are cut out from a physical volume which is LUKS encrypted: I don't want someone to get at my (and my customer's) data just because I leave the laptop in the metro). Now: tomas@trotzki:~$ file /dev/mapper/trotzki-home /dev/mapper/trotzki-home: symbolic link to ../dm-4 Ah. tomas@trotzki:~$ file /dev/dm-4 /dev/dm-4: block special (254/4) Not yet what we wanted. But: tomas@trotzki:~$ sudo file -s /dev/dm-4 /dev/dm-4: Linux rev 1.0 ext4 filesystem data, UUID=c5d1ae98-df63-4c04-913d-661b82d38075 (needs journal recovery) (extents) (64bit) (large files) (huge files) I guess that's not all info you want, but hey. Sudo is needed, because mere mortals have no business in reading raw disks, usually; The "needs journal recovery" sounds alarming, but remember that the thing is mounted, i.e. active, so that's OK too. Perhaps this can be a small building block for you. I guess you'd like more info about the file system (size, what not). Those commands (and their outputs!) are most probably file system specific, as Thomas points out. Cheers -- t
Description: Digital signature