LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   automated fdisk problem -- advice needed (https://www.linuxquestions.org/questions/linux-software-2/automated-fdisk-problem-advice-needed-52170/)

Frustin 03-28-2003 05:54 AM

automated fdisk problem -- advice needed
 
I have a boot cd that has a small linux distro on it and i am trying to alter the boot up script (rcS) so that it automagically partitions a HDD.

I was thinking of getting the fdisk list and then diffing it with the table that i want like so:

fdisk -l /dev/hda > file.txt
diff file.txt intended_partition_table.txt
if null then no need to partition

however thats going to be a problem then as the partition table set up that i want to load up to partition the disk looks like this:

# partition table of /dev/hdc
unit: sectors

/dev/hdc1 : start= 63, size= 523089, Id=83
/dev/hdc2 : start= 523152, size= 1049328, Id=82
/dev/hdc3 : start= 1572480

as you can see /dev/hdc3 is supposed to start at 1572480 and by not putting a value for size it will use the rest of the harddrive space, that way i can put a hardrive of any size in and it will always be able to put this configuration in.

this is a list that i took off of the HDD as it currently stands:

Disk /dev/hdc: 29785 cylinders, 16 heads, 63 sectors/track
Units = cylinders of 516096 bytes, blocks of 1024 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/dev/hdc1 0+ 518 519- 261544+ 83 Linux
/dev/hdc2 519 1559 1041 524664 82 Linux swap
/dev/hdc3 0 0 0 0 0 Empty
/dev/hdc4 0 - 0 0 0 Empty

so you can see no matter what i put in the doctored patition file will always produce a difference.

Anyone got any ideas? I did think that i shouldnt need to do the check, because repartitioning a disk with the same partition table that is already on the HDD wont cause any data loss.

Frustin 03-31-2003 01:47 AM

anyone at all?

Mik 03-31-2003 02:22 AM

I think you should do the check no matter what. You don't want to go repartitioning the disk everytime.
I'm not sure if I understand exactly what you are trying to accomplish. But if you want the output of fdisk -l /dev/hdc to be in the same format as your reference file. You will have to parse the output and then change the format which can then be copied to a temp file or directly compared to the reference file.

I don't know how familiar you are with any types of scripting languages. But perl would probably be a good candidate for that.

Frustin 03-31-2003 02:54 AM

i am creating a setup cdrom disk. put it in the drive turn on computer and then when it says power off remove the disk and your linux is installed onto the harddrive.

Thing is i figure if i can tell it not to repartition every time then it can also be used as a restore disk incase the files on the harddrive get stuffed in some way, hence why i would like to do the check.


All times are GMT -5. The time now is 01:35 AM.