Setup-storage: Difference between revisions

From FAIWiki
Jump to navigation Jump to search
(minor fix)
 
(58 intermediate revisions by 7 users not shown)
Line 1: Line 1:
= Introduction =
== Introduction ==
As setup_harddisks is not portable due to its dependency on sfdisk and the lack of support for RAID and LVM, it has been re-implemented from scratch. However, it is not yet integrated with FAI and deserves rigorous testing.  
As setup_harddisks is not portable due to its dependency on sfdisk and the lack of support for RAID and LVM, it has been re-implemented from scratch. As of FAI 3.2.8 it is integrated with mainline FAI, but not yet used by default.


To test my current implementation, keep reading. There are some TODOs left and
To test the current implementation, keep reading. There are some TODOs left and
probably a lot more will arise as soon as people actually start testing it. Before you
probably a lot more will arise as soon as people actually start testing it. Before you
start, just let me clarify that this is a very dangerous piece of software that
start, just let me clarify that this is a very dangerous piece of software that
Line 11: Line 11:
If you're still interested, the following steps are required next:
If you're still interested, the following steps are required next:


* install libparse-recdescent-perl, parted, lvm2 within your NFSROOT <b>and add lvm2 to FAIBASE or DEFAULT as well</b> (it must be available on the target system, if you define LVMs in your disk_config)
* get FAI 3.2.8 (or later)
 
