0

how to know if some data already exist on device - disk

The simple way to check if disk include filesystem is to do:

 mount /grid/sdb /mnt

and if sdb or other /dev/sdx have file-system then mount will be succeeded, if not ... probably file system exists!

but this is ugly way to check that..

what the other elegant alternative to check file-system on disk?

my target is to check if file-system already configured on disk's as /dev/sdb - /dev/sdx

6
  • blkid / lsblk -f
    – Tom Yan
    Aug 10, 2017 at 14:49
  • do you mean to do for example - blkid | grep sdx , and if it match then we know for sure that filesystem created ? ( can you please write your solution as well .......................... )
    – King David
    Aug 10, 2017 at 14:58
  • You don't need grep. You can pass a specific drive to either of the commands.
    – Tom Yan
    Aug 10, 2017 at 14:59
  • you mean to run this - for example - blkid /dev/sdg
    – King David
    Aug 10, 2017 at 15:02
  • in any case fs not created on disk it will give standard output diff from 0
    – King David
    Aug 10, 2017 at 15:04

1 Answer 1

0

You could use parted -l to list partitions (and filesystems). In case you are interested in damaged or partially wiped filesystems you can use recovery tools such as testdisk.

2
  • so I guess - you mean to run this - parted -l | grep "unrecognised disk label" and if filesystem not create it will bring the disk that match the - "unrecognised disk label"
    – King David
    Aug 10, 2017 at 15:01
  • if you want only to see details for a single disk, you can use parted /dev/sdX print.
    – sebasth
    Aug 10, 2017 at 15:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .