4

sudo fdisk -l gives :

255 heads, 63 sectors/track, 60801 cylinders, total 976773168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xdb20e840

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048   104859647    52428800    7  HPFS/NTFS/exFAT
/dev/sda2       104859648   310630399   102885376    7  HPFS/NTFS/exFAT
/dev/sda3       310632840   372065399    30716280   83  Linux
/dev/sda4       372072446   838281215   233104385    5  Extended
/dev/sda5       372072448   392552447    10240000   83  Linux
/dev/sda6       392554496   453994495    30720000   83  Linux
/dev/sda7       453996544   515436543    30720000   83  Linux
/dev/sda8       515438592   515456169        8789   82  Linux swap / Solaris
/dev/sda9       515457024   552321023    18432000   83  Linux
/dev/sda10      552323072   585091071    16384000   83  Linux
/dev/sda11      585093120   617861119    16384000   83  Linux
/dev/sda12      617876028   822656519   102390246    7  HPFS/NTFS/exFAT
/dev/sda13      822657024   838281215     7812096   82  Linux swap / Solaris

While df -h gives :

Filesystem      Size  Used Avail Use% Mounted on
/cow            1.9G   30M  1.9G   2% /
udev            1.9G  4.0K  1.9G   1% /dev
tmpfs           385M  1.1M  384M   1% /run
/dev/sr0        913M  913M     0 100% /cdrom
/dev/loop0      874M  874M     0 100% /rofs
none            4.0K     0  4.0K   0% /sys/fs/cgroup
tmpfs           1.9G  8.0K  1.9G   1% /tmp
none            5.0M     0  5.0M   0% /run/lock
none            1.9G   80K  1.9G   1% /run/shm
none            100M   24K  100M   1% /run/user
/dev/sda9        18G  1.2G   16G   8% /media/xubuntu/b90d1c45-7805-421b-9ba7-88ab7ed04fd3
/dev/sda7        29G  4.2G   24G  16% /media/xubuntu/964f9a2f-3641-4754-8319-1decea626931
/dev/sda6        29G   20G  7.8G  72% /media/xubuntu/4f6e6be0-a703-4cb6-a425-9ae73f31eb82
/dev/sda5       9.5G   22M  9.0G   1% /media/xubuntu/3c662996-cf77-41a3-9b5d-d7520f8d534a
/dev/sda3        29G  3.4G   24G  13% /media/xubuntu/57f03636-d50f-43fe-97c0-192b761d7054
/dev/sda12       98G   18G   81G  19% /media/xubuntu/5943EBDD309DF483
/dev/sda11       16G  935M   14G   7% /media/xubuntu/a2176105-4afc-4f19-b182-c027925e249e
/dev/sda10       16G   40M   15G   1% /media/xubuntu/4397bd85-5172-4dc4-a4ce-e9690d3ac7f9
/dev/sda1        50G   32G   19G  64% /media/xubuntu/OSDisk

How can I combine these two results using awk or something else to have in the same command that result in the following output.

**Device  -  System_Type  -  Size   -  Use%    -    Mount_Point**

4 Answers 4

7

why can't you try df -hT?

Output

-bash-3.2$ df -hT
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/sda2     ext3     48G   17G   29G  37% /
/dev/sda5     ext3    238G   66G  160G  30% /home
/dev/sda1     ext3     99M   17M   77M  18% /boot
tmpfs        tmpfs    2.0G     0  2.0G   0% /dev/shm

The type specifies the system type and the only exception is this will show only the mounted file systems as opposed to fdisk -l which shows all the available partitions irrespective of whether they are mounted or not.

3
  • I prefer to get only physical filesystems in the output. How can do so?
    – Nadina
    May 28, 2014 at 20:18
  • Do you mean to get the system type as Windows/Linux in the output?
    – Ramesh
    May 28, 2014 at 20:24
  • yes not to get FS such udev, tmpfs and so on..
    – Nadina
    May 28, 2014 at 21:00
2

From man mount:

For more robust and definable output use findmnt...

findmnt --help
...
-D - imitate the behavior of df
...
Available Columns:
      SOURCE  source device
      TARGET  mountpoint
      FSTYPE  filesystem type
     OPTIONS  all mount options
 VFS-OPTIONS  VFS specific mount options
  FS-OPTIONS  FS specific mount options
       LABEL  filesystem label
        UUID  filesystem UUID
   PARTLABEL  partition label
    PARTUUID  partition UUID
     MAJ:MIN  major:minor device number
      ACTION  action detected by --poll
  OLD-TARGET  old mountpoint saved by --poll
 OLD-OPTIONS  old mount options saved by --poll
        SIZE  filesystem size
       AVAIL  filesystem size available
        USED  filesystem size used
        USE%  filesystem use percentage
      FSROOT  filesystem root
         TID  task ID
          ID  mount ID
  OPT-FIELDS  optional mount fields
 PROPAGATION  VFS propagation flags
        FREQ  dump(8) period in days [fstab only]
      PASSNO  pass number on parallel fsck(8) [fstab only]

...

findmnt -D

SOURCE                  FSTYPE           SIZE   USED AVAIL USE% TARGET
devtmpfs                devtmpfs        11.8G      0 11.8G   0% /dev
tmpfs                   tmpfs           11.8G  95.1M 11.7G   1% /dev/shm
tmpfs                   tmpfs           11.8G   928K 11.8G   0% /run
tmpfs                   tmpfs           11.8G      0 11.8G   0% /sys/fs/cgroup
/dev/sda2[/manjaro]     btrfs             12G   7.8G  3.8G  65% /
tmpfs                   tmpfs           11.8G 758.2M   11G   6% /tmp
/dev/sda1               vfat               3G   588M  2.4G  19% /esp
/dev/sda1[/EFI/manjaro] vfat               3G   588M  2.4G  19% /boot
tmpfs                   tmpfs            2.4G     8K  2.4G   0% /run/user/1000
gvfsd-fuse              fuse.gvfsd-fuse     0      0     0    - /run/user/1000/gvfs
2

Here's a modified version of Ramesh's answer which gives you the columns you need of only the important filesystems (not udev, tmpfs).

disks=$(sudo fdisk -l | grep -Po "/dev/sd.\d+")
for i in $disks; do df -Th $i | tail -n 1; done
1
  • He wants the Filesystem Type in there as well. That's part of the problem.
    – Jeight
    Jun 4, 2014 at 21:42
-1

This might be to simple but you could always just use &&:

sudo fdisk -l && df -h

But cfdisk may do what you're wanting:

cfdisk -P s

Partition Table for /dev/sda

           First       Last
# Type       Sector      Sector   Offset    Length   Filesystem Type (ID) Flag
-- ------- ----------- ----------- ------ ----------- -------------------- ----
 Pri/Log           0        2047*     0#       2048*Free Space           None
 1 Primary        2048*    1026047*     0     1024000*Linux (83)           Boot
 2 Primary     1026048*    3074047*     0     2048000*Linux swap / So (82) None
 3 Primary     3074048*   41943039*     0    38868992*Linux LVM (8E)       None
1
  • Whomever down voted me, learn to take a joke...geeze. My second (serious) answer has both the file length and Filesystem Types which was kinda (not exactly) what he was asking for.
    – Jeight
    Jun 4, 2014 at 21:44

You must log in to answer this question.

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