Changing the partition used by the task

  • Good Morning!

    I’m experimenting with FOG 1.0.0 now, and I’ve run into a bit of a problem. On computers which have a recovery partition, tasks like checkdisk and clam fail. It tries to use /dev/sda1, which happens to be the recovery partition. I can see the usual error ‘NTFS Signature missing’, which makes sense because it’s not defined as an NTFS partition.

    If I boot into debug mode, fdisk -l shows me that /dev/sda2 is the boot partition. I can mount /dev/sda2 using ntfs-3g as well.

    I tried specifying the correct partition under the Host in ‘Host Primary Disk’, but it appears this is for the whole disk only, as it appends a ‘1’ to whatever I enter. I skimmed through available kernel arguments on the fog wiki, but couldn’t find an appropriate one. If anyone has some suggestions, I’m all ears!

    I found a related thread:

    But this is simply asking about entering the partition under ‘Host Primary Disk’.


  • Developer

    fog has a git that is synchronized with the svn [url][/url]

  • Tom,

    I found some time to just dive in. In the init image, under bin/fog.av, the code that selects the partition is this:
    If the OS is set to windows 7, then it simply selects the last partition of all the partitions.
    [CODE] if [ “$osid” == “5” ]; then
    parts=fogpartinfo --list-parts $hd 2>/dev/null;
    for prt in $parts
    win7partcnt=expr ${win7partcnt} + 1;

    To obtain the behavior I was speaking of, I added this simple bit to the fog.av script:


        partNum=`parted $hd -m print | grep 'boot' | sed -n 's/^\([0-9]\+\).*/\1/p'`;
        if [ -n "$partNum" ]

    This finds the boot partition on the selected hard drive, then uses that partition number, instead of just selecting partition 1. When will this not work? Dual boot machines would likely have a problem, but there’s a 50% (or 33%) chance they wouldn’t work in the original configuration anyway. But on dual partition (where one partition is a recovery partition) and single partition machines, this works great. I have a clamscan running on a previously offending computer now.

    The code above is not a final solution. I will be creating a function under the script and applying it to the rest of the scritps as I see fit. I’ll probably also refine the sed portion a little bit.
    Can you see any issue with this method which makes it worse off than just using $hd’1’?

    I’ve only used git, but I can submit a pull request (or whatever the equivalent terminology is for svn) of my completed work if you see no issue so far.

  • Moderator

    I’ve seen some manufacturers use weird practices such as intentionally broken partition information to lock down their recovery partitions. I’ve never been a fan of this, and it becomes quite a pain when a rootkit finds its way in there and you can’t. If you have installation media for your OS, and have the keys you use recorded somewhere, then you really are safe to nuke those partitions. All they do for you is what Fog can do better.

  • Senior Developer

    I think they try to iterate through all of the partitions.

  • That was my other thought. Tools such as the checkdisk and clamAV - what criteria are they using to select the windows partition? Because it’s selecting the wrong partition to act on in my case.

  • Senior Developer

    The fog system is actually attempting to find all partitions. Telling it “which” partitions are needed isn’t supported, nor should it be.

    I realize the want of being able to do so, but if you need such granular control, you may be better off booting into a “debug” mode and running the commands yourself where needed.

  • Hi Tom!

    [quote=“Tom Elliott, post: 26826, member: 7271”]Host Primary Disk should be the Device, not a partition label.[/quote]

    This part I have already figured, so I abandoned this early on.
    [quote=“Tom Elliott, post: 26827, member: 7271”]I’m going to guess that you’re trying to create a Single Disk Resizable image?[/quote]
    Actually, I’m not trying to create any image yet. At the moment, I’m just playing with the additional tools FOG comes with. My question is, is there a way to change the partition these tools use? Instead of automatically using /dev/sda1, can I change it to /dev/sda2?
    Thank you for such a quick reply!

  • Senior Developer

    I’m going to guess that you’re trying to create a Single Disk Resizable image?

    If you are, you’re better off actually recreating the image from scratch rather than trying to use the OEM installed information.

  • Senior Developer

    Host Primary Disk should be the Device, not a partition label.