Alter boot volume 

Goal change boot device from /dev/hda3 to /dev/hda2

cmd:sfdisk 

Usage 

To set /dev/hd?2 as boot devive:

sfdisk -A2 /dev/$HD

Comments 

Using sfdisk to change boot devive is recommended, it does not require two steps to achieve so:

HD=hda
% sfdisk -l /dev/$HD
Disk /dev/hda: 7476 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/hda1          0+     63      64-    514048+  82  Linux swap
/dev/hda2         64     320     257    2064352+   b  Win95 FAT32
/dev/hda3   *    321     705     385    3092512+  83  Linux
/dev/hda4        706    7475    6770   54380025    f  Win95 Ext'd (LBA)
/dev/hda5        706+   1989    1284-  10313698+  83  Linux
[...]
% sfdisk -A2 /dev/$HD
Done
% sfdisk -l /dev/$HD
Disk /dev/hda: 7476 cylinders, 255 heads, 63 sectors/track
Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/hda1          0+     63      64-    514048+  82  Linux swap
/dev/hda2   *     64     320     257    2064352+   b  Win95 FAT32
/dev/hda3        321     705     385    3092512+  83  Linux
/dev/hda4        706    7475    6770   54380025    f  Win95 Ext'd (LBA)
/dev/hda5        706+   1989    1284-  10313698+  83  Linux
[...]

Verified again at 2004.08.23.

save/restore disk partition setting and fix errors using sfdisk 

HD=hda
HD=hdb
HD=sda

To check partition setting or errors, use the following command:

# check partition
sfdisk -V /dev/$HD

To backup the current disk partition setting, use the following command:

sfdisk -d /dev/$HD | tee partition.$HD.info

Most importantly, partitions can be recreated by this simple command:

# recreate partition
sfdisk --no-reread /dev/$HD < partition.$HD.info

Then reboot ASAP.

cmd:parted 

debfoster parted libparted1.6-0 libreiserfs0.3-0
debfoster parted- libparted1.6-0- libreiserfs0.3-0-
(parted) select /dev/hda
(parted) print
Disk geometry for /dev/hda: 0.000-58644.140 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031    502.031  primary   linux-swap
2        502.031   2518.000  primary   FAT
3       2518.000   5538.032  primary   ext2        boot
4       5538.032  58643.525  extended              lba
5       5538.063  15610.034  logical
[...]
(parted) set 2 boot on
(parted) print
Disk geometry for /dev/hda: 0.000-58644.140 megabytes
Disk label type: msdos
Minor    Start       End     Type      Filesystem  Flags
1          0.031    502.031  primary   linux-swap
2        502.031   2518.000  primary   FAT         boot
3       2518.000   5538.032  primary   ext2
4       5538.032  58643.525  extended              lba
5       5538.063  15610.034  logical
[...]
(parted) quit
help 
set MINOR FLAG STATE          change a flag on partition MINOR

MINOR is the partition number used by Linux. On msdos disk labels, the primary partitions number from 1-4, and logical partitions are 5 onwards. FLAG is one of: boot, root, swap, hidden, raid, lvm, lba STATE is one of: on, off

cmd:tune2fs 

Ext2 

Filesystem features:      filetype sparse_super
Mount count:              0
Maximum mount count:      31

Ext3 

Filesystem features:      has_journal filetype needs_recovery sparse_super
Mount count:              18
Maximum mount count:      -1

Make ext3 file system 

% mkfs -t ext3 -v -L 'dlCache1' /dev/hdb11
This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
% tune2fs -c 20 -i 15d !$
tune2fs 1.35 (28-Feb-2004)
Setting maximal mount count to 20
Setting interval between check 1296000 seconds

documented on: 2004.07.02

cmd:mkfs Partition Init 

*Tags*: format partition for linux, initial file system for linux

Use mkfs, to be more precisely, use mke2fs!

ext3 

mkfs -t ext3 -v -L 'ToBurn' /dev/hda11
mkfs.ext3 -v -L 'ToBurn' /dev/hda11
mke2fs 1.27 (8-Mar-2002)
Filesystem label=ToBurn
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1289280 inodes, 2576424 blocks
128821 blocks (5.00%) reserved for the super user
First data block=0
79 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

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

This filesystem will be automatically checked every 37 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
If called as mkfs.ext3 a journal is created as if
      the -j option was specified.
Notes:

ext2 

mkfs -t ext2 -v -L 'ToBurn' /dev/hda11
mke2fs 1.27 (8-Mar-2002)
Filesystem label=ToBurn
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1289280 inodes, 2576424 blocks
128821 blocks (5.00%) reserved for the super user
First data block=0
79 block groups
32768 blocks per group, 32768 fragments per group
16320 inodes per group
Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632

