[BusyBox] applet: read disk partition only

bug1 at optushome.com.au bug1 at optushome.com.au
Sun Dec 29 08:42:03 UTC 2002


Ive been thinking about partitioning, there are lots of compromises with
existing tools.

I think it would be more flexible to have a cleaner sepeartion between
existing tools, so the task can be done in more descrete steps.

1) detect devices
2) detect partitions
3) detect filesystems
4) create/modify partitions
5) create/modify filesystems

Advatage of breaking it up is that only the needed tools have to be
provided.

parted does a very good all round job, but it has to be pretty big to
support all those features.

I hacked up libfdisk and made a small busybox appplet (rdisk, i.e. read
disk) that provides a similar output to fdisk -lu <device>

e.g.
home:/home/bug1/dev/busybox# ./busybox rdisk /dev/hda

Disk /dev/hda: 20.5 GB = 40160988 sectors
Units = sectors of 1 * 512 bytes

   Device Boot    Start       End    Blocks   Id  System
/dev/hda1            63    999936    499936+  82  Linux swap
/dev/hda2   *    999936   1976688    488376   83  Linux native
/dev/hda3       1976688   4905936   1464624   83  Linux native
/dev/hda4       4905936  40160736  17627400    5  DOS Extended
/dev/hda5       4905999  10765440   2929720+  83  Linux native
/dev/hda6      10765503  40160736  14697616+  83  Linux native

fdisk could be used directly, but you have to take the partition
creation/modifciate capability with it... and you dont know wether that
is needed, or which tool(s) are best used (parted / cfdisk / raidtools /
lvm stuff) untill after you see the current state

Similar information could be gathered by parsing /proc/partitions, but
you dont get the partition type which can be quite usefull for
identifying partitions, also it is kernel dependent.

What ive done is only experimental, it only detects standard msdos
partitions, if its going to be usefull i will have to put a bit of stuff
back in.

As it is it only adds 4kB to the busybox udeb, a patch is at
http://people.debian.org/~bug1/busybox/rdisk.diff

It would be pretty trivial to change the format so that it could be more
easily parsed or whatever


 
and trivial




More information about the busybox mailing list