4. Installing: disks and file systems

This section of the document will go from the beginning of the installation to mounting file systems.

Main steps consist of partitioning disks, preparing RAID and LVM, creating file systems.

4.1. Start installation

Boot from Debian 3.0 "Woody" CD 1 and at lilo prompt use bf24, to boot with kernel 2.4.18.

Choose install language and configure the keyboard then open a shell (this option is near the end of the menu).

4.2. Load RAID and LVM support

Insert "LVM-and-RAID" floppy into floppy drive and use:

extdisk

to load RAID and LVM support.

The following (or similar) messages should be displayed; ignore any warning message regarding the kernel:


Trying the floppy drives, please wait...
Locating a new mount point...
Copying resource files...
Warning: loading /ext1/lib/modules/2.4.18-bf2.4/kernel/drivers/md/md.o will taint the kernel: forced load
Warning: loading /ext1/lib/modules/2.4.18-bf2.4/kernel/drivers/md/linear.o will taint the kernel: forced load
Warning: loading /ext1/lib/modules/2.4.18-bf2.4/kernel/drivers/md/xor.o will taint the kernel: forced load
Warning: loading /ext1/lib/modules/2.4.18-bf2.4/kernel/drivers/md/raid0.o will taint the kernel: forced load
Warning: loading /ext1/lib/modules/2.4.18-bf2.4/kernel/drivers/md/raid1.o will taint the kernel: forced load
Warning: loading /ext1/lib/modules/2.4.18-bf2.4/kernel/drivers/md/raid5.o will taint the kernel: forced load
Warning: loading /ext1/lib/modules/2.4.18-bf2.4/kernel/drivers/md/lvm-mod.o will taint the kernel: forced load
Done: LVM and RAID tools available now.

After the extension disk has been loaded the floppy can be removed from the drive.

NoteNote
 

Debian install process works by booting a kernel and mounting a ram disk; so extdisk loads RAID and LVM commands from floppy disk to the RAM disk. Please bear in mind that the same fate suffers any configuration file (as /etc/raidtab), so any file copied to /etc folder during install is lost when the machine is rebooted. This is true at least until target file systems are created and mounted. Only at this point configuration files can be copied to "real" /etc (ex. /target/etc) and packages installed in "real" file systems.

4.3. Partition hard disks

Partition hard disks: minimal configuration requires two RAID arrays, one for boot file system and one for LVM volume group.

The procedure has been written for two IDE disks on first IDE channel (/dev/hda, /dev/hdb): using fdisk create two partitions in each disk, the first one 20 or 25 MB large, the second one using all remaining space. The first partition will be used to hold boot volume, the second one will hold LVM volume group.

If the two disks are not equal in size, the second partition must fit on both disks, so it has to be large as the remaining space on the smallest disk. Ex. If the disks are 40000 MB and 30000 MB large, create 25 MB and 29975 MB partitions.

WarningWarning!
 

Partitioning hard disks can destroy all data. Check that the disks do not contain any valuable data before going on.

Use:

fdisk /dev/hda

to partition the first hard disk: delete any existing partition, create one primary partition 25 MB large (/dev/hda1), mark it with type FD (Linux raid autodetect) and bootable, then create another primary partition with required size and mark this too with type FD (Linux raid autodetect). Write configuration to disk and quit from fdisk.

Repeat the same step for second disk:

fdisk /dev/hdb

It is possible to use cfdisk to partition hard disks.

4.4. Create RAID arrays

NoteNote
 

The steps from current section to Create mount points and mount target file systems can be executed with a script, one can be found in section Preparing script and configuration files disk. It is suggested that the first installation is completed by hand, so that each step can be fully understanded.

If a script disk is to be used mount it with mount /dev/fd0 /floppy

Now it is necessary to create RAID arrays: two arrays will be created, /dev/md1 and /dev/md2.

First configuration file /etc/raidtab has to be created: edit it using nano-tiny or any other available editor or, more conveniently, prepare the file before on a floppy and then just copy it from there to /etc. To do so mount such a floppy with:

mount /dev/fd0 /floppy

then copy the file with:

cp /floppy/raidtab /etc/

Here is shown a valid /etc/raidtab for /dev/md1 and /dev/md2 built over /dev/hda and /dev/hdb:


raiddev	/dev/md1
	raid-level		1
	nr-raid-disks		2
	nr-spare-disks		0
	chunk-size		32
	persistent-superblock	1
		device		/dev/hda1
		raid-disk	0
		device		/dev/hdb1
		raid-disk	1

raiddev	/dev/md2
	raid-level		1
	nr-raid-disks		2
	nr-spare-disks		0
	chunk-size		32
	persistent-superblock	1
		device		/dev/hda2
		raid-disk	0
		device		/dev/hdb2
		raid-disk	1

This file can be downloaded here: http://www.midhgard.it/files/lvm/raidtab

Once created or copied /etc/raidtab, RAID arrays must be created. This is done using mkraid command.


mkraid /dev/md1
mkraid /dev/md2

The following output should result:


#mkraid /dev/md1
handling MD device /dev/md1
analyzing super-block
disk 0: /dev/hda1, 32098kB, raid superblock at 32000kB
disk 1: /dev/hdb1, 30712kB, raid superblock at 30592kB
#
#mkraid /dev/md2
handling MD device /dev/md2
analyzing super-block
disk 0: /dev/hda2, 44998065kB, raid superblock at 44997952kB
disk 1: /dev/hdb2, 45004176kB, raid superblock at 45004096kB

NoteNote
 

As soon as arrays are created, a rebuild thread is started to align disk status. This process can be lengthy and requires that all disk space is rewritten, so heavy disk activity will be generated. This is normal, so don't panic.

Verify that RAID arrays have been created successfully, by issuing the following command:

cat /proc/mdstat

This should print a status of all RAID arrays, similar to this:


Personalities : [linear] [raid0] [raid1] [raid5] 
read_ahead 1024 sectors
md2 : active raid1 hdb2[1] hda2[0]
      44997952 blocks [2/2] [UU]
      [>....................]  resync =  0.7% (320788/44997952) finish=37.1min speed=20049K/sec
md1 : active raid1 hdb1[1] hda1[0]
      30592 blocks [2/2] [UU]
      
unused devices: <none>

Each disk/partition that makes up an array should be in UP status (should have [UU] reported), and the big array will be under resync. While looking at mdstat repeatedly the resync percentage should rise.

4.5. Configurations with more than two disks

If more than two disks are present many other disk schemes are usable.

With three disks possible configurations are:

  1. Create RAID 1 arrays over two disks and use the third as hot spare

  2. Create a small RAID 1 array for boot (using two disks) and a big RAID 5 arrays over all three disks

In the first case create two partitions, one small and one big, on every disk, then configure mirroring between the first two disks; the third disk will not be used until one disk suffers a crash and the hot spare is activated.

In the second case it is best to partition all disks with the same scheme, one small partition and one big, then create a RAID 1 using the first partition of the first two disks, then create a RAID 5 array using the second partition of each disk:

NoteNote
 

The boot partition must be a RAID 1 array, lilo has currently no support for booting from a RAID 5 array.

With four disks possible configurations are:

  1. Create RAID 1 arrays over the first couple of disks as before, the create another RAID 1 volume using the second couple (one big partition over the third and fourth disk).

  2. As configuration #2 plus the fourth disk as hot spare.

  3. Create a small RAID 1 array from two disks then a RAID 5 array over all four disks.

And so on with more disks.

In Appendix A: /etc/raidtab examples there are examples of the file /etc/raidtab for the first two cases (RAID 1 + hot spare, RAID 1 + RAID 5).

4.6. LVM disk organization

For detailed informations on LVM consult LVM man pages and the official LVM howto (search for links in section General RAID and LVM info).

LVM maps disk partitions or raid arrays to physical disks (one to one), so the first step while configuring a LVM-enabled machine is to create physical volumes.

Then disks are organized into volume groups: a volume group is a group of physical volumes and of logical volumes that are related each other.

Each volume group can hold one or more logical volumes: think of a logical volume as a "dynamic" partition (Microsoft Windows 2000 Server calls this "Dynamic Volume").

For an example of situation where more than one volume group is advisable look at Appendix B: more than one volume group.

