Scripting deletion and creation of partitions
|
Author | Content |
---|---|
techiem2 Sep 19, 2008 1:21 PM EDT |
Hey all.
I'm working on creating a custom restore dvd set for our faculty laptops and want to make things easier on the user.
Our original setup had 2 partitons on the disk, but the current load only uses one.
So I'd like to have the disk automatically delete the partitions and create a single ntfs flagged partition using the full disk before running partimage.
I assume this is possible using some cli commands with fdisk, parted, or some such.
I just don't know how. Any of you gurus have any experience with this? Thanks all! Mark II |
gus3 Sep 19, 2008 1:52 PM EDT |
If you can guarantee that all drives have identical geometry and partition layout, it's easy enough to pipe input to fdisk. I have used this technique myself. Then again, in your case it might be a brute-force solution to delete all partitions, from 8 to 1 (whether they exist or not), then create a new partition with default everything (from the first available sector to the end of the disk) and tag it as ntfs. I think that might give you the results you need. Don't forget to save the changes at the end! |
hkwint Sep 21, 2008 8:32 AM EDT |
I'd use sfdisk. It's what I used in the past when I screwed up; and to make 'backups' of my partition tables. What you basically do is the following: -Partition a 'test-device' - meaning the dvd partitioned in the 'future' manner; than dump in a format suited for later input. Something like: #/sbin/sfdisk -d /dev/hdc >> dvd_disk.setup Now, you don't have to delete the old partitions; you just can provide this input to sfdisk. #/sbin/sfdisk /dev/hdd < dvd_disk.setup However, I'm not sure this works for writable DVD as well. It does work for magnetic harddisks. Please read about the -O and -I option in the sfdisk manual; they provide an extra security mechanism you might need. |
techiem2 Sep 21, 2008 2:10 PM EDT |
Thanks guys! I hadn't thought of using sfdisk for it. That would probably be the easy way. Theoretically all the hard disks are identical (they're all the same model laptop anyway). |
gus3 Sep 21, 2008 9:37 PM EDT |
@techiem2: Theoretically, yes, but you might want to check geometry on them first, or at least a sample of them. In my experience, manufacturers might substitute drives of equal, or slightly larger, capacity in order to match advertised specs, meaning the same model system might have a different model h.d. |
You cannot post until you login.