* add USE_SETUP_STORAGE=1 to one of your scripts in class/
* grab setup_harddisks_2 from the SVN: [http://svn.debian.org/wsvn/fai/people/michael/features/setup_harddisks_2/implementation/] (get all the shdd2* files)
* you may want to take a look at the SETUPSTORAGE class used in the simple example in FAI 3.2.8 and/or see [http://fai-project.org/doc/man/setup-storage.html man 8 setup-storage]
 
* add lvm2 and mdadm to one of your client classes (it must be available on the target system, if you define LVMs/RAIDs in your disk_config)
* For a first shot copy the files somewhere into your NFSROOT
* create a disk_config for some class MY_TEST_CLASS from the old one apart from (at least) the following changes:
 
* create a disk_config for <CLASS> from the old one apart from (at least) the following changes:
** the filesystem is now given as the 4th column, the mount options are now in column 5
** the filesystem is now given as the 4th column, the mount options are now in column 5
** there is no ;-hack anymore -- anything given after the mount options is passed on to mkfs.<filesystem>
** there is no ;-hack anymore -- anything given after the mount options is passed on to mkfs.<filesystem>
** Partitions are marked as bootable using the bootable:<nr> option in the disk_config line
** Partitions are marked as bootable using the bootable:<nr> option in the disk_config line
** The other things should at least work like they did before, but there are some new things as well, like RAID support (which is surely incomplete), LVM support, mounting by label or UUID. Please take a look at the attached examples to get an idea of the new format.
** The other things should at least work like they did before, but there are some new things as well, like RAID support (which is surely incomplete), LVM support, mounting by label or UUID.  
All details of the implemented syntax and examples are given below.
** '''Please take a look at the [[Setup-storage#Some_examples|attached examples]] to get an idea of the new format.'''
 
** All details of the implemented syntax and examples are given below.
* create a hook partition.<CLASS>.source as follows (make sure you don't forget the .source)
* Give it a go (you have backed up all data, don't you?). There will be lots of debug output; if it finishes with the printout of an fstab file that is to your liking, it should have succeeded.
<pre>
#!/bin/sh
 
# load the device mapper module for LVM support
modprobe dm_mod
 
cd <somewhere>
debug=1 ./shdd2
# if you really brave, you can get things written to disk as well
debug=1 ./shdd2 -X
# now define variable for root and boot partition and boot device
# this is necessary because we skip the original task
. $LOGDIR/disk_var.sh
# skip the original parititioning
skiptask partition
 
</pre>
* Give it a go and hope... There will be lots of debug output; if it finishes with the printout of an fstab file that is to your liking, it should have succeeded.




Some further infos may also be found on [http://wiki.debian.org/DebianEdu/HowTo/FaiInstallDebianEdu].
Some further infos may also be found on [http://wiki.debian.org/DebianEdu/HowTo/FaiInstallDebianEdu wiki.debian.org].


= New configuration file syntax =
== New configuration file syntax ==


In the following, we present a complete EBNF description of a modified configuration file syntax, as well as some examples.
In the following, we present a complete EBNF description of a modified configuration file syntax, as well as some examples.
Line 61: Line 41:
comment ::= #.*  
comment ::= #.*  


config ::= disk_config lvm  
config ::= disk_config lvm( <lvmoption>)*
           | disk_config raid
           | disk_config raid( <raidoption>)*
           | disk_config end  
           | disk_config end  
           | disk_config disk[[:digit:]]+( <option>)*
           | disk_config disk[[:digit:]]+( <option>)*
Line 69: Line 49:
             * path is assumed to be /dev/hda */
             * path is assumed to be /dev/hda */
           | <volume>
           | <volume>
lvmoption ::= /* empty */
          | preserve_always:[^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*
          /* preserve partitions -- always */
          | preserve_reinstall:[^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*
          /* preserve partitions -- unless the system is installed for the
          first time */
          | resize:[^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*
          /* attempt to resize partitions */
          | fstabkey:(device|label|uuid)
          /* when creating the fstab, the key used for defining the device
          may be the device (/dev/xxx), a label given using -L, or the uuid
          */
raidoption ::= /* empty */
          | preserve_always:[[:digit:]]+(,[[:digit:]]+)*
          /* preserve partitions -- always */
          | preserve_reinstall:[[:digit:]]+(,[[:digit:]]+)*
          /* preserve partitions -- unless the system is installed for the
          first time */
          | fstabkey:(device|label|uuid)
          /* when creating the fstab, the key used for defining the device
          may be the device (/dev/xxx), a label given using -L, or the uuid
          */


option ::= /* empty */
option ::= /* empty */
Line 106: Line 110:
               | swap
               | swap
               /* swap space */
               /* swap space */
               | /[^[:space:]]*
               | /[^[:space:]]*(:encrypt)?
               /* fully qualified path */
               /* fully qualified path; if :encrypt is given, the partition
                * will be encrypted, the key is generated automatically */


name ::= [^/[:space:]]+
name ::= [^/[:space:]]+
Line 130: Line 135:
               /* mkfs.xxx must exist */
               /* mkfs.xxx must exist */


fs_options ::= .*
fs_options ::= (createopts=".*"|tuneopts=".*")*
               /* options appended to mkfs.xxx call */
               /* options to append to mkfs.xxx and to the filesystem-specific
                * tuning tool */
</pre>
</pre>


Line 137: Line 143:


* the disk_config ... line allows for the keywords lvm and raid
* the disk_config ... line allows for the keywords lvm and raid
* options may be appended to the disk_config line as well, but this may be subject to change
* options may need to be appended to the disk_config line
* the ";" is not used anymore, the options that were given there have now been split up
* the ";" is not used anymore, the options that were given there have now been split up
** the filesystem is now an explicit parameter; note, that the order of filesystem/mount-options is the same /etc/fstab, as opposed to the previous format of disk_config
** the filesystem is now an explicit parameter; note, that the order of filesystem/mount-options is the same /etc/fstab, as opposed to the previous format of disk_config
** any options to mkfs.xxx may be given
** any options to mkfs.xxx may be given using createopts=""
** the "boot"-option is one of the options now given on the disk_config line
** The "preserveX" and "boot" options are one of the options now given on the  
disk_config line, using preserve_reinstall or preserve_always and bootable.
preserve_always is equivalent to the previous preserveX option, whereas
preserve_reinstall preserves the partition unless "initial" is given as one of
the FAI_FLAGS.
* support for LVM and RAID is completely new :-)
* support for LVM and RAID is completely new :-)
* resizing partitions is supported
* resizing partitions is supported


= Some examples =
== Some examples ==
 
In fai 3.2.19 syntax has changed a little bit
use: <pre> createopts="-O dir_index,resize_inode" instead of -O dir_index,resize_inode </pre>
May be we can update the examples if the new syntax also works in debian stable I have not checked it. --Andreas 11:28, 25 April 2009 (CEST)


<pre>
<pre>
# Configure the device /dev/hda
# Configure the device /dev/hda
disk_config hda  preserve:6,7  disklabel:msdos  bootable:3
disk_config hda  preserve_always:6,7  disklabel:msdos  bootable:3
# preserve the 6th and the 7th partition. The disklabel is msdos, which is the default
# preserve the 6th and the 7th partition. The disklabel is msdos, which is the default
# for x86. Furthermore the 3rd partition is made bootable.  
# for x86. Furthermore the 3rd partition is made bootable.  
Line 158: Line 171:
primary swap      1000    swap      sw
primary swap      1000    swap      sw
# /dev/hda2 will be a swap space of 1000 MB
# /dev/hda2 will be a swap space of 1000 MB
primary /        12000      ext3          rw        -b 2048
primary /        12000      ext3          rw        createopts="-b 2048"
# /dev/hda3 should be formatted using ext3 filesystem; when calling mkfs.ext3
# /dev/hda3 should be formatted using ext3 filesystem; when calling mkfs.ext3
# the option "-b 2048" is appended.
# the option "-b 2048" is appended.
logical /tmp      1000      ext3            rw,nosuid
logical /tmp      1000      ext3            rw,nosuid
# create the logical partition /dev/hda5
# create the logical partition /dev/hda5
logical /usr      preserve6     ext3          rw
logical /usr      10000     ext3          rw
logical /var      10%-      ext3              rw
logical /var      10%-      ext3              rw
# make /dev/hda7 at least 10% of the disk size
# make /dev/hda7 at least 10% of the disk size
Line 204: Line 217:




</pre>
<pre>
# Simple LVM example
disk_config sda  bootable:1
primary /boot 500 ext3 rw
primary -      4096-  -      -
disk_config lvm
vg my_pv        sda2
my_pv-_swap    swap    2048    swap    sw
my_pv-_root    /      2048    ext3 rw
</pre>
</pre>


Line 245: Line 270:
my_pv-_usr /usr 2048        ext3  rw -O dir_index,resize_inode
my_pv-_usr /usr 2048        ext3  rw -O dir_index,resize_inode
my_pv-_var /var 600        ext3  rw -O dir_index,resize_inode
my_pv-_var /var 600        ext3  rw -O dir_index,resize_inode
my_pv-_e_h /export/home 10240      reiser         rw,notail
my_pv-_e_h /export/home 10240      reiserfs         rw,notail
my_pv-_e_s /export/sites 2048        reiser         rw,notail
my_pv-_e_s /export/sites 2048        reiserfs         rw,notail
my_pv-_v /vservers 2048        ext3    rw  
my_pv-_v /vservers 2048        ext3    rw  
</pre>
</pre>


= Implementation =
== Implementation ==
The current implementation is found at [http://svn.debian.org/wsvn/fai/people/michael/features/setup_harddisks_2/implementation/] and has still some TODOs left:
The current implementation still some TODOs left:
 
=== Missing features and regressions ===


* Missing features
* Missing features
** some auto mode (something like auto:server, auto:desktop?) might be desirable
** lazyformat -- will probably not be implemented as preserve_reinstall is much more stable.
** no man page
** some auto mode (something like auto:server, auto:desktop?) might be desirable
** crypto support would be nice to have; we could implement it by an additional (optional) argument to the mount point specification. A nice tutorial on crypt setups is found at [http://www.saout.de/tikiwiki/tiki-index.php?page=EncryptedDeviceUsingLUKS]
** once everything is done, some checks should be performed, e.g., test that all partitions were created
** does preserve work the way lazyformat used to work?
** Having /boot on a SW-RAID or LVM should be tested, I think it doesn't work - yes, it does indeed fail because $BOOT_* don't get set. No idea what the proper setting is -- use class GRUB_PC as shown in the simple example in experimental
** there needs to be a proper order of events. you need to tear down lvm, then raid and finally partitions and build them up the other way around. Right now things are just sorted in the disk, raid, lvm order and both teardown and buildup take place right after each other within each section. 
** implement disklabels other than msdos and gpt
 
* Implementation details
* Implementation details
** resize should imply resizing the filesystem as well (unless this is done by parted already, needs to be checked)
** preserve/resize deserve thorough testing, especially in case of LVM/RAID
** LVMs definitely require resizing the filesystem
** The code of create_volume_group for the case of an existing vg should handle existing information and not rely on lvm commands to silently ignore existing volumes
** how to detect old-style config files? migration strategies?
** mdadm --misc --zero-superblock /dev/hdx may be necessary
** implement disklabels other than msdos and gpt
** preserve must retain the flags (bootable, etc.)
** the RAID commands are surely incomplete and lack any management of unanticipated situations
** the RAID commands are surely incomplete and lack any management of unanticipated situations
** try to get libparted-swig-perl and use that one instead of the manual parsing
** evaluate the return code of external commands in exec.pm -- currently only a warning is given
** (done) setup_harddisks_2 writes the UUIDs or labels to fstab, but grub's menu.lst must be adapted as well
** more error messages must be caught by exec.pm
** volume groups may need to be cleaned, which could require some magic, see partman [http://svn.debian.org/wsvn/d-i/trunk/packages/partman/partman-auto/auto-shared.sh?op=file&rev=0&sc=0], dm_wipe_lvm
** more error messages must be caught by shdd2-exec, e.g.,
<pre>
(CMD) parted -s /dev/sdc unit TiB print 1> /tmp/xkxZndMHZ7 2> /tmp/qaYSzz9BLr
(STDERR) No Implementation: Partition 1 isn't aligned to cylinder boundaries.  This is still unsupported.
</pre>
** create a proper perl namespace
** chop the long functions into many smaller ones
** (done) try to use modules like LINUX::Lvm for lvm handling. Unfortunatly there seems to be no raid or partitioning module. liblinux-lvm-perl is currently in [http://ftp-master.debian.org/new.html NEW]


* Ideas that came up on IRC
=== Documentation of internal data structures ===
** it should be possible to preserve logical volumes, etc. using preserve instead of giving a size
** (done) volume groups and RAID configs should refer to disk1.2 etc.
** once everything is done, some checks should be performed, e.g., test that all paritions were created
** (done) test and use udevsettle instead of sleep commands
** Disks must be selectable by their ID or the like [http://www.mail-archive.com/linux-fai-devel@uni-koeln.de/msg00023.html]
 
== Changes required for integration with main-line FAI ==
* libparse-recdescent-perl and liblinux-lvm-perl must get installed in nfsroot (add Depends:
  to fai-nfsroot package)
* closes #380629, #330915, #277045, #356862, #416633
* no-bug: #364763
 
== Missing features and regressions ==
 
* crypto
* md
* (done) lazypreserve (preserve if there is a partition, otherwise create it) -- we now offer preserve_always and preserve_reinstall
* preserve for lvm partitions/vg
* no lazyformat
 
== Documentation of internal data structures ==


The hash of all configurations specified in the disk_config file
The hash of all configurations specified in the disk_config file
Line 390: Line 388:
</pre>
</pre>


= Other implementations for RAID and LVM =  
== Other implementations for RAID and LVM ==


Meanwhile you might also want to look at
Meanwhile you might also want to look at
Line 396: Line 394:
* [[User:Svamberg/Software RAID|Software RAID hook]] with mdadm
* [[User:Svamberg/Software RAID|Software RAID hook]] with mdadm
* [[User:Gervai/Raid and LVM hook|SWRaid and LVM hook]] (with mdadm)
* [[User:Gervai/Raid and LVM hook|SWRaid and LVM hook]] (with mdadm)
* [http://www.informatik.uni-koeln.de/fai/download/developers/setup_harddisks patched version of setup_harddisks]: Code refactoring, LVM/RAID support and POD manual page: Copyright (c) 2003, Sam Vilain ''(not updated with recent changes in FAI)''
* [http://www.linuxma.com/fai_raid/ LVM & RAID]
* [http://www.linuxma.com/fai_raid/ LVM & RAID]
== See also ==
* [http://fai-project.org/doc/man/setup-storage.html setup-storage manpage]
[[Category:User Manual]]

Latest revision as of 16:26, 21 July 2011

Introduction

As setup_harddisks is not portable due to its dependency on sfdisk and the lack of support for RAID and LVM, it has been re-implemented from scratch. As of FAI 3.2.8 it is integrated with mainline FAI, but not yet used by default.

To test the current implementation, keep reading. There are some TODOs left and probably a lot more will arise as soon as people actually start testing it. Before you start, just let me clarify that this is a very dangerous piece of software that has not been sufficiently tested for any cases where you want to retain any of your data. It will definitely destroy any data on any of your disks in your system. You have been warned.

If you're still interested, the following steps are required next:

  • get FAI 3.2.8 (or later)
  • add USE_SETUP_STORAGE=1 to one of your scripts in class/
  • you may want to take a look at the SETUPSTORAGE class used in the simple example in FAI 3.2.8 and/or see man 8 setup-storage
  • add lvm2 and mdadm to one of your client classes (it must be available on the target system, if you define LVMs/RAIDs in your disk_config)
  • create a disk_config for some class MY_TEST_CLASS from the old one apart from (at least) the following changes:
    • the filesystem is now given as the 4th column, the mount options are now in column 5
    • there is no ;-hack anymore -- anything given after the mount options is passed on to mkfs.<filesystem>
    • Partitions are marked as bootable using the bootable:<nr> option in the disk_config line
    • The other things should at least work like they did before, but there are some new things as well, like RAID support (which is surely incomplete), LVM support, mounting by label or UUID.
    • Please take a look at the attached examples to get an idea of the new format.
    • All details of the implemented syntax and examples are given below.
  • Give it a go (you have backed up all data, don't you?). There will be lots of debug output; if it finishes with the printout of an fstab file that is to your liking, it should have succeeded.


Some further infos may also be found on wiki.debian.org.

New configuration file syntax

In the following, we present a complete EBNF description of a modified configuration file syntax, as well as some examples.

file ::= <lines> EOF 

lines ::= EOL 
          /* empty lines or whitespace only */
          | <comment> EOL 
          | <config> EOL 

comment ::= #.* 

config ::= disk_config lvm( <lvmoption>)* 
           | disk_config raid( <raidoption>)*
           | disk_config end 
           | disk_config disk[[:digit:]]+( <option>)*
           | disk_config [^[:space:]]+( <option>)*
           /* fully qualified device-path or short form, like hda, whereby full
            * path is assumed to be /dev/hda */
           | <volume>

lvmoption ::= /* empty */
           | preserve_always:[^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*
           /* preserve partitions -- always */
           | preserve_reinstall:[^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*
           /* preserve partitions -- unless the system is installed for the 
           first time */
           | resize:[^/,\s\-]+-[^/,\s\-]+(,[^/,\s\-]+-[^/,\s\-]+)*
           /* attempt to resize partitions */
           | fstabkey:(device|label|uuid)
           /* when creating the fstab, the key used for defining the device
           may be the device (/dev/xxx), a label given using -L, or the uuid
           */

raidoption ::= /* empty */
           | preserve_always:[[:digit:]]+(,[[:digit:]]+)*
           /* preserve partitions -- always */
           | preserve_reinstall:[[:digit:]]+(,[[:digit:]]+)*
           /* preserve partitions -- unless the system is installed for the 
           first time */
           | fstabkey:(device|label|uuid)
           /* when creating the fstab, the key used for defining the device
           may be the device (/dev/xxx), a label given using -L, or the uuid
           */

option ::= /* empty */
           | preserve_always:[[:digit:]]+(,[[:digit:]]+)*
           /* preserve partitions -- always */
           | preserve_reinstall:[[:digit:]]+(,[[:digit:]]+)*
           /* preserve partitions -- unless the system is installed for the 
           first time */
           | resize:[[:digit:]]+(,[[:digit:]]+)*
           /* attempt to resize partitions */
           | disklabel:(msdos|gpt)
           /* write a disklabel - default is msdos */
           | bootable:[[:digit:]]+
           /* mark a partition bootable, default is / */
           | virtual
           /* do not assume the disk to be a physical device, use with xen */
           | fstabkey:(device|label|uuid)
           /* when creating the fstab, the key used for defining the device
           may be the device (/dev/xxx), a label given using -L, or the uuid
           */  

volume ::= <type> <mountpoint> <size> <filesystem> <mount_options> <fs_options>
           | vg <name> <size>
           /* lvm vg */

type ::= primary
         /* for physical disks only */
         | logical
         /* for physical disks only */
         | raid[0156]
         /* raid level */
         | [^/[:space:]]+-[^/[:space:]]+
         /* lvm logical volume: vg name and lv name*/

mountpoint ::= -
               /* do not mount */
               | swap
               /* swap space */
               | /[^[:space:]]*(:encrypt)?
               /* fully qualified path; if :encrypt is given, the partition
                * will be encrypted, the key is generated automatically */

name ::= [^/[:space:]]+
         /* lvm volume group name */

size ::= [[:digit:]]+[kMGTP%]?(-([[:digit:]]+[kMGTP%]?)?)?(:resize)?
         /* size in kilo, mega (default), giga, tera or petabytes or %,
          * possibly given as a range; physical
          * partitions or lvm logical volumes only; */
         | -[[:digit:]]+[kMGTP%]?(:resize)?
         /* size in kilo, mega (default), giga, tera or petabytes or %,
          * given as upper limit; physical partitions
          * or lvm logical volumes only */
         | [^,:[:space:]]+(:(spare|missing))*(,[^,:[:space:]]+(:(spare|missing))*)*
         /* devices and options for a raid or lvm vg */

mount_options ::= [^[:space:]]+

filesystem ::= -
               | swap
               | [^[:space:]]
               /* mkfs.xxx must exist */

fs_options ::= (createopts=".*"|tuneopts=".*")*
               /* options to append to mkfs.xxx and to the filesystem-specific
                * tuning tool */

The major differences to the prior format:

  • the disk_config ... line allows for the keywords lvm and raid
  • options may need to be appended to the disk_config line
  • the ";" is not used anymore, the options that were given there have now been split up
    • the filesystem is now an explicit parameter; note, that the order of filesystem/mount-options is the same /etc/fstab, as opposed to the previous format of disk_config
    • any options to mkfs.xxx may be given using createopts=""
    • The "preserveX" and "boot" options are one of the options now given on the

disk_config line, using preserve_reinstall or preserve_always and bootable. preserve_always is equivalent to the previous preserveX option, whereas preserve_reinstall preserves the partition unless "initial" is given as one of the FAI_FLAGS.

  • support for LVM and RAID is completely new :-)
  • resizing partitions is supported

Some examples

In fai 3.2.19 syntax has changed a little bit

use:

 createopts="-O dir_index,resize_inode" instead of -O dir_index,resize_inode 

May be we can update the examples if the new syntax also works in debian stable I have not checked it. --Andreas 11:28, 25 April 2009 (CEST)

# Configure the device /dev/hda
disk_config hda   preserve_always:6,7   disklabel:msdos  bootable:3
# preserve the 6th and the 7th partition. The disklabel is msdos, which is the default
# for x86. Furthermore the 3rd partition is made bootable. 
primary /boot     20-100        ext3            rw
# create a primary partition /dev/hda1 with a size between 20 and 100 MB and mount it
# read-write as /boot; it is formatted using ext3 filesystem
primary swap      1000     swap       sw
# /dev/hda2 will be a swap space of 1000 MB
primary /         12000      ext3           rw        createopts="-b 2048"
# /dev/hda3 should be formatted using ext3 filesystem; when calling mkfs.ext3
# the option "-b 2048" is appended.
logical /tmp      1000      ext3            rw,nosuid
# create the logical partition /dev/hda5
logical /usr      10000      ext3          rw
logical /var      10%-      ext3               rw
# make /dev/hda7 at least 10% of the disk size
logical /nobackup 0-        xfs                rw
# use mkfs.xfs to format the partition


# Configure the virtual device /dev/sda (for, e.g., Xen setups), all
# partitions are primary and sizes are ignored (so one could as well specify
# anything other than 0)
disk_config sda virtual
primary /boot     0            ext3                 rw
primary /         0            ext3                 rw
primary /tmp      0            ext3                 rw
primary /usr      0            ext3                 rw
primary /var      0            ext3                 rw

# resizing partitions is possible by appending :resize to any given size
disk_config /dev/scsi/host0/bus0/target1/lun0 
primary /      3000-6000:resize         ext3         rw
# resize to any value between 3000 and 6000 MB, as limited by the disk size,
# the desired sizes of the other partitions, and the data on the partition
primary /tmp   1000                     ext3         rw


# Create a softRAID
disk_config raid
raid1        /    sda1,sdd1  ext2        rw,errors=remount-ro
# create a RAID-1 on /dev/sda1 and /dev/sdd1, format using mkfs.ext2 and mount
# it as /
raid0        -    disk2.2,sdc1,sde1:spare:missing  ext2       default
# create a RAID-0 on the second partition of the second disk, /dev/sdc1, and
# /dev/sde1 as a spare partition, which (may?) me missing


# Simple LVM example
disk_config sda  bootable:1
primary /boot 500 ext3 rw
primary -       4096-   -       -

disk_config lvm
vg my_pv        sda2
my_pv-_swap     swap    2048    swap    sw
my_pv-_root     /       2048    ext3 rw

A pretty complex setup looks as follows:

disk_config sda

primary  -    256         -    -  
primary  swap 1024        swap       sw
primary  -		0-				 -    -

disk_config sdb
primary  -		0-				 - -

disk_config sdc
primary  -		0-				 - -

disk_config sdd
primary  -             	256         - -
primary  -          	1024        -                   -
primary  -		0-				 - -

disk_config sde
primary  -		0-				 - -

disk_config sdf
primary  -		0-				 - -

disk_config raid

raid1        /    sda1,sdd1  ext2    rw,errors=remount-ro   
raid1        swap sda2,sdd2  swap    rw                     
raid1        -    sda3,sdd3  ext2    default                

raid0        -    sdb1,sde1  ext2    default
raid0        -    sdc1,sdf1  ext2    default

# config the LVM
disk_config lvm
vg  my_pv   md2,md3   
my_pv-_usr	/usr			2048        ext3  rw -O dir_index,resize_inode
my_pv-_var	/var			600         ext3  rw -O dir_index,resize_inode
my_pv-_e_h	/export/home		10240       reiserfs          rw,notail
my_pv-_e_s	/export/sites		2048        reiserfs          rw,notail
my_pv-_v	/vservers		2048        ext3    rw 

Implementation

The current implementation still some TODOs left:

Missing features and regressions

  • Missing features
    • lazyformat -- will probably not be implemented as preserve_reinstall is much more stable.
    • some auto mode (something like auto:server, auto:desktop?) might be desirable
    • once everything is done, some checks should be performed, e.g., test that all partitions were created
    • Having /boot on a SW-RAID or LVM should be tested, I think it doesn't work - yes, it does indeed fail because $BOOT_* don't get set. No idea what the proper setting is -- use class GRUB_PC as shown in the simple example in experimental
    • implement disklabels other than msdos and gpt
  • Implementation details
    • preserve/resize deserve thorough testing, especially in case of LVM/RAID
    • The code of create_volume_group for the case of an existing vg should handle existing information and not rely on lvm commands to silently ignore existing volumes
    • mdadm --misc --zero-superblock /dev/hdx may be necessary
    • preserve must retain the flags (bootable, etc.)
    • the RAID commands are surely incomplete and lack any management of unanticipated situations
    • evaluate the return code of external commands in exec.pm -- currently only a warning is given
    • more error messages must be caught by exec.pm

Documentation of internal data structures

The hash of all configurations specified in the disk_config file

PHY_<DEVICE>
  virtual (0|1)
  disklabel STRING
  bootable -1..n
  partitions
    <1..n>
      size
        extended (0|1)
        preserve (0|1)
        resize (0|1)
        range
        eff_size
      number 1..n
      maps_to_existing 1..n
      start_byte
      end_byte
      mountpoint
      mount_options
      filesystem
      fs_options
      label
VG_<NAME>
  devices
  estimated_size
  volumes
    <logical-volume-name>
      size
        preserve (0|1)
        resize (0|1)
        range
        eff_size
      mountpoint
      mount_options
      filesystem
      fs_options
      label
RAID
  volumes
    <0..n>
      mode
      devices
        /dev/<device-name>
          options
            spare (0|1)
            missing (0|1)
      mountpoint
      mount_options
      filesystem
      fs_options
      label

The current disk configuration

<DEVICE>
  bios_cylinders
  bios_heads
  bios_sectors_per_track
  sector_size
  disklabel
  begin_byte
  end_byte
  partitions
    <1..n>
      begin_byte
      end_byte
      count_byte
      is_extended
      filesystem

The current LVM configuration

<VG>
  physical_volumes
  size
  volumes
    <lv-name>
      size

The current RAID configuration

<0..n>
  devices
  mode

Other implementations for RAID and LVM

Meanwhile you might also want to look at

See also