4.7. Start LVM

Before creating or accessing physical volumes and volume groups the LVM subsystem must be activated: this is done by using:

vgscan

This should produce the following output:


vgscan -- reading all physical volumes (this may take a while...)
vgscan -- "/etc/lvmtab" and "/etc/lvmtab.d" successfully created
vgscan -- WARNING: This program does not do a VGDA backup of your volume group

NoteNote
 

It is normal that the first time vgscan is invoked after each boot, /etc/lvmtab is created.

4.8. Create LVM physical volume(s)

Before creating volume groups physical volumes have to be created: this is done using pvcreate command. To create /dev/md2 physical disk issue:

pvcreate /dev/md2

The following output should be shown:

pvcreate -- physical volume "/dev/md2" successfully created

4.9. Create LVM volume group(s)

Now it is time to create required volume groups. In this case just one volume group can be created: there is only one physical volume available. Create the volume group writing:

vgcreate -A n vg00 /dev/md2

This creates the volume group vg00 and allocates physical disk dev/md2 to it. Following output should result:


vgcreate -- INFO: using default physical extent size 4.00 MB
vgcreate -- INFO: maximum logical volume size is 255.99 Gigabyte
vgcreate -- WARNING: you don't have an automatic backup of "vg00"
vgcreate -- volume group "vg00" successfully created and activated

NoteNote
 

The "-A n" option is used to prevent auto-backup of volume group configuration. This would be done into /etc/lvmtab.d

Remember that current /etc is into a RAM disk, so it would be useless to make a backup of the configuration and, much worst, after a few backup the RAM disk would be full. Should this ever happen it would be sufficient to delete all *.old files into /etc/lvmtab.d, but the "-A n" option prevents this.

NoteNote
 

If more that one physical volume is to be put into the volume group this can be done at volume group creation by putting all physical volume on pvcreate command line or later by using vgextend (look at related man pages).

NoteNote
 

Note: the name vg00 is arbitrary, but if changed (ex. vg0, vgroot) all subsequent commands related to this volume group or his logical volumes must be changed accordingly.

4.10. Choose file systems structure

Before proceeding with logical volumes creation a file systems structure has to be chosen: while it is possible to install over a single "big" root file system, this is not recommended, since this solution has several disadvantages:

To avoid all these problems use different file systems for the main folders held into root. Next is indicated a "decent" file systems structure with some possible values for file systems size:

/ (root)128 MB
/boot25 MB
/home128 MB or more (depends on data to be held)
/opt16 MB or more (depends on packages installed)
/tmp128 MB
/usr256 MB or more (depends on packages installed)
/var128 MB or more (depends on packages installed, logs created and data to be held)
swap128 MB or more (depends on RAM and usage)

Of course this is just an indication and everybody is free to adopt a custom solution.

4.11. Create LVM logical volumes

Now logical volumes have to be created. It is necessary to create one logical volume for each file system (except /boot that will be held in /dev/md1) plus one logical volume for swap space. Logical volumes are creating by using lvcreate.

Referring to file systems structure in Choose file systems structure here are commands for creating such logical volumes:


lvcreate -A n -L 128 -n root vg00
lvcreate -A n -L 128 -n home vg00
lvcreate -A n -L 16  -n opt  vg00
lvcreate -A n -L 128 -n tmp  vg00
lvcreate -A n -L 256 -n usr  vg00
lvcreate -A n -L 128 -n var  vg00
lvcreate -A n -L 128 -n swap vg00

For each lvcreate command an output similar to the following should be shown:


lvcreate -- WARNING: you don't have an automatic backup of "vg00"
lvcreate -- logical volume "/dev/vg00/root" successfully created

It is possible to verify logical volume correct creation by issuing:

vgdisplay -v vg00 | more

The following output should be displayed:


--- Volume group ---
VG Name               vg00
VG Access             read/write
VG Status             available/resizable
VG #                  0
MAX LV                255
Cur LV                7
Open LV               0
MAX LV Size           255.99 GB
Max PV                255
Cur PV                1
Act PV                1
VG Size               42.91 GB
PE Size               4.00 MB
Total PE              10984
Alloc PE / Size       228 / 912.00 MB
Free  PE / Size       10756 / 42.02 GB
VG UUID               W2R8ko-px88-WoJ1-9KV8-syTX-tBqh-My6YjD

