个人工具

“UbuntuHelp:Installation/FromAnotherDistro”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
(新页面: {{From|https://help.ubuntu.com/community/Installation/FromAnotherDistro}} {{Languages|UbuntuHelp:Installation/FromAnotherDistro}} === Introduction and Warning === The intent of this howt...)
 
第2行: 第2行:
 
{{Languages|UbuntuHelp:Installation/FromAnotherDistro}}
 
{{Languages|UbuntuHelp:Installation/FromAnotherDistro}}
 
=== Introduction and Warning ===
 
=== Introduction and Warning ===
 
 
The intent of this howto is to describe how to install Ubuntu from within your current distribution, replacing your current distribution ON THE SAME PARTITION.  In case you haven't guessed, '''this is a rather tricky situation, and can cause you to lose information''', even though care is taken to try to prevent this.
 
The intent of this howto is to describe how to install Ubuntu from within your current distribution, replacing your current distribution ON THE SAME PARTITION.  In case you haven't guessed, '''this is a rather tricky situation, and can cause you to lose information''', even though care is taken to try to prevent this.
 
 
This is mainly useful in the case where you have no boot Ubuntu install disk, and no cd burner.  It can also be useful for saving your old homedirs when you have no way to back them up, and your filesystem is of a type that can't be resized to allow for a new partition.  Its main purpose, though, is to satisfy the wreckless urge to risk your data over an operating-system change, rather than waiting until one can back it up.  Keep in mind that, on the chance that something goes wrong and you turn your computer into a dead badger, you should have a known-to-work install disk for another OS or distribution available to you.  You should also recognize that you are taking responsibility for your information (or the loss thereof) into your own hands by following this howto.  You should be at least an intermediate linux user.
 
This is mainly useful in the case where you have no boot Ubuntu install disk, and no cd burner.  It can also be useful for saving your old homedirs when you have no way to back them up, and your filesystem is of a type that can't be resized to allow for a new partition.  Its main purpose, though, is to satisfy the wreckless urge to risk your data over an operating-system change, rather than waiting until one can back it up.  Keep in mind that, on the chance that something goes wrong and you turn your computer into a dead badger, you should have a known-to-work install disk for another OS or distribution available to you.  You should also recognize that you are taking responsibility for your information (or the loss thereof) into your own hands by following this howto.  You should be at least an intermediate linux user.
 
 
=== Before We Begin ===
 
=== Before We Begin ===
 
 
 
==== Things You Will Need ====
 
==== Things You Will Need ====
 
+
# Any linux boot/rescue cd with standard utilities for your filesystem (often the install disk for your current distribution will work fine, as long as you can get to a shell)
* Any linux boot/rescue cd with standard utilities for your filesystem (often the install disk for your current distribution will work fine, as long as you can get to a shell)
+
2. A network connection.  There's no need for the Ubuntu install disk.
* A network connection.  There's no need for the Ubuntu install disk.
+
3. The package "alien", to convert the install package to your own distribution's format, from that of Ubuntu.  You should install this now, if it isn't already on your system.
* The package "alien", to convert the install package to your own distribution's format, from that of Ubuntu.  You should install this now, if it isn't already on your system.
+
4. To verify that Ubuntu supports your current filesystem.
* To verify that Ubuntu supports your current filesystem.
+
5. To convert your current distribution's bootloader to "grub", unless it already uses it.
* To convert your current distribution's bootloader to "grub", unless it already uses it.
+
 
+
 
We will be assuming RPM as the package management for the original OS in this howto, but alien converts between quite a few formats.
 
We will be assuming RPM as the package management for the original OS in this howto, but alien converts between quite a few formats.
 
 
 
 
==== Summary of Actions to be taken ====
 
==== Summary of Actions to be taken ====
 
 
The following list is for those who just want to race ahead and find out.
 
The following list is for those who just want to race ahead and find out.
 
+
# [http://archive.ubuntulinux.org/ubuntu/pool/main/d/debootstrap/ Get debootstrap](w/install scripts), convert with the "Alien" package converter, and install to original system.
* [http://archive.ubuntulinux.org/ubuntu/pool/main/d/debootstrap/ Get debootstrap](w/install scripts), convert with the "Alien" package converter, and install to original system.
+
2. Run the install scripts, wait, configure the new system, and install a few things.
* Run the install scripts, wait, configure the new system, and install a few things.
+
3. Configure bootloader and reboot to rescue disk.
* Configure bootloader and reboot to rescue disk.
+
4. Move some things around -- out with the old, and in with the new. :-)
* Move some things around -- out with the old, and in with the new. :-)
+
5. Boot to Ubuntu, with fingers crossed.
* Boot to Ubuntu, with fingers crossed.
+
6. Install and configure the rest of the system
* Install and configure the rest of the system
+
 
+
 
Shall we?
 
Shall we?
 
 
 
 
=== Installation ===
 
=== Installation ===
 
 
==== Install debootstrap and Ubuntu debootstrap scripts ====
 
==== Install debootstrap and Ubuntu debootstrap scripts ====
 
 
* Grab the latest debootstrap_*.deb from http://archive.ubuntulinux.org/ubuntu/pool/main/d/debootstrap/.  Make sure it matches your architecture.
 
* Grab the latest debootstrap_*.deb from http://archive.ubuntulinux.org/ubuntu/pool/main/d/debootstrap/.  Make sure it matches your architecture.
 
 
* Using alien, convert the package to your distribution's format.  For example:
 
* Using alien, convert the package to your distribution's format.  For example:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# alien -r debootstrap*.deb
 
# alien -r debootstrap*.deb
 
</nowiki></pre>
 
</nowiki></pre>
 
 
* Now install the new RPM package as you normally would for your distribution.  If your distribution already has debootstrap installed (debian?), then uninstall it, and install the package you downloaded.
 
* Now install the new RPM package as you normally would for your distribution.  If your distribution already has debootstrap installed (debian?), then uninstall it, and install the package you downloaded.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# rpm -iv debootstrap*.rpm
 
# rpm -iv debootstrap*.rpm
 
</nowiki></pre>
 
</nowiki></pre>
 
 
* Locate the installation directory for the scripts.  This should be in /opt or in /usr.
 
* Locate the installation directory for the scripts.  This should be in /opt or in /usr.
 
<pre><nowiki>
 
<pre><nowiki>
 
# find /opt | grep debootstrap\/scripts; find /usr | grep debootstrap\/scripts
 
# find /opt | grep debootstrap\/scripts; find /usr | grep debootstrap\/scripts
 
</nowiki></pre>
 
</nowiki></pre>
 
 
This should return the location of pathnames that contain debootstrap/scripts, for example:
 
This should return the location of pathnames that contain debootstrap/scripts, for example:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
/usr/lib/debootstrap/scripts
 
/usr/lib/debootstrap/scripts
第77行: 第52行:
 
/usr/lib/debootstrap/scripts/sarge.buildd
 
/usr/lib/debootstrap/scripts/sarge.buildd
 
</nowiki></pre>
 
</nowiki></pre>
 
 
* Set DEBOOTSTRAP_DIR environment variable and start the install.  
 
* Set DEBOOTSTRAP_DIR environment variable and start the install.  
 
* Make sure DEBOOTSTRAP_DIR is set to the path you got above (not including the "scripts" directory).
 
* Make sure DEBOOTSTRAP_DIR is set to the path you got above (not including the "scripts" directory).
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# export DEBOOTSTRAP_DIR="/usr/lib/debootstrap"
 
# export DEBOOTSTRAP_DIR="/usr/lib/debootstrap"
 
 
# cd /usr/lib/debootstrap/scripts
 
# cd /usr/lib/debootstrap/scripts
 
 
# debootstrap --arch i386 warty /mnt/ubuntu http://archive.ubuntulinux.org/ubuntu warty
 
# debootstrap --arch i386 warty /mnt/ubuntu http://archive.ubuntulinux.org/ubuntu warty
 
<sup>1^        ^2^              ^^3^</sup>
 
<sup>1^        ^2^              ^^3^</sup>
 
</nowiki></pre>
 
</nowiki></pre>
 
+
*For 1:  Choose your processor architecture (all, including new, pc's are i386).
**For 1:  Choose your processor architecture (all, including new, pc's are i386).
+
*For 2:  Choose the directory to install to.  Choose something unique, like /mnt/ubuntu.  :-) Don't choose a used directory.
**For 2:  Choose the directory to install to.  Choose something unique, like /mnt/ubuntu.  :-) Don't choose a used directory.
+
*For 3:  Choose an appropriate, up-to-date mirror, or use the above address.
**For 3:  Choose an appropriate, up-to-date mirror, or use the above address.
+
 
+
 
+
 
+
 
Wait for the install to finish.  If your network is unreliable, then you may need to run debootstrap multiple times to complete the installation.  It should resume where it left off.  If it has successfully installed, you should see the message "Base system installed successfully" near the end of its output.  If you run into a problem unrelated to networking, you may need to delete all of the installed files and directories and restart.
 
Wait for the install to finish.  If your network is unreliable, then you may need to run debootstrap multiple times to complete the installation.  It should resume where it left off.  If it has successfully installed, you should see the message "Base system installed successfully" near the end of its output.  If you run into a problem unrelated to networking, you may need to delete all of the installed files and directories and restart.
 
 
 
 
==== Set up fstab ====
 
==== Set up fstab ====
 
 
* Create your fstab.  You can copy your current one, but you may need to make a couple changes.
 
* Create your fstab.  You can copy your current one, but you may need to make a couple changes.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# cp /etc/fstab /mnt/ubuntu/etc/fstab
 
# cp /etc/fstab /mnt/ubuntu/etc/fstab
 
# nano /mnt/ubuntu/etc/fstab
 
# nano /mnt/ubuntu/etc/fstab
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Use your favorite text editor in place of nano above.  
 
Use your favorite text editor in place of nano above.  
 
 
* Change the mount points on the partition(s) you set up in step 1
 
* Change the mount points on the partition(s) you set up in step 1
 
* Change their options to "defaults"
 
* Change their options to "defaults"
第117行: 第77行:
 
* Add "sync" to the options for /mnt/floppy.
 
* Add "sync" to the options for /mnt/floppy.
 
* Remove the /dev/pts line -- not needed?
 
* Remove the /dev/pts line -- not needed?
 
 
Here is a decent fstab file:
 
Here is a decent fstab file:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
#FileSystem MountPT    FSType  Options    Dump fsck-order
 
#FileSystem MountPT    FSType  Options    Dump fsck-order
第125行: 第83行:
 
/proc      /proc      proc    defaults  0    0
 
/proc      /proc      proc    defaults  0    0
 
/sys        /sys        sysfs  defaults  0    0
 
/sys        /sys        sysfs  defaults  0    0
 
 
#Hard Drives..  ..edit these if necessary
 
#Hard Drives..  ..edit these if necessary
 
/dev/hda2  none        swap    defaults  0    0
 
/dev/hda2  none        swap    defaults  0    0
第132行: 第89行:
 
#Uncomment and edit the following line if you have a boot partition
 
#Uncomment and edit the following line if you have a boot partition
 
#/dev/hda1  /boot      ext2    defaults,noauto  0    0
 
#/dev/hda1  /boot      ext2    defaults,noauto  0    0
 
 
#Removable Media..
 
#Removable Media..
 
/dev/fd0    /mnt/floppy auto user,noauto,sync,exec,umask=000 0 0
 
/dev/fd0    /mnt/floppy auto user,noauto,sync,exec,umask=000 0 0
 
/dev/cdrom  /mnt/cdrom  auto user,noauto,exec,ro            0 0
 
/dev/cdrom  /mnt/cdrom  auto user,noauto,exec,ro            0 0
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
Make sure your / entry has options set to 'defaults', otherwise sudo may not function:  "Sorry, sudo must be setuid root."
 
Make sure your / entry has options set to 'defaults', otherwise sudo may not function:  "Sorry, sudo must be setuid root."
 
 
 
==== Set up Hostname and Networking ====
 
==== Set up Hostname and Networking ====
 
 
===== Hostname =====
 
===== Hostname =====
 
Of course, you should replace HOSTNAME in the command below with the desired name for your machine.  
 
Of course, you should replace HOSTNAME in the command below with the desired name for your machine.  
 
You may need to remove /mnt/ubuntu/etc/hostname first, because it may be a symbolic link to your current /etc/hostname by default, due to a bug in some versions of debootstrap.
 
You may need to remove /mnt/ubuntu/etc/hostname first, because it may be a symbolic link to your current /etc/hostname by default, due to a bug in some versions of debootstrap.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# rm -f /mnt/ubuntu/etc/hostname
 
# rm -f /mnt/ubuntu/etc/hostname
 
# echo $HOSTNAME > /mnt/ubuntu/etc/hostname
 
# echo $HOSTNAME > /mnt/ubuntu/etc/hostname
 
</nowiki></pre>
 
</nowiki></pre>
 
 
===== Networking =====
 
===== Networking =====
 
* If you are running a debian-based distribution already, you can copy /etc/network.interfaces.
 
* If you are running a debian-based distribution already, you can copy /etc/network.interfaces.
 
* Copy the resolv.conf, as in the second line below:
 
* Copy the resolv.conf, as in the second line below:
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# cp /etc/network/interfaces /mnt/ubuntu/etc/network/
 
# cp /etc/network/interfaces /mnt/ubuntu/etc/network/
第162行: 第110行:
 
# nano /mnt/ubuntu/etc/network/interfaces
 
# nano /mnt/ubuntu/etc/network/interfaces
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Here is my Ubuntu /etc/network/interfaces setup (in /mnt/ubuntu/etc/network/).
 
Here is my Ubuntu /etc/network/interfaces setup (in /mnt/ubuntu/etc/network/).
 
<pre><nowiki>
 
<pre><nowiki>
 
auto lo
 
auto lo
 
iface lo inet loopback
 
iface lo inet loopback
 
 
auto wlan0
 
auto wlan0
 
iface wlan0 inet dhcp
 
iface wlan0 inet dhcp
 
</nowiki></pre>
 
</nowiki></pre>
 
 
You also need to set up the hosts file to include your machine name.
 
You also need to set up the hosts file to include your machine name.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# cp /etc/hosts /mnt/ubuntu/etc/
 
# cp /etc/hosts /mnt/ubuntu/etc/
 
# nano /mnt/ubuntu/etc/hosts
 
# nano /mnt/ubuntu/etc/hosts
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Here is an example /etc/hosts file for cowflavors.dyndns.org.
 
Here is an example /etc/hosts file for cowflavors.dyndns.org.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
127.0.0.1  localhost
 
127.0.0.1  localhost
 
127.0.0.1  cowflavors.dyndns.org  cowflavors
 
127.0.0.1  cowflavors.dyndns.org  cowflavors
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
 
==== Enter the install environment ====
 
==== Enter the install environment ====
 
 
Chroot puts you in the new Ubuntu environment.  "mount /proc" mounts proc in the new environment.  You may also need to mount /sys, if you are on a 2.6 kernel.  If you run into errors accessing devices, mount /sys.
 
Chroot puts you in the new Ubuntu environment.  "mount /proc" mounts proc in the new environment.  You may also need to mount /sys, if you are on a 2.6 kernel.  If you run into errors accessing devices, mount /sys.
 
 
If you have a sepparate boot partition, mount /boot before you do the other three commands.
 
If you have a sepparate boot partition, mount /boot before you do the other three commands.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# mount /boot #If you have a sepparate boot partition.
 
# mount /boot #If you have a sepparate boot partition.
 
 
# mount -o bind /boot /mnt/ubuntu/boot
 
# mount -o bind /boot /mnt/ubuntu/boot
 
# chroot /mnt/ubuntu
 
# chroot /mnt/ubuntu
 
# mount /proc
 
# mount /proc
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
 
==== Set up base system ====
 
==== Set up base system ====
 
 
Setting up your locale and keyboard.
 
Setting up your locale and keyboard.
 
 
"""***If you do not do this then dpkg, a system configurator, may have problems, due to a bug in certain versions of dpkg."""
 
"""***If you do not do this then dpkg, a system configurator, may have problems, due to a bug in certain versions of dpkg."""
 
 
I use en-US ISO 8859-1, as I don't often type international characters, and can use a character selector in X when I do.  en-US ISO 8859-15 contains mapping to type international characters.  ("u becomes ü, etc)
 
I use en-US ISO 8859-1, as I don't often type international characters, and can use a character selector in X when I do.  en-US ISO 8859-15 contains mapping to type international characters.  ("u becomes ü, etc)
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# dpkg-reconfigure locales console-data
 
# dpkg-reconfigure locales console-data
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
 
==== Install the kernel and bootloader ====
 
==== Install the kernel and bootloader ====
 
 
When installing the linux kernel below, you may want to install one specifically for your particular processor.
 
When installing the linux kernel below, you may want to install one specifically for your particular processor.
 
 
Your options are:
 
Your options are:
 
linux-image-386    Safest
 
linux-image-386    Safest
第228行: 第151行:
 
linux-image-k7      AMD K7, Athlon, AthlonXP etc. and higher.
 
linux-image-k7      AMD K7, Athlon, AthlonXP etc. and higher.
 
linux-image-k7-smp  AMD K7, etc. Multiprocessor systems
 
linux-image-k7-smp  AMD K7, etc. Multiprocessor systems
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# apt-get install linux-image-386
 
# apt-get install linux-image-386
 
# apt-get install grub
 
# apt-get install grub
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
 
==== Configuring Grub for Both Systems ====
 
==== Configuring Grub for Both Systems ====
 
 
As was mentioned initially, your original distribution should be using Grub.  Grub is much more flexible than Lilo, and works very well for our purposes.  Since your present/original system should already boot from Grub, all we have to do here is edit the menu.lst file to add Ubuntu.
 
As was mentioned initially, your original distribution should be using Grub.  Grub is much more flexible than Lilo, and works very well for our purposes.  Since your present/original system should already boot from Grub, all we have to do here is edit the menu.lst file to add Ubuntu.
 
 
Because Linux starts numbering at hda1, but grub starts at (hd0,0), you must subtract 1 from the partition number.  (hd0,2) is equivalent to hda3, and (hd1,0) is equivalent to hdb1.
 
Because Linux starts numbering at hda1, but grub starts at (hd0,0), you must subtract 1 from the partition number.  (hd0,2) is equivalent to hda3, and (hd1,0) is equivalent to hdb1.
 
 
Edit /boot/grub/menu.lst (and/or /boot/grub/grub.conf).  If you have both, check and see if they are identical.  If so, do the following.
 
Edit /boot/grub/menu.lst (and/or /boot/grub/grub.conf).  If you have both, check and see if they are identical.  If so, do the following.
 
<pre><nowiki>
 
<pre><nowiki>
第247行: 第163行:
 
ln -s grub.conf menu.lst
 
ln -s grub.conf menu.lst
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If they are not identical, either edit them both or determine which one your system boots from normally, keep that one, and make a link by the name of the original file which points to the file you kept (as above).
 
If they are not identical, either edit them both or determine which one your system boots from normally, keep that one, and make a link by the name of the original file which points to the file you kept (as above).
 
 
Insert the following into the file, with the following caveats.
 
Insert the following into the file, with the following caveats.
A. "root (hd0,0)", replacing (hd0,0) with the device that contains your kernels.  This is usually either your root or boot partition.
+
# "root (hd0,0)", replacing (hd0,0) with the device that contains your kernels.  This is usually either your root or boot partition.
 
B. "kernel /vmlinuz root=/dev/hda3" and "initrd /initrd.img"
 
B. "kernel /vmlinuz root=/dev/hda3" and "initrd /initrd.img"
** If you have no boot partition, using the /vmlinuz and /initrd links should be fine.
+
# If you have no boot partition, using the /vmlinuz and /initrd links should be fine.
** If those do not work, use "kernel /boot/<YourCurrentKernel>" and "initrd /boot/<YourCurrentInitrd", I.e. vmlinuz-2.6.8.1-3 and initrd.img-2.6.8.1-3, respectively.  You'll need to update these if and when you update your kernel in the future.
+
2. If those do not work, use "kernel /boot/<YourCurrentKernel>" and "initrd /boot/<YourCurrentInitrd", I.e. vmlinuz-2.6.8.1-3 and initrd.img-2.6.8.1-3, respectively.  You'll need to update these if and when you update your kernel in the future.
** BE SURE to update the "root=/dev/hda3" part to whatever partition is your root partition!  If you don't, it will not boot past loading the kernel and initrd.  It will panic and suggest using a proper device in the root= line.
+
3. BE SURE to update the "root=/dev/hda3" part to whatever partition is your root partition!  If you don't, it will not boot past loading the kernel and initrd.  It will panic and suggest using a proper device in the root= line.
 
C. "initrd /initrd.img" Make sure you use the matching initrd for your kernel.
 
C. "initrd /initrd.img" Make sure you use the matching initrd for your kernel.
 
 
Example:
 
Example:
 
<pre><nowiki>
 
<pre><nowiki>
第265行: 第178行:
 
initrd /initrd.img
 
initrd /initrd.img
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Example of modified /boot/grub/menu.lst
 
Example of modified /boot/grub/menu.lst
 
 
<pre><nowiki>
 
<pre><nowiki>
 
default 0
 
default 0
 
timeout 4
 
timeout 4
 
 
title=Ubuntu
 
title=Ubuntu
 
root (hd0,0)
 
root (hd0,0)
 
kernel /vmlinuz root=/dev/hda3
 
kernel /vmlinuz root=/dev/hda3
 
initrd /initrd.img
 
initrd /initrd.img
 
 
title=My Old Distribution
 
title=My Old Distribution
 
root (hd0,0)
 
root (hd0,0)
 
kernel /bzImage.customYopper
 
kernel /bzImage.customYopper
 
initrd /initrd.customYopper
 
initrd /initrd.customYopper
 
 
title=Memtest86
 
title=Memtest86
 
root (hd0,0)
 
root (hd0,0)
 
kernel /boot/memtest86+.bin
 
kernel /boot/memtest86+.bin
 
</nowiki></pre>
 
</nowiki></pre>
 
 
The version of Grub which your current distribution installed is in the bootsector, and will read the changes on bootup.
 
The version of Grub which your current distribution installed is in the bootsector, and will read the changes on bootup.
 
 
Now unmount the drives, and exit the subshell.
 
Now unmount the drives, and exit the subshell.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# exit            <-- exits the chroot subshell
 
# exit            <-- exits the chroot subshell
 
# umount /mnt/ubuntu/boot
 
# umount /mnt/ubuntu/boot
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If you want, you can do an optional reinstall of grub, but it should be unnecessary.  Replace hda with your system's default boot disk.
 
If you want, you can do an optional reinstall of grub, but it should be unnecessary.  Replace hda with your system's default boot disk.
 
<pre><nowiki>
 
<pre><nowiki>
 
# grub-install /dev/hda
 
# grub-install /dev/hda
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Insert the recovery CDRom and reboot.
 
Insert the recovery CDRom and reboot.
 
 
 
 
==== Swapping in your new Ubuntu ====
 
==== Swapping in your new Ubuntu ====
 
 
===== Mounting =====
 
===== Mounting =====
 
Once your recovery CD is done booting, first make a directory to mount the disk to.
 
Once your recovery CD is done booting, first make a directory to mount the disk to.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
mkdir /mnt/disk
 
mkdir /mnt/disk
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If that doesn't work, type "mount" by itsself, and look at the feedback.  You're looking for a directory which has a read-write ramfs mounted.
 
If that doesn't work, type "mount" by itsself, and look at the feedback.  You're looking for a directory which has a read-write ramfs mounted.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# mount
 
# mount
 
none on /example1 type ramfs (rw)
 
none on /example1 type ramfs (rw)
 
</nowiki></pre>
 
</nowiki></pre>
 
 
There, the directory /example1 is mounted!  What a surprise.
 
There, the directory /example1 is mounted!  What a surprise.
 
 
If there is no mounted ramfs, try:
 
If there is no mounted ramfs, try:
 
<pre><nowiki>
 
<pre><nowiki>
 
# mount -t ramfs none /mnt
 
# mount -t ramfs none /mnt
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Feel free to change /mnt to some other non-essential directory of your choice.
 
Feel free to change /mnt to some other non-essential directory of your choice.
 
 
 
Now, to mount your root partition -- Do the following, but change /dev/hda3 to whatever your root partition is:
 
Now, to mount your root partition -- Do the following, but change /dev/hda3 to whatever your root partition is:
 
<pre><nowiki>
 
<pre><nowiki>
第336行: 第227行:
 
# mount /dev/hda3 /mnt/hd
 
# mount /dev/hda3 /mnt/hd
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
 
===== Moving =====
 
===== Moving =====
 
 
Move your old Distribution into a backup dir.  If you have a boot partition, do not mount it.
 
Move your old Distribution into a backup dir.  If you have a boot partition, do not mount it.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# cd /mnt/hd
 
# cd /mnt/hd
第349行: 第235行:
 
# ls -a
 
# ls -a
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If the ls -a shows any files other than OldDistro, ., and .., move them into OldDistro.
 
If the ls -a shows any files other than OldDistro, ., and .., move them into OldDistro.
 
Then, move Ubuntu into the present directory.
 
Then, move Ubuntu into the present directory.
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# mv .hiddenfiles OldDistro/
 
# mv .hiddenfiles OldDistro/
 
 
# mv OldDistro/mnt/ubuntu/* ./
 
# mv OldDistro/mnt/ubuntu/* ./
 
# ls -a OldDistro/mnt/ubuntu/
 
# ls -a OldDistro/mnt/ubuntu/
 
</nowiki></pre>
 
</nowiki></pre>
 
 
If the ls -a shows any files, move them into the current directory (/mnt/hd):
 
If the ls -a shows any files, move them into the current directory (/mnt/hd):
 
<pre><nowiki>
 
<pre><nowiki>
 
# mv OldDistro/mnt/ubuntu/.dev ./
 
# mv OldDistro/mnt/ubuntu/.dev ./
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Restore original boot directory (containing files to boot both distributions):
 
Restore original boot directory (containing files to boot both distributions):
 
<pre><nowiki>
 
<pre><nowiki>
第370行: 第251行:
 
# mv OldDistro/boot ./
 
# mv OldDistro/boot ./
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Now, what you should have in /mnt/hd (your hard drive):
 
Now, what you should have in /mnt/hd (your hard drive):
 
* boot/
 
* boot/
第379行: 第259行:
 
** Standard linux directories, but not the ones you want.  ;-)
 
** Standard linux directories, but not the ones you want.  ;-)
 
** Don't forget, your old home directories are in here!
 
** Don't forget, your old home directories are in here!
 
 
Now, unmount and reboot, crossing fingers!
 
Now, unmount and reboot, crossing fingers!
 
<pre><nowiki>
 
<pre><nowiki>
第386行: 第265行:
 
shutdown -r now
 
shutdown -r now
 
</nowiki></pre>
 
</nowiki></pre>
 
 
Don't forget to eject the rescue cd before next bootup.  ;-)
 
Don't forget to eject the rescue cd before next bootup.  ;-)
 
 
 
 
==== Finish Setup ====
 
==== Finish Setup ====
 
 
Set up timezones, users, and apt.  This is a lengthy process that will try to launch GDM at the end.  Once that's done, if you're not in your new desktop, then reboot again, and all should be started.. :-)
 
Set up timezones, users, and apt.  This is a lengthy process that will try to launch GDM at the end.  Once that's done, if you're not in your new desktop, then reboot again, and all should be started.. :-)
 
 
<pre><nowiki>
 
<pre><nowiki>
 
# /usr/sbin/base-config new
 
# /usr/sbin/base-config new
 
</nowiki></pre>
 
</nowiki></pre>
 
 
 
 
==== troubleshooting ====
 
==== troubleshooting ====
 
This page was largely written while I was very tired.  Please look for mistakes and fix them as appropriate.. :-)  I know this is an atrocity of textual formatting.  :-(
 
This page was largely written while I was very tired.  Please look for mistakes and fix them as appropriate.. :-)  I know this is an atrocity of textual formatting.  :-(
 
 
This page was taken mainly from the [[UbuntuHelp:Installation/FromKnoppix]].
 
This page was taken mainly from the [[UbuntuHelp:Installation/FromKnoppix]].
 
References from the [[UbuntuHelp:Installation/FromKnoppix]]:
 
References from the [[UbuntuHelp:Installation/FromKnoppix]]:

2007年11月30日 (五) 17:55的版本

Introduction and Warning

The intent of this howto is to describe how to install Ubuntu from within your current distribution, replacing your current distribution ON THE SAME PARTITION. In case you haven't guessed, this is a rather tricky situation, and can cause you to lose information, even though care is taken to try to prevent this. This is mainly useful in the case where you have no boot Ubuntu install disk, and no cd burner. It can also be useful for saving your old homedirs when you have no way to back them up, and your filesystem is of a type that can't be resized to allow for a new partition. Its main purpose, though, is to satisfy the wreckless urge to risk your data over an operating-system change, rather than waiting until one can back it up. Keep in mind that, on the chance that something goes wrong and you turn your computer into a dead badger, you should have a known-to-work install disk for another OS or distribution available to you. You should also recognize that you are taking responsibility for your information (or the loss thereof) into your own hands by following this howto. You should be at least an intermediate linux user.

Before We Begin

Things You Will Need

  1. Any linux boot/rescue cd with standard utilities for your filesystem (often the install disk for your current distribution will work fine, as long as you can get to a shell)

2. A network connection. There's no need for the Ubuntu install disk. 3. The package "alien", to convert the install package to your own distribution's format, from that of Ubuntu. You should install this now, if it isn't already on your system. 4. To verify that Ubuntu supports your current filesystem. 5. To convert your current distribution's bootloader to "grub", unless it already uses it. We will be assuming RPM as the package management for the original OS in this howto, but alien converts between quite a few formats.

Summary of Actions to be taken

The following list is for those who just want to race ahead and find out.

  1. Get debootstrap(w/install scripts), convert with the "Alien" package converter, and install to original system.

2. Run the install scripts, wait, configure the new system, and install a few things. 3. Configure bootloader and reboot to rescue disk. 4. Move some things around -- out with the old, and in with the new. :-) 5. Boot to Ubuntu, with fingers crossed. 6. Install and configure the rest of the system Shall we?

Installation

Install debootstrap and Ubuntu debootstrap scripts

# alien -r debootstrap*.deb
  • Now install the new RPM package as you normally would for your distribution. If your distribution already has debootstrap installed (debian?), then uninstall it, and install the package you downloaded.
# rpm -iv debootstrap*.rpm
  • Locate the installation directory for the scripts. This should be in /opt or in /usr.
# find /opt | grep debootstrap\/scripts; find /usr | grep debootstrap\/scripts

This should return the location of pathnames that contain debootstrap/scripts, for example:

/usr/lib/debootstrap/scripts
/usr/lib/debootstrap/scripts/sid
/usr/lib/debootstrap/scripts/hoary
/usr/lib/debootstrap/scripts/sarge
/usr/lib/debootstrap/scripts/slink
/usr/lib/debootstrap/scripts/warty
/usr/lib/debootstrap/scripts/woody
/usr/lib/debootstrap/scripts/woody.buildd
/usr/lib/debootstrap/scripts/potato
/usr/lib/debootstrap/scripts/hoary.buildd
/usr/lib/debootstrap/scripts/sid.buildd
/usr/lib/debootstrap/scripts/warty.buildd
/usr/lib/debootstrap/scripts/sarge.buildd
  • Set DEBOOTSTRAP_DIR environment variable and start the install.
  • Make sure DEBOOTSTRAP_DIR is set to the path you got above (not including the "scripts" directory).
# export DEBOOTSTRAP_DIR="/usr/lib/debootstrap"
# cd /usr/lib/debootstrap/scripts
# debootstrap --arch i386 warty /mnt/ubuntu http://archive.ubuntulinux.org/ubuntu warty
<sup>1^         ^2^               ^^3^</sup>
  • For 1: Choose your processor architecture (all, including new, pc's are i386).
  • For 2: Choose the directory to install to. Choose something unique, like /mnt/ubuntu.  :-) Don't choose a used directory.
  • For 3: Choose an appropriate, up-to-date mirror, or use the above address.

Wait for the install to finish. If your network is unreliable, then you may need to run debootstrap multiple times to complete the installation. It should resume where it left off. If it has successfully installed, you should see the message "Base system installed successfully" near the end of its output. If you run into a problem unrelated to networking, you may need to delete all of the installed files and directories and restart.

Set up fstab

  • Create your fstab. You can copy your current one, but you may need to make a couple changes.
# cp /etc/fstab /mnt/ubuntu/etc/fstab
# nano /mnt/ubuntu/etc/fstab

Use your favorite text editor in place of nano above.

  • Change the mount points on the partition(s) you set up in step 1
  • Change their options to "defaults"
  • Change the Type to whatever Filesystem is on that particular partition.
  • Change /mnt/auto/floppy to /mnt/floppy. Do the same for /mnt/cdrom.
  • Add "sync" to the options for /mnt/floppy.
  • Remove the /dev/pts line -- not needed?

Here is a decent fstab file:

#FileSystem MountPT     FSType  Options    Dump fsck-order
#System Mounts..
/proc       /proc       proc    defaults   0    0
/sys        /sys        sysfs   defaults   0    0
#Hard Drives..  ..edit these if necessary
/dev/hda2   none        swap    defaults   0    0
/dev/hda3   /           ext3    defaults   0    1
/dev/hda6   /home       ext3    defaults   0    2
#Uncomment and edit the following line if you have a boot partition
#/dev/hda1  /boot       ext2    defaults,noauto   0    0
#Removable Media..
/dev/fd0    /mnt/floppy auto user,noauto,sync,exec,umask=000 0 0
/dev/cdrom  /mnt/cdrom  auto user,noauto,exec,ro             0 0

Make sure your / entry has options set to 'defaults', otherwise sudo may not function: "Sorry, sudo must be setuid root."

Set up Hostname and Networking

Hostname

Of course, you should replace HOSTNAME in the command below with the desired name for your machine. You may need to remove /mnt/ubuntu/etc/hostname first, because it may be a symbolic link to your current /etc/hostname by default, due to a bug in some versions of debootstrap.

# rm -f /mnt/ubuntu/etc/hostname
# echo $HOSTNAME > /mnt/ubuntu/etc/hostname
Networking
  • If you are running a debian-based distribution already, you can copy /etc/network.interfaces.
  • Copy the resolv.conf, as in the second line below:
# cp /etc/network/interfaces /mnt/ubuntu/etc/network/
# cp /etc/resolv.conf /mnt/ubuntu/etc/
# nano /mnt/ubuntu/etc/network/interfaces

Here is my Ubuntu /etc/network/interfaces setup (in /mnt/ubuntu/etc/network/).

auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet dhcp

You also need to set up the hosts file to include your machine name.

# cp /etc/hosts /mnt/ubuntu/etc/
# nano /mnt/ubuntu/etc/hosts

Here is an example /etc/hosts file for cowflavors.dyndns.org.

127.0.0.1   localhost
127.0.0.1   cowflavors.dyndns.org  cowflavors

Enter the install environment

Chroot puts you in the new Ubuntu environment. "mount /proc" mounts proc in the new environment. You may also need to mount /sys, if you are on a 2.6 kernel. If you run into errors accessing devices, mount /sys. If you have a sepparate boot partition, mount /boot before you do the other three commands.

# mount /boot #If you have a sepparate boot partition.
# mount -o bind /boot /mnt/ubuntu/boot
# chroot /mnt/ubuntu
# mount /proc

Set up base system

Setting up your locale and keyboard. """***If you do not do this then dpkg, a system configurator, may have problems, due to a bug in certain versions of dpkg.""" I use en-US ISO 8859-1, as I don't often type international characters, and can use a character selector in X when I do. en-US ISO 8859-15 contains mapping to type international characters. ("u becomes ü, etc)

# dpkg-reconfigure locales console-data

Install the kernel and bootloader

When installing the linux kernel below, you may want to install one specifically for your particular processor. Your options are: linux-image-386 Safest linux-image-686 Optimized for Intel PPro/Celeron/PII/PIII/PIV linux-image-686-smp Intel multiprocessor or hyperthreading machines. linux-image-k7 AMD K7, Athlon, AthlonXP etc. and higher. linux-image-k7-smp AMD K7, etc. Multiprocessor systems

# apt-get install linux-image-386
# apt-get install grub

Configuring Grub for Both Systems

As was mentioned initially, your original distribution should be using Grub. Grub is much more flexible than Lilo, and works very well for our purposes. Since your present/original system should already boot from Grub, all we have to do here is edit the menu.lst file to add Ubuntu. Because Linux starts numbering at hda1, but grub starts at (hd0,0), you must subtract 1 from the partition number. (hd0,2) is equivalent to hda3, and (hd1,0) is equivalent to hdb1. Edit /boot/grub/menu.lst (and/or /boot/grub/grub.conf). If you have both, check and see if they are identical. If so, do the following.

rm menu.lst
ln -s grub.conf menu.lst

If they are not identical, either edit them both or determine which one your system boots from normally, keep that one, and make a link by the name of the original file which points to the file you kept (as above). Insert the following into the file, with the following caveats.

  1. "root (hd0,0)", replacing (hd0,0) with the device that contains your kernels. This is usually either your root or boot partition.

B. "kernel /vmlinuz root=/dev/hda3" and "initrd /initrd.img"

  1. If you have no boot partition, using the /vmlinuz and /initrd links should be fine.

2. If those do not work, use "kernel /boot/<YourCurrentKernel>" and "initrd /boot/<YourCurrentInitrd", I.e. vmlinuz-2.6.8.1-3 and initrd.img-2.6.8.1-3, respectively. You'll need to update these if and when you update your kernel in the future. 3. BE SURE to update the "root=/dev/hda3" part to whatever partition is your root partition! If you don't, it will not boot past loading the kernel and initrd. It will panic and suggest using a proper device in the root= line. C. "initrd /initrd.img" Make sure you use the matching initrd for your kernel. Example:

title=Ubuntu
root (hd0,0)
kernel /vmlinuz root=/dev/hda3
initrd /initrd.img

Example of modified /boot/grub/menu.lst

default 0
timeout 4
title=Ubuntu
root (hd0,0)
kernel /vmlinuz root=/dev/hda3
initrd /initrd.img
title=My Old Distribution
root (hd0,0)
kernel /bzImage.customYopper
initrd /initrd.customYopper
title=Memtest86
root (hd0,0)
kernel /boot/memtest86+.bin

The version of Grub which your current distribution installed is in the bootsector, and will read the changes on bootup. Now unmount the drives, and exit the subshell.

# exit             <-- exits the chroot subshell
# umount /mnt/ubuntu/boot

If you want, you can do an optional reinstall of grub, but it should be unnecessary. Replace hda with your system's default boot disk.

# grub-install /dev/hda

Insert the recovery CDRom and reboot.

Swapping in your new Ubuntu

Mounting

Once your recovery CD is done booting, first make a directory to mount the disk to.

mkdir /mnt/disk

If that doesn't work, type "mount" by itsself, and look at the feedback. You're looking for a directory which has a read-write ramfs mounted.

# mount
none on /example1 type ramfs (rw)

There, the directory /example1 is mounted! What a surprise. If there is no mounted ramfs, try:

# mount -t ramfs none /mnt

Feel free to change /mnt to some other non-essential directory of your choice. Now, to mount your root partition -- Do the following, but change /dev/hda3 to whatever your root partition is:

# mkdir /mnt/hd
# mount /dev/hda3 /mnt/hd
Moving

Move your old Distribution into a backup dir. If you have a boot partition, do not mount it.

# cd /mnt/hd
# mkdir OldDistro
# mv * OldDistro/
# ls -a

If the ls -a shows any files other than OldDistro, ., and .., move them into OldDistro. Then, move Ubuntu into the present directory.

# mv .hiddenfiles OldDistro/
# mv OldDistro/mnt/ubuntu/* ./
# ls -a OldDistro/mnt/ubuntu/

If the ls -a shows any files, move them into the current directory (/mnt/hd):

# mv OldDistro/mnt/ubuntu/.dev ./

Restore original boot directory (containing files to boot both distributions):

# mv boot boot.bak      #This file should be empty anyways.
# mv OldDistro/boot ./

Now, what you should have in /mnt/hd (your hard drive):

  • boot/
    • (a directory containing boot files for both systems)
  • Ubuntu
    • Standard linux directories: /mnt, /opt, /var/, /proc, /dev, etc..
  • OldDistro/
    • Standard linux directories, but not the ones you want.  ;-)
    • Don't forget, your old home directories are in here!

Now, unmount and reboot, crossing fingers!

cd /
umount /mnt/hd
shutdown -r now

Don't forget to eject the rescue cd before next bootup.  ;-)

Finish Setup

Set up timezones, users, and apt. This is a lengthy process that will try to launch GDM at the end. Once that's done, if you're not in your new desktop, then reboot again, and all should be started.. :-)

# /usr/sbin/base-config new

troubleshooting

This page was largely written while I was very tired. Please look for mistakes and fix them as appropriate.. :-) I know this is an atrocity of textual formatting.  :-( This page was taken mainly from the UbuntuHelp:Installation/FromKnoppix. References from the UbuntuHelp:Installation/FromKnoppix: http://archive.ubuntulinux.org/ubuntu/dists/warty/main/installer-i386/current/doc/manual/en/apcs03.html . Another page that might prove helpful is http://www.inittab.de/manuals/debootstrap.html .