Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

How do I get the list of all devices which are root dependent i.e either mounted on root filesystem or created from root devices(Logical volume on the top of physical volume which is root device).

EDIT

Answer must be an script (may be shell) that will return list of all the root dependent devices.I dont wanna use any LVM specific package command (such as lvdisplay etc).

23-OCT-2013

As answer posted by @Oli,

mount | awk '$3 ==  "/" {printf $1}' | sed s'/.$//'

Only lists the device.But I want which of its partition is actually a root dependent.

I tried getting which LVM device is mapped to physical device using dmsetup deps

I got

ubuntu-swap_1: 1 dependencies   : (8, 5) 
ubuntu-root: 1 dependencies : (8, 5)

Above gives me mapping(can get by comparing (major, minor) number) but how can I ensure LVM is root device?

share|improve this question
2  
Why no lvdisplay? –  Oli Oct 22 '13 at 9:41
    
@Oli use of lvdisplay will make it lvm package dependent. You need to install LVM package before using it(as its not inbuild). So no to LVM package commands.Can use dmsetup instead. –  Pilot Oct 22 '13 at 11:10
add comment

2 Answers

  • df -h will list all devices/mounts.
  • lsof / will list all open files under root.
  • lvs, lvscan, and lvdisplay are used for LVM information.
share|improve this answer
    
df -h will not give me LVM details which is created from root device. And I want devices which are either created from root or root device. –  Pilot Oct 18 '13 at 11:25
    
For LVM, you can use lvscan, lvs, and lvdisplay. –  mmstick Oct 18 '13 at 11:30
add comment

Well to find out the root device (virtual or physical), I've been using:

mount | awk '$3 ==  "/" {printf $1}' | sed s'/.$//'

Past there, it's fairly simple. You either have a device, or you have a mapped device. If it's mapped, dmsetup info can help resolve physical devices:

$ ROOTDEV=$(mount | awk '$3 ==  "/" {printf $1}' | sed s'/.$//')
$ sudo dmsetup info -Co blkdevs_used $ROOTDEV | tail -n+2
sdg,sdf 

Of course, if $ROOTDEV isn't a mapped, device, everything will explode in a sticky, hot mess. It should be noted that dm-mapper can map partitions, so you may need to recurse through returned devices until you end up with sd* strings.

I've no idea how this works in an LVM environment. I've tested it on JBOD and dmraid-1.

share|improve this answer
    
Thanks for replying.But your solution wont work in case of LVM devices.I am testing it on ubuntu 12.04 –  Pilot Oct 22 '13 at 17:31
    
Can you provide any actual output? You've tied our hands from using LVM specific tools so it's a bit hard to debug. –  Oli Oct 22 '13 at 19:16
add comment

Your Answer

 
discard

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.