来源:https://www.dedoimedo.com/computers/linux-uninstall.html

This article was suggested to me by a reader called krishna. I realized this was a very important, very common topic - and quite often so easily overlooked by Linux users all over the world. It stands to logic, really. You install an operating system - so you expect to be able to uninstall it, undo the installation, remove the operating system without any trace left to its presence. How do you do that in Linux?

While the idea is a very logical, it is very difficult to answer. This is probably the reason why so many Linux users never bothered answering it. Not to worry. In this tutorial, I will teach you how you can fully and safely remove Linux installations from your system and remain with a bootable, working machine. Let's begin.

Install Linux

The first step in getting Linux onto your system is by downloading a distribution of your choice, burning the .iso image to a CD, booting a computer from the CD, and then installing the distribution. To learn how to do that, please refer to my myriad Linux reviews and tutorials, all of which explain in great, rich detail the installation procedure for different distributions. Now let's examine several test cases.

Single operating system

This is one of the most common solutions that most people will use. A single instance of an operating system is installed.

Two operating systems in a dual boot configuration

This is another very common scenario. Many new Linux users will be recent converts, all of which have previously and are currently using Windows. Many will keep their Windows installation and use Linux as a second or secondary operating system alongside their existing Windows installation. This configuration is known as dual boot. Please refer to this tutorial to learn how it can be created.

More than two operating systems

This configuration is usually used by power users, who will have several Windows releases and several Linux distributions and possibly other operating systems installed on their machine. Practically, there is very little difference between a dual-boot and a multiple-boot system.

Understand how things work

Whichever configuration you choose, it is important to understand how things work. When you install an operating system, several things are done.

Disk layout is changed

Disks are logically divided into sections called partitions. Operating systems are installed onto these partitions, when they requires at least one and usually no more than a single partition to install to. To better understand partitioning, please read the very extensive GParted tutorial.

The partitions are also formatted with one or another filesystem type, which is a logical data structure method that allows operating systems to interact with the hard disk. For example, NTFS is a Windows filesystem, EXT3 is a Linux filesystem.

A bootloader is installed

When you start your computer, the first thing you see is the BIOS screen. After that, an operating system boots. But who does it do that? Well, the answer is simple.

Hard disks contain sectors, physical parcels onto which logical data is written in the form of a filesystem operations. The very first sector is reserved for a tiny bit of code called the bootloader, which contains a basic set of instructions required to kickstart the operating system boot. The first sector is called the Master Boot Record (MBR) and it points to the active partition where important files necessary for the booting of the operating system can be found.

Every operating system installs this or that bootloader. Windows uses the NT Loader (NTLDR). Linux uses the popular GRUB. Reading my tutorial linked to the left will grant you a much deeper understanding into how GRUB works. So the boot sequence goes like this:

  • BIOS looks for the first bootable device (hard disk) and initiates it.
  • The MBR is read and the relevant partition is chosen.
  • Boot files on the relevant partitions are loaded into memory and the booting of the system begins.

Boot process

The boot process is accompanied by visual cues that allow the user to interact with the system. The first is the BIOS menu, where you can change the boot order of your devices, enable and disable peripherals and other tasks.

Next comes a bootloader menu. On Windows, you do not usually see this menu, as it's hidden from view when there's only one operating system installed. On Linux, the menu is normally displayed, usually offering several boot options.

After this stage, you reach your desktop and things are just the way you know them. However, it is important that you remember the sequence of events that took place.

Operating systems are not self-sustained entities. They require the presence of several factors to be able to function, namely the hard disk and the partitioning layout, which the operating system uses for permanent storage of its files, the bootloader that points to the right files and allows the system to boot, the BIOS, which recognizes and properly initializes the hardware. Take away any one of these and your system will not boot.

Another very critical thing to remember is that on a machine with no operating system installed, nothing will happen past the BIOS stage. Since the hard disks are empty, there is no boot sector and no bootloader installed in it. Therefore, once BIOS initializes the primary boot device, nothing will happen. The boot sequence will simply fail.

This means that uninstalling an operating system usually means leaving your machine unbootable. It is important for you to remember this. The only way to maintain desktop functionality is if there's more than a single operating system installed. You remove one or more, but that's ok, as long as there's at least one instance of an operating system capable of completing the boot sequence. Now that we understand what uninstalling an operating system means, let's do it.

Uninstall Linux

Operating systems will not work without their boot files or if they are never called by the bootloader. Therefore, to remove the presence of an operating system, it is enough to dereference is from the bootloader menu. Alternatively, you can also delete its files or replace them with another operating system. So let's examine our test cases again.

Single operating system

