PDC_Linux
01-21-2010, 07:54 PM
I've installed my first Linux OS and am trying to make it dual boot.
To make things a bit odd, my "other" OS is DOS 6.0 (needed for some old hardware application)
DOS was on the drive first, Then installed Ubuntu 9.10. Ubuntu loads and runs great.
Now to learn GRUB... To my confusion I don't have a menu.lst file anywhere! So I got lazy and loaded a graphical configuration program. But it doesn't have a way of editing the list of OS options.( just has Ubuntu and memtest )
Any suggestions?
saikee
01-22-2010, 02:46 PM
PDC_Linux,
Welcome to Justlinux !
Ubuntu 9.10 uses Grub2 which in its place of menu.lst (for Grub1 oe lagacy Grub) the equicvalent is /boot/grub/grub.cfg. The command syntax is slightly different.
You can chainload Dos 6 just the same as before.
temporary storage only
-----------------------------------------------
I have one PC running a 1TB hard disk with 57 partitions mostly filled with operating systems. Recently I acquired a 128GB Solid State Disk (SSD) for trying it with the Linux and MS systems. The SSD works no different from any 2.5" hard disk except it is a bit faster and consumes a lot less current.
In the last couple of hours I managed to migrate a Vista-64, Win7-64 and Opensuse 11.2 from the 1TB mechical hard disk to the 128Gb SSD. The former is in a mobile rig that I can pull out in seconds while the second is hooked up as an eSata external hard disk inserted into a docking station. If I pull away the internal 1TB hard disk the external hard disk (SSD) will boot normally as the first and the only bootable disk.
In the original 1TB internal hard disk I have the Vista, swap, Win7 and Opensuse in partition No. 1, 5, 7 and 12 respectively in 50, 1, 50 and 20Gb sizes. In the external SSD the Linux is placed in the sda6 while the other remain in sda1, sda5 and sda7 as before. It is not a good idea to change a MS system partition size during migration due to its inbuilt protection but for Linux it is just a simple file-copying.
There following points may be of interest to multi-booters
How to clone a big disk to a small disk
How to manipulate the MS boot loaders
How to migrate these systems
How to make the boot loaders work after migration
My Vista in the first partition of the hard disk actually has both NTLDR (for booting Win2k and XP) and bootmgr (for booting one Vista and two Win7, one 32-bit and one 64-bit, only the latter is migrated). Thus I have an interest to preserve the MS boot loaders in the Vista partition. I did this by clone the 1TB disk, known as device sda, into the 128 SSD, device sdb, using a root terminal command from a Linux.
dd if=/dev/sda of=/dev/sdb bs=32256
This was a brutal act of forcing a 128Gb device to receive a 1TB data. However if one understands how a hard disk works then the above operation yields the desirable result.
The new disk was rejected by all operating systems as I expected because the SSD partition table claims to have 1TB size boundary when physically it has only 128Gb. An operating system does not know what to do with it and to play safe none of them would mount it and so in theory the disk is an outcast, except some Linux commands can be used to good effect in such a situation. After all Linux is the mother of all utilities!
With the normal mechanical hard disks the only Linux program that would still read such a disk would be the "fdisk" program but for some reasons this doesn't work on the SSD. My last resort was the terminal program "sfdisk" which must be used with care as it wipes any partition table.
Basically my strategy was to just to delete all the partitions except the first one and the SSD disk should be readable again so that I can access the Vista partition. My Win7 and Opensuse were located in areas exceeding the 128Gb boundary and must be done separately. I seldom use the "sfdisk" program but it is possibly the most lethal partitioning software for the PC. Basically I open up a text terminal in Linux displaying the geometry of the 1TB. The 50Gb the Vista partition occupies from 1st to 6079th cylinder.
I used these root terminal commands to repartition my unreadable hard disk with the first partition starting from default (1st cylinder), size=6078 cylinders, Type 7 for NTFS and * for marking it bootable. These are identical to the original 1TB
sfdisk /dev/sdb << EOF
,6078,7,*
EOF
As you can see the commands are very simple and every user can try it by viewing the man page of sfdisk.
I then powered the PC, removed the internal 1TB internal hard disk, left the bare SSD inserted in the docking station externally, slip in a Grub floppy, powered up the PC and fired up Vista by these commands in a Grub prompt
root (hd0,0)
chainloader +1
boot
The above step is necessary because my 1TB disk has been managed by Grub from Ubuntu 9.10 in sda16 which was no longer available in the SSD. When Grub has been broken without a home it can't boot. However my new sda1 has been cloned by dd and so the original MS boot loader inside the boot sector of sda1 would be intact. So any Grub can fire it up. I just used a floppy but the legacy Grub in a CD, say as a stand alone boot loader or from a selected iso can also do the same job.
By the way re-partitioning of a hard disk doesn't alter the partition interior. Therefore as long as I retain the relevant parts of my partition table I can still access the health data.
During the cloning of the disk the "dd" command was forced to stop when the SSD ran out of space. Thus the majority of the first 128Gb data is still good and I am using only the first 50Gb of it for the Vista.
My next step is to clone the Win7 and copy the Opensuse partition. I did this by powering down the PC, reinstating the internal 1TB disk and booting up a Linux (any one will do). Again I opened up two root terminals. One for using "fdisk -l" to display the partition sizes in cylinder unit and another to create sdb2 as an extended partition using command
fdisk /dev/sdb
The extended partition is for absorbing all the remaining space in the SSD. Inside the extended partition I created sdb5 as Type 82 for swap, sdb6 as Type 83 for Linux and sdb7 as Type 7 for NTFS partition. The crucial point here is I must make my new Win7 partition in the SSD exactly in size, down to the exact 6078 cylinders, as the old Win7 of the 1TB disk. The size of the swap and Linux partition, namely sdb5 and sdb6, are immaterial as I explained below. The SSD is recognised as device sdb when the internal disk is present but becomes device sda once the internal 1TB disk is removed. A mobo always detects the internal disks before the external disks.
Once I have the receiving partitions of Opensuse and Win7 ready I could carry out the migration.
Migration of Opensuse (or any Linux)
After the necessary partitions have been created there are 4 essential steps of formatting, mounting, copying and booting
To format the new partition is by command in root
mkfs.ext3 /dev/sdb6
To mount the source sda12 and the target sdb6 partition
mkdir /mnt/sda12
mount /dev/sda12 /mnt/sda12
mkdir /mnt/sdb6
mount /dev/sdb6 /mnt/sdb6
To copy the files from sda12 to sdb6
cd /mnt/sda12
tar cf - . | ( cd /mnt/sdb6; tar xf -)
To boot the Linux at the new location two files in the new SSD Linux partition must be altered. They are "/etc/fstab" and /boot/grub/menu.lst" which must have the reference of sda12 changed to sdb6.
I list the key sections of the two old files here, mark the relevant parts in blue which need alteration and then list the new files mark the changes in red.
Listing of old etc/fstab in sda12
/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-part5 swap swap defaults 0 0
/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-part12 / ext3 acl,user_xattr 1 1
/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-part1 /windows/C ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_GB.U TF-8 0 0
/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-part6 /windows/D ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_GB.U TF-8 0 0
/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-part7 /windows/E ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_GB.U TF-8 0 0
/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-part8 /windows/F ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_GB.U TF-8 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
New /etc/fstab of sdb6
/dev/sda5 swap swap defaults 0 0
/dev/sda6 / ext3 acl,user_xattr 1 1
/dev/sda1 /windows/C ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_GB.U TF-8 0 0
/dev/sda7 /windows/D ntfs-3g users,gid=users,fmask=133,dmask=022,locale=en_GB.U TF-8 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs noauto 0 0
debugfs /sys/kernel/debug debugfs noauto 0 0
devpts /dev/pts devpts mode=0620,gid=5 0 0
Old /boot/grub/menu.lst from sda12
default 0
timeout 8
##YaST - generic_mbr
gfxmenu (hd0,11)/boot/message
##YaST - activate
###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 11.2
root (hd0,11)
kernel /boot/vmlinuz root=/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-art12 resume=/dev/disk/by-id/ata-SAMSUNG_HD103UJ_S13PJ1KQ623145-part5 splash=silent quiet showopts vga=0x31a
initrd /boot/initrd
New /boot/grub/menu.lst for the new sdb6
default 0
#timeout 8
##YaST - generic_mbr
gfxmenu (hd0,5)/boot/message
##YaST - activate
###Don't change this comment - YaST2 identifier: Original name: linux###
title openSUSE 11.2
root (hd0,5)
kernel /boot/vmlinuz-2.6.29-6-default root=/dev/sda6 resume=/dev/sda5 splash=silent quiet showopts vga=0x31a
initrd /boot/initrd-2.6.29-6-default
After the above two files have been corrected to reflect the system has been moved from sda12 to sda6 my Opensuse was ready for booting. Again this was done by powering down, removing the internal hard disk, putting a Grub floppy in, booting up to a Grub prompt and issuing these Grub commands:
root (hd0,5)
setup (hd0,5)
setup (hd0)
The above instructs Grub to select the 6th partition of the first disk, since Grub counts from zero, as the root partition and install itself first within that partition and then in the MBR. To put Grub inside the root partition of a Linux is optional but from now on my Opensuse can be booted by any other boot loader or chainloaded by another Grub (or Lilo).
When I withdrew the floppy the Grub in the MBR now takes charge and boots to either Vista or Opensuse Linux. It was time to fixed the Win7.
To fixed Win7 boot loader one can use the BCDedit.exe available in Vista. Alternatively one can download the free utilities, one of which is EasyBCD installable in Vista and Win7. This graphic tool will lists the entries for bootmgr, which is common to both Vista and Win7, and the user can overwrite any setting. The amendment amounted to no more than letting the EasyBCD to run through the bootmgr configuration and generate the necessary ID number for the Win7 as Vista's configuration remains unchanged and valid. In the Easy BCD I just made sure the partition=D was for Win7 as Vista occupies partition=C.
Finally I had all three operating systems up and running in the faster but smaller SSD. The migration and the write-up took me about half a day. This is the first time I moved Win7 to a different logical partition.
By the way MS system boot loaders are only downward compatible. This is to say Win2k's NTLDR can't boot Xp but Xp's version can boot both. Vista and Win7 use a new common boot loader which I call bootmgr. It doesn't boot Win2k or XP but only the NTLDR. Thus in my case Grub boot everybody. When It boots Vista it actually passes the control to bootmgr. Bootmgr controls NTLDR and would pass the control to it if the user select Win2k or XP, otherwise it is bootmgr's duty to fire Vista or Win7. If one have several MS Windows the bootmgr would take control at the first partition recognised by MS systems. Thus Win2k, Xp, Vista and Win7 can all be installed in logical partitions as long as a primary partition is available to house bootmgr and NTLDR.