Postdownloadscripts to specific partitions



  • I need a little help with postdownloadscripts. Are they executed after all image are deployed or one partition?

    We have 4 partitions in a disk (mbr) and we need to change a hostname in linux and hostname in a file under Windows partition.
    The problem is that linux and windows are not fixed to a partition numbers (sometimes sda3 or sda and so on)

    How can i identify Windows or Linux, excluding swap and recovery?
    Maybe this is more about linux skills than fog.



  • @george1421
    we have a few images. my script mount directly (i.e. mount /dev/sda2 /windows)
    The problem is: now, our server will be used by another department with other config (i only know that they have 4 parts, using mbr) and sometimes the image name can change, disk layout too.
    I like your idea and wanna let things more generalized as possible.
    in any case, this is temporary until standardize all
    Thanks a lot


  • Moderator

    @Thiago OK then please stay with me here (not trying to be too difficult).

    Can I assume you have one image you captured and are deploying to these computers? If so that captured image has a specific drive layout and doesn’t matter if it is windows or linux. For example /dev/sda2 within that image will always be the linux swap partition when you deploy that specific captured image. Or if you have 2 image captured, for image 1, /dev/sda2 will always be that swap partition. So if this is the case you will always know the layout of the target computer because of the layout of the original captured image.

    There is also a post download variable you can use called $img that matches the captured image name in fog. You could create a switch statement so if $img = “image1” then geometry is x,y, if $img = “image2” then geometry is y,z.

    Don’t get me wrong, you can do it the way you have planned no problem. It would be more flexible if you have many images, but if you only have a few making a few assumptions (educated guesses) based on the know configuration of the captured image would give you results faster.

    The other thought I had, what are you using for the dual boot loader for these computers? Grub? It may be possible to query the grub config file to find the location of important partitions too.



  • @george1421
    Yes we have dual boot system. Debian 8 with Win10/Vista.
    Computers Lab.


  • Moderator

    Sorry for me being dumb here, but what is the use case for having both windows and linux partitions on the same physical disk? Are you doing a dual boot between linux and windows?



  • @Sebastian-Roth
    Thanks for the tip.
    assuming we have only one disk on each machine, there are always 2 parts for Windows (winre and C:) and 2 for linux (swap and /).
    My 1st idea is to do something like this:

    #for linux
    fdisk -l /dev/sda | awk '/ 83 / {print $1}'
    

    or this

    #for windows, it requires more pipes
    fdisk -l /dev/sda | awk '/ 7 /' | sort -k5 -h | tail -n1 | awk '{print $1}'
    

    I will work on this.
    Thank you all for the great help.


  • Developer

    @Thiago $osid is set for a whole image (all partitions) AFAIK. So this won’t be of much help for you. ch3i’s suggestion using fdisk sounds like a good idea. Or you can use lsblk -o KNAME,FSTYPE


  • Moderator

    The $osid is populated with the value you assign to the image from within the fog console. The integer number stored in $osid is the integer value listed in the drop down list for Operating System under image management.



  • @george1421
    Yes, Windows and linux are on the same drive. All computers have only 1 disk.
    While our organization don’t make a default layout for disks (fixed parts for specific system), i will try using $osid.
    This variable inside a postdownscript env, identify parts or system images defined in fog web ui?


  • Moderator

    Do you mean you are putting both linux and windows on the same hard drive?

    If not then you can check the system type and then make your partition selection from that. If you do have floating partitions, I think you better work on a different plan because this will be trouble to manage.

    Just for reference you can use the variable $osid to identify the OS that will be deployed to the target computer.


  • Moderator

    @Thiago Hi, you can use fdisk -l to identify the partition type via the id

    List of IDs :

    0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
     1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-
     2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-
     3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
     4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx
     5  Extended        42  SFS             86  NTFS volume set da  Non-FS data
     6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP/M / CTOS / .
     7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility
     8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt
     9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access
     a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O
     b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor
     c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs
     e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT
     f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/
    10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b
    11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor
    12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor
    14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary
    16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS
    17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE
    18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto
    1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep
    1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT
    1e  Hidden W95 FAT1
    

Log in to reply
 

437
Online

38939
Users

10697
Topics

101495
Posts

Looks like your connection to FOG Project was lost, please wait while we try to reconnect.