You are not logged in.

#1 2011-04-22 18:24:42

RetroX
Member
Registered: 2009-10-17
Posts: 106

AIF - Automatic install help

I'm kind of confused on how the partitioning works.  This line in one of the default configurations:

PARTITIONS='/dev/sda 100:ext2:+ *:ext4'

Seems a bit weird to me, and the wiki doesn't explain it very well.  I looked in a few of the bash sources for AIF and it didn't really help me understand what's going on.

What I'm trying to do is, if possible, edit some partitions, while leaving others alone.  To me, this line looks as if it erases and recreates the entire drive, which is something that I'd like to avoid if possible.

Can anyone give me a decent explanation on what the $PARTITIONS varaible does?

Offline

#2 2011-04-22 19:23:54

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: AIF - Automatic install help

My guess would be it creates a 100 MB ext2 partition, makes it bootable and fills the rest of /dev/sda with ext4. Maybe you can point it to a specific partition, like /dev/sda1 instead of the whole drive.

Last edited by karol (2011-04-22 19:28:44)

Offline

#3 2011-04-22 19:33:57

litemotiv
Forum Fellow
Registered: 2008-08-01
Posts: 5,026

Re: AIF - Automatic install help

Moved to Installation.


ᶘ ᵒᴥᵒᶅ

Offline

#4 2011-04-22 19:44:54

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: AIF - Automatic install help

sfdisk manual doesn't give any direct answer to your question, but try the '-N' option:

       -N number
              Change only the single partition indicated. For example:
                  % sfdisk /dev/hdb -N5
                  ,,,*
                  %
              will make the fifth partition on /dev/hdb bootable (`active') and change nothing else. (Probably  this
              fifth  partition  is  called  /dev/hdb5,  but you are free to call it something else, like `/my_equip‐
              ment/disks/2/5' or so).

I have no idea if this can be achieved from AIF.

Offline

#5 2011-04-22 21:05:20

RetroX
Member
Registered: 2009-10-17
Posts: 106

Re: AIF - Automatic install help

litemotiv wrote:

Moved to Installation.

Sorry about that; I naturally posted the question in the newbie corner even though I shouldn't have.

I guess that I need to rephrase my question a bit.  I looked through the code and it seems a bit unclear what AIF does with this particular string.  I don't think that it directly relates to anything in sfdisk/cfdisk/whatever that AIF uses.

Offline

#6 2011-04-22 21:58:46

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: AIF - Automatic install help

Have you tried the example from tests/runtime/automatic-reuse-fs-sda/profile?

Offline

#7 2011-04-22 22:15:27

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: AIF - Automatic install help

RetroX wrote:

I looked through the code and it seems a bit unclear what AIF does with this particular string.  I don't think that it directly relates to anything in sfdisk/cfdisk/whatever that AIF uses.

https://github.com/Dieterbe/aif/blob/ma … systems.sh

# partitions a disk. heavily altered
# $1 device to partition
# $2 a string of the form: <partsize in MiB>:<fstype>[:+] (the + is bootable flag)
partition()
{
debug 'FS' "Partition called like: partition '$1' '$2'"
[ -z "$1" ] && die_error "partition() requires a device file and a partition string"
[ -z "$2" ] && die_error "partition() requires a partition string"

DEVICE=$1
STRING=$2

# validate DEVICE
if [ ! -b "$DEVICE" ]; then
notify "Device '$DEVICE' is not valid"
return 1
fi

target_umountall

# setup input var for sfdisk
# format: each line=1 part. <start> <size> <id> <bootable>[ <c,h,s> <c,h,s>]

read -r -a fsspecs <<< "$STRING" # split up like this otherwise '*' will be globbed. which usually means an entry containing * is lost

for fsspec in "${fsspecs[@]}"; do
fssize=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
fssize_spec=",$fssize"
[ "$fssize" = "*" ] && fssize_spec=';'

fstype=$(echo $fsspec | tr -d ' ' | cut -f2 -d:)
fstype_spec=","
[ "$fstype" = "swap" ] && fstype_spec=",S"

bootflag=$(echo $fsspec | tr -d ' ' | cut -f3 -d:)
bootflag_spec=""
[ "$bootflag" = "+" ] && bootflag_spec=",*"

sfdisk_input="${sfdisk_input}${fssize_spec}${fstype_spec}${bootflag_spec}\n"
done

sfdisk_input=$(printf "$sfdisk_input") # convert \n to newlines

# invoke sfdisk
debug 'FS' "Partition calls: sfdisk $DEVICE -uM >$LOG 2>&1 <<< $sfdisk_input"
printk off
sfdisk -D $DEVICE -uM >$LOG 2>&1 <<EOF
$sfdisk_input
EOF
    if [ $? -gt 0 ]; then
notify "Error partitioning $DEVICE (see $LOG for details)"
        printk on
        return 1
    fi
printk on

    return 0
}

Seems it chops that string

for fsspec in "${fsspecs[@]}"; do
fssize=$(echo $fsspec | tr -d ' ' | cut -f1 -d:)
fssize_spec=",$fssize"
[ "$fssize" = "*" ] && fssize_spec=';'

and passes it to sfdisk

sfdisk_input="${sfdisk_input}${fssize_spec}${fstype_spec}${bootflag_spec}\n"

Offline

#8 2011-04-23 16:07:16

RetroX
Member
Registered: 2009-10-17
Posts: 106

Re: AIF - Automatic install help

Ah, for some reason, I seemed to have skipped over that function. hmm
I thought that it was for the mount points and such, rather than the partitioning.

Thanks for the help.

Offline

Board footer

Powered by FluxBB