Table of Contents
Goal change boot device from /dev/hda3 to /dev/hda2
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.
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.
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