--- Logical volume ---
LV Name                /dev/vg00/root
VG Name                vg00
LV Write Access        read/write
LV Status              available
LV #                   1
# open                 0
LV Size                128.00 MB
Current LE             32
Allocated LE           32
Allocation             next free
Read ahead sectors     120
Block device           58:0

...

Look also at /dev/vg00 directory with:

ls -l /dev/vg00

There should be one node for each logical volume, like this:


crw-r-----    1 root     disk     109,   0 Jan  1 22:42 group
brw-rw----    1 root     root      58,   1 Jan  1 22:58 home
brw-rw----    1 root     root      58,   2 Jan  1 22:58 opt
brw-rw----    1 root     root      58,   0 Jan  1 22:47 root
brw-rw----    1 root     root      58,   6 Jan  1 22:58 swap
brw-rw----    1 root     root      58,   3 Jan  1 22:58 tmp
brw-rw----    1 root     root      58,   4 Jan  1 22:58 usr
brw-rw----    1 root     root      58,   5 Jan  1 22:58 var

4.12. Create and initialize swap space

Next a swap partition has to be created and activated: for this step mkswap and swapon commands are used.

Create swap space:

mkswap /dev/vg00/swap

Output similar to this should result:

Setting up swapspace version 1, size = 134213632 bytes

Then activate swap space:

swapon /dev/vg00/swap

This command has no output.

Finally verify swap space status:

cat /proc/swaps

The file should be like this one:


Filename			Type		Size	Used	Priority
/dev/vg00/swap                  partition	131064	0	-1

4.13. Create file systems

At this point it is possible to create file systems. File systems can be of any type supported by the kernel that will be installed, common choices are ext2, ext3 or reiserfs. ext3 and reiserfs are journaled file systems, so are more secure than ext2, on the other hand they are slower and journal entries takes up some space. The commands here shown create ext3 file systems except for the boot file system that will be an ext2 file system.

To create file systems use these commands:


mke2fs /dev/md1
mke2fs -j /dev/vg00/root
mke2fs -j /dev/vg00/home
mke2fs -j /dev/vg00/opt
mke2fs -j /dev/vg00/tmp
mke2fs -j /dev/vg00/usr
mke2fs -j /dev/vg00/var

For each command an output similar to the following should be displayed:


mke2fs 1.27 (8-Mar-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
32768 inodes, 131072 blocks
6553 blocks (5.00%) reserved for the super user
First data block=1
16 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks: 
	8193, 24577, 40961, 57345, 73729

Writing inode tables: done                            
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

4.14. Create mount points and mount target file systems

The final step necessary before proceeding with "normal" installation is to create mount points and mount file systems into /target.

First root file system has to be mounted into /target:

mount /dev/vg00/root /target

Then mount points have to be created:


mkdir /target/boot
mkdir /target/home
mkdir /target/opt
mkdir /target/tmp
mkdir /target/usr
mkdir /target/var

Finally remaining file systems have to be mounted into corresponding mount points:


mount /dev/md1       /target/boot
mount /dev/vg00/home /target/home
mount /dev/vg00/opt  /target/opt
mount /dev/vg00/tmp  /target/tmp
mount /dev/vg00/usr  /target/usr
mount /dev/vg00/var  /target/var

Verify that all mounts are successful with:

mount

This should be the result:


/dev/ram0 on / type ext2 (rw)
/proc on /proc type proc (rw)
/dev/ram1 on /ext1 type ext2 (rw)
/dev/vg00/root on /target type ext3 (rw)
/dev/fd0 on /floppy type vfat (rw)
/dev/md1 on /target/boot type ext2 (rw)
/dev/vg00/home on /target/home type ext3 (rw)
/dev/vg00/opt on /target/opt type ext3 (rw)
/dev/vg00/tmp on /target/tmp type ext3 (rw)
/dev/vg00/usr on /target/usr type ext3 (rw)
/dev/vg00/var on /target/var type ext3 (rw)