If you have a single operating system, removing it will render the machine unbootable. So any which way you to choose to get rid of is perfectly acceptable. This method is true for just about any operating system, including Windows.

  • You can delete all the files on the disks; this will render the system unbootable.(note: “rm -rf /*” can be used)
  • You can format the partitions where the operating system is installed.
  • You can delete the partitions where the operating system is installed or even delete the entire partition table.
  • You can uninstall the bootloader.
  • You can install another operating system on top of the existing one, simply overwriting its files.

Two operating systems in a dual boot configuration

This is the case that really interests us. We will focus on the classic case - Windows and Linux. If you've read my GRUB tutorial, you will have learned by now that GRUB install itself into the MBR and replaces the Windows bootloader that existed there.

When you uninstall Linux, which we will do shortly, you remove the GRUB stage2 from the system. GRUB stage2 contains the crucial files that allow it to boot your installed instances of Linux or transfer the boot control to Windows. This means that by removing Linux, you will also cripple the Windows installation. It will be intact, but unbootable.

This is because the Linux bootloader will still be present after you remove the Linux installation. To restore Windows functionality, you will have to install the Windows bootloader again. It will overwrite the GRUB present in the MBR and you'll be back to being able to use Windows once more. Now, to uninstall Linux, there are several options:

  • You can boot from a live CD and delete or format the Linux partitions.
  • You can boot into Windows and delete or format the Linux partitions.

Now, please note that by default, Windows cannot read data from partitions formatted in Linux filesystems like EXT3, EXT4, JFS, ReiserFS, and others, however the Disk Management utility can see these partitions. It will label them as Unknown.

There is a way to allow Windows to be able to read and write to Linux filesystems. Please read this tutorial for more details.

Furthermore, to learn more how to work with the Disk Management utility in Windows, please read my How to partition and format hard disks in Windows article.

To remove Linux, open the Disk Management utility, select the partition(s) where Linux is installed and then format them or delete them. If you delete the partitions, the device will have all its space freed. To make good use of the free space, create a new partition and format it.

But our work is not done. There's the bootloader issue to fix.

Fix the bootloader

This needs to be done on next reboot. What you need to do is restore the Master Boot Record. There are several tools that can do the trick, I will mention just two:

Super Grub Disk

Super Grub Disk is intended to run from a floppy disk or CD and is used for system rescue. Most importantly, it can be used to restore boot loaders, including GRUB, LILO and even Windows boot loader.

Ultimate Boot CD for Windows

This is one of the most important tools a Windows user can have. It is a complete bootable Windows kernel, packaged with tens of useful utilities in a range of categories. Most importantly, UBCD4WIN can fix the MBR quickly and easily. If you have a Windows CD, you can also boot from it, go into the Recovery Console and manually restore the MBR, although this is a procedure for more advanced users. Let's take a look at each option separately.

Windows Recovery Console

Boot from Window CD. After a while, you'll reach the screen where you have to choose between a setup and the Recovery Console. Press R to get into the Recovery Console.

Provide the administrator's password when asked:

Then simply type the following command:

fixmbr /r

After that, write quit to exit and reboot. And that's it.

Ultimate Boot CD for Windows

This mighty tool also has the Recovery Console, so you can use it the same way you did before. Or you can boot into the live desktop and use a number of tools.

Under Programs > Disk Tools > Partition, you will find both MBRWizard and MbrFix.

Super GRUB Disk

Super GRUB Disk also lets you fix the bootloader, be it LILO, GRUB or NTLDR. Just burn the .iso and let it boot. The main menu is very ugly, but it's quite simple to follow:

That's it. From now on, the principle is the same for three, four or a million operating systems. Just follow the same train of actions.

Conclusion

Uninstalling operating systems is not a simple thing. It's a complicated issue that requires quite a bit of knowledge, including the understanding of how computers work, the boot sequence, the hard disk & partitioning vocabulary, the bootloader.

It comes as no small wonder that so many people avoid this topic. Furthermore, it does hurt many Linux users that one of their peers should abandon the world of freedom and whatnot and go back to using Microsoft software.

Regardless what your motives are, this tutorial provides you with the tools necessary to remove Linux installations from your system and still maintain a bootable, operable machine. I would very much like to believe that no Linux user would ever take a step back and abandon his/her distribution, but in a real world, this happens and having the right tools for the task guarantees a painless transition. I hope you've learned something new. Enjoy.

佳文赏析:How to uninstall Linux的更多相关文章

  1. 一文让你熟练掌握Linux的ncat(nc)命令

    一文让你熟练掌握Linux的ncat(nc)命令 ncat 或者说 nc 是一款功能类似 cat 的工具,但是是用于网络的.它是一款拥有多种功能的 CLI 工具,可以用来在网络上读.写以及重定向数据. ...

  2. 佳文分享:CAP定理

    1976年6月4号,周5,在远离音乐会大厅的一个楼上的房间内,在位于Manchester的Lesser Free Trade Hall ,Sex Pistols 乐队(注:Sex Pistols的经理 ...

  3. PythonWeb 服务部署文档及迁移到Linux相关

    pythonWeb的部署(Django+Uwsgi): 1. 部署服务器上需要的Python3.6环境: 安装集成了python3.6 和pip ,virtualenv虚拟环境 的Anaconda(A ...

  4. NetBean 远程开发的好文1 --> NetBeans的远程Linux C开发实践

    from:  http://blog.csdn.net/jacktan/article/details/9268535 一直以来总觉得NetBeans生活在Eclipse的阴影下,同样做为一款不错的基 ...

  5. 一文带你彻底理解Linux的各种终端类型及概念

    每天使用Linux每天都要接触到Bash,使用Bash时似乎永远都让人摸不着头脑的概念就是终端,坐在这台运行着Linux的机器的显示器前面,这个显示器就是终端的输出,而插在机器上的USB键盘或者PS/ ...

  6. Linux 文档与目录结构

    Linux之文档与目录结构   Linux文件系统结构 Linux目录结构的组织形式和Windows有很大的不同.首先Linux没有“盘(C盘.D盘.E盘)”的概念.已经建立文件系统的硬盘分区被挂载到 ...

  7. Linux之文档与目录结构 目录的相关操作 Linux的文件系统

    Linux之文档与目录结构   Linux文件系统结构 Linux目录结构的组织形式和Windows有很大的不同.首先Linux没有“盘(C盘.D盘.E盘)”的概念.已经建立文件系统的硬盘分区被挂载到 ...

  8. Linux之文档与目录结构 (/ 用法, 相对路径,绝对路径)

    Linux之文档与目录结构   Linux文件系统结构 Linux目录结构的组织形式和Windows有很大的不同.首先Linux没有“盘(C盘.D盘.E盘)”的概念.已经建立文件系统的硬盘分区被挂载到 ...

  9. (转)linux下进程的进程最大数、最大线程数、进程打开的文件数和ulimit命令修改硬件资源限制

    ulimit命令查看和更改系统限制 ulimit命令详解 ulimit用于shell启动进程所占用的资源,可以用来设置系统的限制 语法格式 ulimit [-acdfHlmnpsStvw] [size ...

随机推荐

  1. .NET Core微服务之基于Jenkins+Docker实现持续部署(Part 1)

    Tip: 此篇已加入.NET Core微服务基础系列文章索引 一.CI, CD 与Jenkins 互联网软件的开发和发布,已经形成了一套标准流程,最重要的组成部分就是持续集成(Continuous i ...

  2. 在dotnet core下去中心化访问HTTP服务集群

    一般应用服务都会部署到多台服务器之上,一.可以通过硬件得到更多的并发处理能力:二.可以避免单点太故障的出现,从而确保服务7X24有效运作.当访问这些HTTP服务的情况一般都是经过反向代理服务进行统一处 ...

  3. 如何让vue自定义组件可以包裹内容,并且渲染出来,以及组件的组合使用

    当我们用vue一开始写项目时,按需求文档自定义了一个公用组件,这个组件很多地方都用到了,然后随着项目的推进,又有了新的需求要在里面加东西,但又不是所有的地方都要加 这时候我们想这样往里面塞内容↓    ...

  4. [开源]WinForm 控件使用总结

    背景 都2019年了,还在用WinForm吗?哈哈,其实我也没在用,都是很多年前一些项目积累,所以代码写的有些屎,之所以开源出来,希望能给大家有所帮助,喜欢的话给 一个Star以资鼓励~: 具体代码: ...

  5. 机器学习之支持向量机—SVM原理代码实现

    支持向量机—SVM原理代码实现 本文系作者原创,转载请注明出处:https://www.cnblogs.com/further-further-further/p/9596898.html 1. 解决 ...

  6. 【Java】几道让你拿offer的知识点

    前言 只有光头才能变强 之前在刷博客的时候,发现一些写得比较好的博客都会默默收藏起来.最近在查阅补漏,有的知识点比较重要的,但是在之前的博客中还没有写到,于是趁着闲整理一下. 文本的知识点: Inte ...

  7. CVE-2017-1000405 利用脏牛漏洞Linux提权复现

    当前路径: /var/www 磁盘列表: / 系统信息: Linux zico 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC 2012 ...

  8. 基础知识:IDE集成开发环境(pycharm)、基本数据类型、用户的交互、运算符

    今日内容: 1.IDE集成开发环境(pycharm) 2.基本数据类型(int.float.str.list.dict) 3.用户的交互(注释.输入input.输出print) 4.运算符(分类及使用 ...

  9. 委托的多线程方法BeginInvoke

    同步方法和异步方法: 同步方法调用在程序继续执行之前需要等待同步方法执行完毕返回结果.(比如烧水泡茶,需要等水烧开了才能继续泡茶) 异步方法则在被调用之后立即返回以便程序在被调用方法完成其任务的同时执 ...

  10. 三位数流水码的生成(000·····009··00A····00Z····ZZZ)

    //规格代码的生成 private String getCode (String code) { char[] chars=code.toCharArray(); if (chars[2]==57){ ...