Hard Disk Partitioning

From SME Server
Revision as of 19:16, 10 February 2013 by Allsorts (talk | contribs) (Removed under score in new link)
Jump to navigationJump to search
PythonIcon.png Skill level: Advanced
The instructions on this page may require deviations from standard procedures. A good understanding of linux and Koozali SME Server is recommended.


Warning.png Warning:
Get it right or you will lose data. Take a backup! Keep in mind if you make a mistake you can loose a whole hard disk. A common error is to switch /dev/sda with /dev/sdb.


SME Servers Raid Options are largely automated, if you built your system with a single hard disk simply logon as admin and select Disk Redundancy to add a new drive to your RAID1 array. The same procedure is used if you have a disk failure in a RAID array and you have replaced that failed disk.

But with the best laid plans things don't always go according to plan, these are the processes required to do it manually.

See also: Raid:Manual Rebuild

Is the Disk Partitioned Correctly ?

Here two disks are partitioned identically

[root@ ~]# fdisk -lu /dev/sda; fdisk -lu /dev/sdb

Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      208844      104391   fd  Linux raid autodetect
/dev/sda2          208845  1953520064   976655610   fd  Linux raid autodetect

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *          63      208844      104391   fd  Linux raid autodetect
/dev/sdb2          208845  1953520064   976655610   fd  Linux raid autodetect

Example : Incorrecty Partitioned 2nd Disk

In this example the partitions are set too close to the start of the disk and there is no room for GRUB to be written, the disk will not boot, there will not be enough room for grub staging

[root@ ~]# fdisk -lu /dev/sdb; fdisk -lu /dev/sdb

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      104384+  fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sdb2              13      121601   976655647   fd  Linux raid autodetect

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1      208769      104384+  fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sdb2          208770  1953520063   976655647   fd  Linux raid autodetect
message Log showing Grub errors during the processus of installation

If we try to install grub you will see these errors messages

add_drive_to_raid: Waiting for boot partition to sync before installing grub...
add_drive_to_raid: Probing devices to guess BIOS drives. This may take a long time.
add_drive_to_raid:
add_drive_to_raid:
add_drive_to_raid:     GNU GRUB  version 0.95  (640K lower / 3072K upper memory)
add_drive_to_raid:
add_drive_to_raid:  [ Minimal BASH-like line editing is supported.  For the first word, TAB
add_drive_to_raid:    lists possible command completions.  Anywhere else TAB lists the possible
add_drive_to_raid:    completions of a device/filename.]
add_drive_to_raid: grub> device (hd0) /dev/sdb
add_drive_to_raid: grub> root (hd0,0)
add_drive_to_raid:  Filesystem type is ext2fs, partition type 0xfd
add_drive_to_raid: grub> setup (hd0)
add_drive_to_raid:  Checking if "/boot/grub/stage1" exists... no
add_drive_to_raid:  Checking if "/grub/stage1" exists... yes
add_drive_to_raid:  Checking if "/grub/stage2" exists... yes
add_drive_to_raid:  Checking if "/grub/e2fs_stage1_5" exists... yes
add_drive_to_raid:  Running "embed /grub/e2fs_stage1_5 (hd0)"... failed (this is not fatal)
add_drive_to_raid:  Running "embed /grub/e2fs_stage1_5 (hd0,0)"... failed (this is not fatal)
add_drive_to_raid:  Running "install /grub/stage1 (hd0) /grub/stage2 p /grub/grub.conf "... succeeded
add_drive_to_raid: Done.
add_drive_to_raid: grub> quit

HowTo: Partition / Re-Partition a disk

Important.png Note:
if you are using the disk for the first time you can go straight to the next section otherwise you need to erase the old partitions before you create a new one. We will presume you have two existing partitions as is the default partitioning on a SME Server raid1.


Delete Existing Partitions

[root@ ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 121601.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      104384+  fd  Linux raid autodetect
Partition 1 does not end on cylinder boundary.
/dev/sdb2              13      121601   976655647   fd  Linux raid autodetect

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Selected partition 2

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Create new partitions

Important.png Note:
Now we will create two partitions for md1 and md2, as it is the default partitioning schema of SME. You can make another choice to create just one partition if you want a data disk in a raid array. At this point you will allocate the whole disk to partition 1. In this case there is no need to give a boot flag (see below the flag "a")



Warning.png Warning:
Note: change the partitions system id to reflect Linux raid autodetect


[root@ ~]# fdisk /dev/sdb

The number of cylinders for this disk is set to 121601.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-121601, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-121601, default 121601): 13

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (14-121601, default 14):
Using default value 14
Last cylinder or +size or +sizeM or +sizeK (14-121601, default 121601):
Using default value 121601

Command (m for help): a
Partition number (1-4): 1

Command (m for help): t
Partition number (1-4): 1
Hex code (type L to list codes): fd
Changed system type of partition 1 to fd (Linux raid autodetect)

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): fd
Changed system type of partition 2 to fd (Linux raid autodetect)

Command (m for help): p

Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1          13      104391   fd  Linux raid autodetect
/dev/sdb2              14      121601   976655610   fd  Linux raid autodetect
 
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

HowTo: Write the GRUB boot sector

Important.png Note:
The new disk requires grub to ensure the boot sequence


[root@ ~]# dd if=/dev/sda1 of=/dev/sdb1

[root@ ~]# grub

    GNU GRUB  version 0.95  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename.]

grub> device (hd1) /dev/sdb

grub> root (hd1,0)
 Filesystem type is ext2fs, partition type 0xfd

grub> setup (hd1)
 Checking if "/boot/grub/stage1" exists... no
 Checking if "/grub/stage1" exists... yes
 Checking if "/grub/stage2" exists... yes
 Checking if "/grub/e2fs_stage1_5" exists... yes
 Running "embed /grub/e2fs_stage1_5 (hd1)"...  16 sectors are embedded.
succeeded
 Running "install /grub/stage1 (hd1) (hd1)1+16 p (hd1,0)/grub/stage2 /grub/grub.conf"... succeeded
Done.

grub> quit