Writing inode tables: 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.

vfat 

mkfs -t vfat -v -F 32 -n 'os4' /dev/hda10
mkdosfs -v -F 32 -n 'os4' /dev/hda10
mkdosfs 2.8 (28 Feb 2001)
/dev/hda10 has 255 heads and 63 sectors per track,
logical sector size is 512,
using 0xf8 media descriptor, with 11888036 sectors;
file system has 2 32-bit FATs and 8 sectors per cluster.
FAT size is 11587 sectors, and provides 1483103 clusters.
Volume ID is 3df9542f, volume label os4     .
-F FAT-size
       Specifies  the type of file allocation tables used (12, 16 or 32
       bit).  If  nothing  is  specified,  mkdosfs  will  automatically
       select  between  12  and  16  bit,  whatever fits better for the
       filesystem size.  32 bit FAT  (FAT32  format)  must  (still)  be
       selected explicitly if you want it.
-n volume-name
       Sets the volume name (label) of the filesystem.  The volume name
       can be up to 11 characters long.  The default is no label.

cmd:fdisk 

Usage 

fdisk -l /dev/hda

Help 

# fdisk -l /dev/hda     # by cylinder
Disk /dev/hda: 255 heads, 63 sectors, 2491 cylinders
Units = cylinders of 16065 * 512 bytes
Device Boot    Start       End    Blocks   Id  System
/dev/hda1             1        64    514048+  83  Linux
/dev/hda2            65       319   2048287+  83  Linux
/dev/hda3   *       320      1057   5927985    c  Win95 FAT32 (LBA)
/dev/hda4          1058      2491  11518605    f  Win95 Ext'd (LBA)
/dev/hda5   *      2085      2491   3269196    b  Win95 FAT32
/dev/hda6          1058      2084   8249314+  83  Linux
# fdisk -lu /dev/hda     # by sector
Disk /dev/hda: 255 heads, 63 sectors, 2491 cylinders
Units = sectors of 1 * 512 bytes
Device Boot    Start       End    Blocks   Id  System
/dev/hda1            63   1028159    514048+  83  Linux
/dev/hda2       1028160   5124734   2048287+  83  Linux
/dev/hda3   *   5124735  16980704   5927985    c  Win95 FAT32 (LBA)
/dev/hda4      16980705  40017914  11518605    f  Win95 Ext'd (LBA)
/dev/hda5   *  33479523  40017914   3269196    b  Win95 FAT32
/dev/hda6      16980831  33479459   8249314+  83  Linux

Whenever a partition table is printed out, a consistency check is performed on the partition table entries. This check verifies that the physical and logical start and end points are identical, and that the partition starts and ends on a cylinder boundary (except for the first partition).

Help 

> fdisk -l
>
>Disk /dev/hda: 255 heads, 63 sectors, 2491 cylinders
>Units = cylinders of 16065 * 512 bytes
>
>   Device Boot    Start       End    Blocks   Id  System
>/dev/hda1             1        64    514048+  83  Linux
>/dev/hda2            65       319   2048287+  83  Linux
>/dev/hda3   *       320      1057   5927985    c  Win95 FAT32 (LBA)
>/dev/hda4          1058      2491  11518605    5  Extended
>/dev/hda5          1058      2030   7815591   83  Linux
>/dev/hda6          2031      2491   3702951    c  Win95 FAT32 (LBA)

FYI: Data on this disk will be damaged. If data are important, Linux partitioning tools should not be used.

An extended partition ending 1 based cylinder 1024 or later *must* by type 0F or 85 if DOS or Windows is present. The type of hda6 should be 0B.

Svend Olaf

Help 

> Isn't 0B a Fat 16 partition ?  This person wanted win95 fat32 , which is
>  >32MB , the code for which is, I believe "c"

A FAT16 partition > 32 MB is type 06, or 0E for a primary FAT16 partition ending 1 based cylinder 1025 or later. Type 0C is used for primary FAT32 partitions ending 1 based cylinder 1025 or later. Logical FAT32 partitions always are type 0B.

If cylinders are numbered from 1, extended partitions ending cylinder 1025 (not 1024) or later should be type 0F or 85.

Svend Olaf

Help 

>/dev/hda4          1058      2491  11518605    5  Extended
>/dev/hda5          1058      2030   7815591   83  Linux
>/dev/hda6          2031      2491   3702951    c  Win95 FAT32 (LBA)

You can just change the type of hda4 from 05 to 0F (F), and the type of hda6 from 0C to 0B (B) using the Linux fdisk t command. This however should be done before hda6 is formatted.

Svend Olaf