Formatting problem with sizes from /proc/partitions

Login or Register for Dates, Times and to Reply

Thread Tools Search this Thread
# 1  
Formatting problem with sizes from /proc/partitions

How would i display the output of /proc/partitions in gb representation/
Please help.
Also eager to know what is dm-0 and dm-1?

# cat /proc/partitions
major minor  #blocks  name

   3     0    8388608 hda
   3     1     104391 hda1
   3     2    8281507 hda2
   3    64     102400 hdb
   3    65      25168 hdb1
 253     0    7208960 dm-0
 253     1    1048576 dm-1

Moderator's Comments:
Mod Comment Try to write more descriptive subjects than "Little scripting help needed" in future, thanks.

Last edited by zaxxon; 07-16-2010 at 07:15 AM.. Reason: subject
# 2  
dm-0 and dm-1 look like Linux multipath SAN-disks.

A block is 512 bytes. To represent in GB, you have to calculate it. A hint with display is to use maybe the printf format option of using something like:
$> printf "%08d\n" "7"
$> printf "%08d\n" "123"

to represent something like 0.03 GB for example.

Since it is nicely separated to columns, awk might come handy also. If you get stuck at a point do not hesitate to ask here.
# 3  
Originally Posted by zaxxon
dm-0 and dm-1 look like Linux multipath SAN-disks.
There are no SAN disk. I m running this machine on virtual box.
# 4  
The dm-? devices are probably LVM volumes.

Originally Posted by zaxxon
A block is 512 bytes.
I'll have to disagree with you on this. At least on my system the output of /proc/partitions is in 1k (1024 Byte) blocks:
$ uname -a
Linux plu-desktop #1 SMP 2008-10-14 22:17:43 +0200 i686 i686 i386 GNU/Linux
$ fdisk -l /dev/sda

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0009693e

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        9243    74244366   83  Linux
/dev/sda2            9244        9729     3903795    5  Extended
/dev/sda5            9244        9729     3903763+  82  Linux swap / Solaris
pludikovsky@plu-desktop:~> cat /proc/partitions
major minor  #blocks  name

   8     0   78150744 sda
   8     1   74244366 sda1
   8     2          1 sda2
   8     5    3903763 sda5
   7     0    4302592 loop0
$ echo '78150744 * 1024' | bc

# 5  
Originally Posted by pludi
The dm-? devices are probably LVM volumes.
Is this because while creating virtual disk rather than allocating fixed sized disk i have set it to dynamically extend volume of disk?
# 6  
dm stands for device mapper. Could have been multipath disks but ok. You can check /dev/mapper or enter
dmsetup ls

for more info about those.
# 7  
No. Most current distributions forgo the old concept of partitioning the harddisk for various mount points, and use them as physical volumes for the Logical Volume Manager (LVM). That way one can add and remove space as needed, without a risky resize of partitions.

The guest system probably doesn't even know it's being run in an VM, and even if it does it probably won't care about how you configured the disks to work in the host system, as long as can access it.
Login or Register for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #442
Difficulty: Easy
84% of the women surveyed by Cosmopolitan Magazine in 2018 indicated they would prefer to date a computer programmer than a rock star.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Output formatting problem

Hello; I have a simple loop filtering a log: for LU in $(< LU-list-Final) do OUT=$(grep -B1 $LU cibc-src-ip.cap |egrep 'IP 16|IP 19|IP 15' |awk -F">" '{print $1}') if ; then echo " LU $LU was accessed by ===============> $OUT " echo "" fi done The current output snippet looks like... (2 Replies)
Discussion started by: delphys
2 Replies

2. Shell Programming and Scripting

trite formatting problem

Hello; having an annoying issue: I wish to have the same formatting in: awk '{print $1}' LOCAL f30f31be17a236378ac896639cc1b996 bff4c460f601444db6ef7f6ad6ca44b9 347a399b6fe9c2f21e6a7f55911c1483 ce3f8fdd4919e891090ca27872f4f983 c00098663f064d14065d0ef248a4db44... (2 Replies)
Discussion started by: delphys
2 Replies

3. Shell Programming and Scripting

Problem in formatting number

Hi, I was trying to format my number like i=1 to 000001 using the below method. typeset -Z6 i (sorry, corrected) My shell is K, is not doing, it is supposed to do Thanks in advance (6 Replies)
Discussion started by: ezee
6 Replies

4. UNIX for Dummies Questions & Answers

Query regarding /proc/partitions.

hi whenever i fire cat /proc/partition i get following output. I can make sense out of first 4 lines but what does dm-* suggests. Please help. # cat /proc/partitions major minor #blocks name 8 0 142577664 sda 8 1 104391 sda1 8 2 41945715 sda2 8 3 ... (1 Reply)
Discussion started by: pinga123
1 Replies

5. UNIX for Dummies Questions & Answers

_/proc/stat vs /proc/uptime

Hi, I am trying to calculate the CPU Usage by getting the difference between the idle time reported by /proc/stat at 2 different intervals. Now the 4th entry in the first line of /proc/stat will give me the 'idle time'. But I also came across /proc/uptime that gives me 2 entries : 1st one as the... (0 Replies)
Discussion started by: coderd
0 Replies

6. Shell Programming and Scripting

Problem with array sizes

If I do :- set -A classifications atype btype ctype dtype etype for i in ${classifications} do echo $i print $i >> /tmp/class.txt done print "${#classifications}" The array prints as I would expect and the size of the array is 5 (as expected). If I use an alternative... (2 Replies)
Discussion started by: sniper57
2 Replies

7. AIX

ProC and other C file compilation problem on AIX

I am linking my compiled proC file with other C files and getting following error. ld: 0711-711 ERROR: Input file /opt/orabase/oracle/product/10.2.0/db_1/lib/libirc.a is empty. The file is being ignored. I used following command to compile my proC code. proc iname=dbConnect.pc code=ANSI_C... (0 Replies)
Discussion started by: amit.singhal
0 Replies

8. Shell Programming and Scripting

Formatting Problem

Hi Suppose we have a file consisting of nos in following format 123 - 789 123 - 828 345 - 989 345 - 792 I require the following output 123, 789,828 345, 989,792 Means Unique nos in 1st Column and Corresponding two nos in comma separated 2nd Column Please help me out... (6 Replies)
Discussion started by: PradeepRed
6 Replies

9. Filesystems, Disks and Memory

Problem setting up raw partitions on SUSE v8.0 using LVM on Oracle 8.1.7.URGENT!!!!!!

Hi all! Working on Oracle v8. with OS  as Suse v8.0 Linux. I had created LVM,linked raw devices to LVM as below: # for binding raw devices raw /dev/raw/raw1 /dev/oracle/sam_raw_system_251m raw /dev/raw/raw2 /dev/oracle/sam_raw_users_26m raw /dev/raw/raw3... (2 Replies)
Discussion started by: Amitstora
2 Replies

10. Programming

Proc problem

Hello all , We have a c program , it is running well on AIX .But when we run it on AIX version the program exit when it begin to do this command : Exec sql connect . N.B: The version of C compiler is :4.2 Database :Oracle8 thanks in advance . Elie . (2 Replies)
Discussion started by: eyounes
2 Replies

Featured Tech Videos