mirror of
https://github.com/xcat2/xcat-core.git
synced 2025-06-13 09:50:19 +00:00
localdisk to support user customize the partition table type
some old code issues found during UT for this feature
This commit is contained in:
@ -22,18 +22,19 @@ An example ``localdisk`` configuration file: ::
|
||||
enable=yes
|
||||
enablepart=no
|
||||
|
||||
[disk]
|
||||
dev=/dev/sdb
|
||||
clear=yes
|
||||
parts=100M-200M,1G-2G
|
||||
|
||||
[disk]
|
||||
dev=/dev/sda
|
||||
clear=yes
|
||||
parts=10,20,30
|
||||
|
||||
[disk]
|
||||
dev=/dev/sdb
|
||||
clear=yes
|
||||
parts=100M-200M,1G-2G
|
||||
|
||||
[disk]
|
||||
dev=/dev/sdc
|
||||
ptype=gpt
|
||||
clear=yes
|
||||
parts=10,20,30
|
||||
|
||||
@ -53,6 +54,7 @@ The ``[disk]`` section is used to configure how to partition a hard disk:
|
||||
|
||||
* dev: The path of the device file.
|
||||
* clear: If set to ``yes`` it will clear all the existing partitions on this disk.
|
||||
* ptype: The partition table type of the disk. For example, ``msdos`` or ``gpt``, and ``msdos`` is the default.
|
||||
* fstype: The file system type for the new created partitions. ``ext3`` is the default.
|
||||
* parts: A comma separated list of space ranges, one for each partition that will be created on the device. The valid format for each space range is ``<startpoint>-<endpoint>`` or ``<percentage of the disk>``. For example, you could set it to ``100M-10G`` or ``50``. If set to ``50``, 50% of the disk space will be assigned to that partition.
|
||||
|
||||
|
@ -54,7 +54,7 @@ sub process_request
|
||||
|
||||
if ($client) { ($client) = noderange($client) }
|
||||
unless ($client) { #Not able to do identify the host in question
|
||||
xCAT::MsgUtils->message("S", "Received syncfiles from $client, which couldn't be correlated to a node (domain mismatch?)");
|
||||
xCAT::MsgUtils->message("S", "Received getpartition from $client, which couldn't be correlated to a node (domain mismatch?)");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -75,9 +75,9 @@ xCATCmd () {
|
||||
}
|
||||
|
||||
doconfigure () {
|
||||
echo "DEBUG: enable=[$enable]; enablepart=[$enablepart]; disk=[$disk]; localspace=[$localspace]; swapspace=[$swapspace]; dev=[$dev]; parts=[$parts]; clear=[$clear];" >>$LOG
|
||||
# run the configure script
|
||||
if [ $isscript -eq 1 ]; then
|
||||
echo "DEBUG: localdisk is run in script mode ..." >>$LOG
|
||||
# run the script
|
||||
chmod +x $SCRIPTFILE
|
||||
$SCRIPTFILE
|
||||
@ -85,8 +85,10 @@ doconfigure () {
|
||||
fi
|
||||
|
||||
if [ x"$enable" != x"yes" ]; then
|
||||
echo "WARN: localdisk is not enabled, enable=[$enable]" >>$LOG
|
||||
exit 1
|
||||
fi
|
||||
echo "DEBUG: enablepart=[$enablepart]; disk=[$disk]; localspace=[$localspace]; swapspace=[$swapspace]; dev=[$dev]; parts=[$parts]; clear=[$clear]; ptype=[$ptype]" >>$LOG
|
||||
if [ $disk -eq 1 ]; then
|
||||
if [ x"$enablepart" != x"yes" ]; then
|
||||
return
|
||||
@ -105,7 +107,7 @@ doconfigure () {
|
||||
# To recreate the disk label when clear=yes, this action is used to resolve the issue
|
||||
# that the disk has been formatted by AIX
|
||||
if [ x$clear != x ]; then
|
||||
`parted -s $dev mklabel msdos`
|
||||
`parted -s $dev mklabel $ptype`
|
||||
fi
|
||||
|
||||
# remove all the partitions on the device
|
||||
@ -125,8 +127,8 @@ doconfigure () {
|
||||
|
||||
if [ x$devname = x"$dev" ]; then
|
||||
#create the label
|
||||
`parted -s $dev mklabel msdos`
|
||||
echo "parted -s $dev mklabel msdos" >>$LOG
|
||||
`parted -s $dev mklabel $ptype`
|
||||
echo "parted -s $dev mklabel $ptype" >>$LOG
|
||||
fi
|
||||
fi
|
||||
done < $PARTLOG
|
||||
@ -261,15 +263,15 @@ do
|
||||
firstline=$LINE
|
||||
# the format of first line should be: type=script|format
|
||||
key=`echo \$firstline |awk -F= '{print \$1}'`
|
||||
if [ x$key != x"type" ]; then
|
||||
echo "Error: Cannot recognize the format of the parition configuration file." >>$LOG
|
||||
if [ x"$key" != x"type" ]; then
|
||||
echo "Error: Cannot recognize the format of the partition configuration file." >>$LOG
|
||||
echo "Error to configure localdisk"
|
||||
exit 1
|
||||
fi
|
||||
value=`echo \$firstline |awk -F= '{print \$2}'`
|
||||
if [ x$value = x"script" ]; then
|
||||
if [ x"$value" = x"script" ]; then
|
||||
isscript=1
|
||||
elif [ x$value = x"format" ]; then
|
||||
elif [ x"$value" = x"format" ]; then
|
||||
isformat=1
|
||||
fi
|
||||
continue
|
||||
@ -288,6 +290,7 @@ do
|
||||
dev=""
|
||||
clear=""
|
||||
parts=""
|
||||
ptype="msdos"
|
||||
elif [ x$LINE = x"[localspace]" ]; then
|
||||
doconfigure
|
||||
disk=0
|
||||
@ -308,6 +311,8 @@ do
|
||||
dev=$value
|
||||
elif [ x$key = x"clear" ]; then
|
||||
clear=$value
|
||||
elif [ x$key = x"ptype" ]; then
|
||||
ptype=$value
|
||||
elif [ x$key = x"parts" ]; then
|
||||
parts=$value
|
||||
elif [ x$key = x"fstype" ]; then
|
||||
|
Reference in New Issue
Block a user