Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I got a server with 2 hard drives. I would like to know what is on 2nd drive. How would I list all contents on physical device ?

xvda    202:0    0  40G  0 disk 
└─xvda1 202:1    0  40G  0 part /
xvde    202:64   0  40G  0 disk 
└─xvde1 202:65   0  40G  0 part 

I run the above code. Does it mean that 2nd drive is empty and not in use ?

share|improve this question
up vote 5 down vote accepted

The answer to your questions are maybe, and yes.

lsblk will hide empty devices -- however, in its case, it is only talking about partitions, not the data on those partitions. lsblk is not the best tool for the job here.

This does, however, tell us the partition is not mounted - so yes, it is not currently being used.

So, is there any data on the partition (and therefore, the drive)?

We can find this out with the df command, or disk free.

To view the contents of the partition (and because there is only one partition, we can call this the contents of the drive itself), we first need to mount it.

Let's create a directory for it, as root

# mkdir /mnt/xvde1

And then mount this partition

# mount /dev/xvde1 /mnt/xvde1

Next, before we get to viewing the actual information... let's see how much (if any) disk space is being used. We know the partition is ~ 40GB large, but that's the allocated space, not the used space. [thanks to @n.st in the comments for suggesting to use the partition as an argument to df!]

# df -H  /dev/xvde1 

Will tell us how much space is being used. Here is an example from my filesystem

Filesystem Size Used Avail Use% Mounted on /dev/sda3 43G 15G 29G 35% /

The second column (15GB) is the used amount. this is what we're looking for! If it is > 0, this drive is not empty!

You can view all of your mounted filesystems' information by simply using

$ df -H

We use H for "Human readable", by the way. Try it without H and you'll see everything is in K blocks!

And finally, we can view all of its contents (filenames at least) by using:

# ls -R /mnt/xvde1

Good luck!

share|improve this answer
Why don't you just use df -H /mnt/xvde1? That way you will also keep the column titles in the output. – n.st May 1 '14 at 11:27
Thanks @n.st. I didn't think df would take a partition/mount as an argument, very cool! I'll update the answer and attribute it to you. – Travis May 1 '14 at 12:32
You can even do something like df -h . if you want to know the free space of the current working directory without looking up its mount point. – n.st May 1 '14 at 13:27

First specifically regarding the example from the question:

No! It does not mean the second drive is empty.

The lines

xvde    202:64   0  40G  0 disk
└─xvde1 202:65   0  40G  0 part 

mean there is a 40GB partition on that disk that is currently not mounted, and may, or may not contain a filesystem. It says nothing about the data on it. It does also not say whether it can be mounted at all.

In general:

To list all local partitions - mounted and unmounted ones - you can use

fdisk -l

which shows the partition tables - similar to cat /proc/partitions proposed in the answer of @Ramesh, but with some additional details that may help to identify disks and partitions (ie: partition type id, boot flag, disk identifier).
See below for example output.

For identifying data actually inside the partitions, use file -s as proposed by @Ramesh:

# file -s /dev/sdc1
/dev/sdc1: Linux rev 1.0 ext4 filesystem data, UUID=[...]

Example output of fdisk -l (shortened):

Disk /dev/sdc: 120.0 GB, 120034123776 bytes                                                                                                                                   
255 heads, 63 sectors/track, 14593 cylinders, total 234441648 sectors                                                                                                           

Disk identifier: 0x0005550d                                                                                                                                                     

   Device Boot      Start         End      Blocks   Id  System                                                                                                                  
/dev/sdc1            2048   217643007   108820480   83  Linux                                                                                                                   
/dev/sdc2       217645054   234440703     8397825    5  Extended                                                                                                               
/dev/sdc5       217645056   234440703     8397824   82  Linux swap / Solaris                                                                                                   

Disk /dev/sdd: 160.0 GB, 160041885696 bytes        
share|improve this answer

/proc/partitions will list all the block devices and partitions that the system recognizes. You can then try using file -s <device> to determine what kind of file system is present on the partition, if any.

You can look for more options here.

share|improve this answer

You need to mount the filesystem and then list it for files, if any.

mount /dev/xvde1 /mnt  || echo 'No filesystem found'
ls -lR /mnt | tee /tmp/xvde1_files.txt
umount /mnt
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.