Suppose I have a set of brand new servers that boot from PXE.
What I want to do is automatically detect that the internal HDD is not formatted and therefore create the partition and format it automatically at boot. Followed by adding the appropriate entry to fstab and mounting it. After that, it will be left alone. The drive is used for caching data only.
The bits I'm stuck on are 1) Recognize whether a disk has partitions or not. i.e. check if disk has a partition table. Can I just test for presence of file /dev/sda and not /dev/sda1? 2) recognizing which disk I booted from so I can ignore it. 3) Creating the partition from the command line.
So, what I'm hoping to put together is a script I can put into the boot process.