博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux 分区方案_如何为Linux PC选择分区方案
阅读量:2508 次
发布时间:2019-05-11

本文共 11877 字,大约阅读时间需要 39 分钟。

linux 分区方案

linux 分区方案

hdd part (dmyhung) cropped

Afraid of the dreaded “p” word?  You’re not alone.  Partitions can get complicated, so here’s an explanation of what they are, how they’re used, and a simple template to use for your own Linux installation.

害怕可怕的“ p”字吗? 你不是一个人。 分区可能会变得很复杂,所以这里是它们的解释,用法以及用于您自己的Linux安装的简单模板。

Image by

图片由

什么是分区? (What Are Partitions?)

Partitions are divisions in the formatting of the hard disk.  It’s a logical – as opposed to a physical – division, so you can edit and manipulate them for various purposes.  Think breaking a disk into two configuration parts.  Partitions are really handy because they act as a sandbox.  If you have a 1 TB hard drive partitioned into a 250 GB partition and a 750 GB partition, what you have on the latter will not affect the other, and vice versa.  You can share one of those partitions on the network and never worry about people accessing information on the other.  One could have Windows installed, riddled with viruses and trojans.  The other could be running a very obsolete, security-hole addled Linux installation.  Never shall the two interfere, unless either you make them or the hard drive itself physically dies.

分区是硬盘格式化中的分区。 这是逻辑划分(而不是物理划分),因此您可以出于各种目的编辑和操作它们。 考虑将磁盘分为两个配置部分。 分区非常方便,因为它们充当沙箱。 如果将1 TB硬盘驱动器划分为250 GB分区和750 GB分区,则后者上的分区不会影响另一个分区,反之亦然。 您可以共享网络上的一个分区,而不必担心人们访问另一个分区上的信息。 一个人可能已经安装了Windows,到处都是病毒和木马。 另一个可能正在运行非常过时的,安全漏洞严重的Linux安装。 除非您制造它们或硬盘驱动器本身物理死亡,否则两者绝对不可干涉。

The other useful thing is that you can have multiple partitions, each formatted with a different “file system.”  A file system is a formatting of the disk into a table that the operating system can read, interpret, and write to.  Only have one hard drive?  That’s okay, because you can still install multiple operating systems on it without actually having another physical disk.

另一个有用的事情是您可以有多个分区,每个分区的格式都不同。 文件系统是将磁盘格式化为表格,操作系统可以读取,解释和写入该表格。 只有一个硬盘? 没关系,因为您仍然可以在其上安装多个操作系统而无需实际拥有另一个物理磁盘。

While there are tons of file system types, there are only three kinds of partitions: primary, extended, and logical.  Any given hard disk can only have a maximum of four primary partitions.  This limitation is due to something called the Master Boot Record which tells the computer which partitions it can boot from, and so primary partitions are usually reserved for operating systems.  But what if we want more than four?  That’s where the extended partition comes into play.  It serves as a hollow container for any number of smaller, logical partitions.  You can make as many as you like there, as well as make it home to your non-OS sections.

尽管文件系统类型很多,但是分区只有三种:主分区,扩展分区和逻辑分区。 任何给定的硬盘最多只能有四个主分区。 此限制是由于称为“主启动记录”的信息,该信息告诉计算机它可以从哪个分区启动,因此通常将主分区保留给操作系统。 但是,如果我们想要四个以上呢? 这就是扩展分区起作用的地方。 它充当任何数量的较小逻辑分区的中空容器。 您可以在那里任意选择,也可以放置在非OS部分中。

If extended partitions are so great, why not just use them?  That’s because you can’t directly boot from anywhere inside an extended partition.  There are ways to get around this, but the best thing to do is to plan properly beforehand with primary partitions.  In addition, the way partitions are numbered by the system depends on these types.  First, the machine will number based on all primary partitions, and then by logical ones.  This can cause changing drive letters if you switch between OSs or add or delete partitions later.

如果扩展分区是如此之大,为什么不只使用它们呢? 那是因为您不能从扩展分区内的任何位置直接启动。 有很多方法可以解决此问题,但是最好的办法是事先对主分区进行适当的计划。 此外,系统对分区进行编号的方式取决于这些类型。 首先,计算机将基于所有主分区进行编号,然后根据逻辑分区进行编号。 如果您在操作系统之间进行切换,或者稍后添加或删除分区,则可能导致驱动器号更改。

Linux中的挂载点 (Mount Points in Linux)

partition scheme (methoddan)

Image by

图片来自

On Windows, things are pretty clearly cut: it lives on your disk, usually on one partition, and that’s that.  If you have other drives, and they have a compatible file system, then it’ll read them as well.  If not, it’ll usually ignore them, or offer you the ability to reformat.  Linux – and anything resembling Unix, really – doesn’t quite work that way.

在Windows上,一切都非常清楚:它驻留在磁盘上,通常在一个分区上,仅此而已。 如果您有其他驱动器,并且它们具有兼容的文件系统,则它也会读取它们。 如果不是,它通常会忽略它们,或者为您提供重新格式化的功能。 Linux-以及实际上任何类似于Unix的东西-都不能那样工作。

The way Linux works is that it puts everything onto a tree.  If you have another partition or disk, it gets “mounted” as a branch in a specific folder, usually /media or /mnt.  The directory that a partition gets mounted to is called a “mount point.”  This method works better with Linux’s tree structure, and you can mount partitions as folders nearly anywhere.  In Windows, this is not so easily done; new partitions generally show up as separate drives.  In addition, Linux can work with many more types of file systems natively than Windows.

Linux的工作方式是将所有内容都放在一棵树上。 如果您有另一个分区或磁盘,它会作为分支挂载在特定文件夹(通常是/ media或/ mnt)中。 分区挂载到的目录称为“挂载点”。 此方法与Linux的树形结构配合使用效果更好,几乎可以将分区挂载为文件夹。 在Windows中,这并非易事。 新分区通常显示为单独的驱动器。 此外,与Windows相比,Linux可以在本地使用更多类型的文件系统。

Remember how there could only be four primary partitions?  If you want to did, you can set up a primary partition for /boot, which houses a boot-loader, like GRUB or LiLo, which handles initial functions and then continues booting into the extended partitions.

还记得怎么可能只有四个主分区吗? 如果要 ,则可以为/ boot设置一个主分区,其中包含一个引导加载程序(例如GRUB或LiLo),该加载程序可以处理初始功能,然后继续引导到扩展分区中。

我应该使用什么方案? (What Scheme Should I Use?)

The standard partitions scheme for most home Linux installs is as follows:

大多数家庭Linux安装的标准分区方案如下:

  • A 12-20 GB partition for the OS, which gets mounted as / (called “root”)

    操作系统的12-20 GB分区,挂载为/(称为“ root”)
  • A smaller partition used to augment your RAM, mounted and referred to as swap

    一个较小的分区,用于增加您的RAM,已安装并称为交换
  • A larger partition for personal use, mounted as /home

    供个人使用的较大分区,安装为/ home

The exact size requirements change based on your needs, but in general you start with swap.  If you do a lot of multimedia editing, and/or have a smaller amount of RAM, you should use a larger amount of swap.  If you have plenty of memory, you can skimp on it, although some distributions of Linux have a problem going into standby or hibernating without much swap.  The rule of thumb is that you choose between 1.5 to 2 times the amount of RAM as the swap space, and you put this partition in a place that is quick to reach, like at the beginning or end of the disk.

确切的大小要求会根据您的需求而变化,但通常从交换开始。 如果您进行大量的多媒体编辑和/或使用较少的RAM,则应使用大量的交换。 如果您有足够的内存,则可以略过,尽管某些Linux发行版在没有太多交换的情况下进入待机或Hibernate状态时会出现问题。 经验法则是,您选择RAM数量的1.5到2倍作为交换空间,然后将此分区放置在可以快速访问的位置,例如磁盘的开头或结尾。

Even if you install a ton software, a maximum of 20 GB for your root partition should be enough.  Most distributions of Linux use either ext3 or ext4 as their file system nowadays, which has a built-in “self-cleaning” mechanism so you don’t have to defrag.  In order for this to work best, though, there should be free space for between 25-35% of the partition.

即使您安装了吨软件,根分区最多也要有20 GB的空间。 如今,大多数Linux发行版都将ext3或ext4用作其文件系统,该文件系统具有内置的“自我清除”机制,因此您无需进行碎片整理。 但是,为了使此方法最有效,应该为分区的25-35%之间留有可用空间。

Finally, whatever else you have should go to your /home partition.  This is where your personal stuff is stored. It is functionally the equivalent of the “Users” directory in Windows, housing your application settings, music, downloads, documents, etc, and those of any other users you have on your system.  It’s useful to have /home in a separate partition because when you upgrade or reinstall your OS, you don’t have to backup anything in this folder!  Isn’t that convenient?  To top it off, most of your program- and UI-related settings are saved as well!

最后,其他所有内容都应转到/ home分区。 这是您的个人物品存放的地方。 它在功能上等效于Windows中的“用户”目录,其中包含您的应用程序设置,音乐,下载,文档等,以及您系统上所有其他用户的设置。 将/ home放在单独的分区中很有用,因为在升级或重新安装操作系统时,无需备份此文件夹中的任何内容! 那不方便吗? 最重要的是,还保存了大多数与程序和用户界面相关的设置!

Screenshot-Install

If you’re running a server with a lot of users and/or a lot of media, you could optimize performance by using two hard drives.  A small solid state drive would be perfect for the OS to live on, maybe 32 GB at most, and you could throw the swap partition on the beginning of a 1 or 2 TB “green” drive that’s mounted on /home.

如果运行的服务器上有很多用户和/或许多媒体,则可以使用两个硬盘驱动器来优化性能。 小型固态驱动器非常适合OS生存,最多可能是32 GB,并且您可以将交换分区扔到/ home上安装的1或2 TB“绿色”驱动器的开头。

If you’re into more tinkering, you can even set up different partitions for things like the temporary directory (/tmp), for your web server’s content (/var/www), for programs (/usr), or for log files (/var/log).

如果您想修改一下,甚至可以为临时目录(/ tmp),Web服务器的内容(/ var / www),程序(/ usr)或日志文件(例如, / var / log)。

在安装过程中指定安装点 (Specifying Mount Points During Installation)

In our example, we’ll be using showing the partition setup during an Ubuntu Maverick Meerkat installation.  When you get to where it says “Allocate drive space,” choose “Specify partitions manually (advanced).”

在我们的示例中,我们将使用在Ubuntu Maverick Meerkat安装过程中显示分区设置。 当您到达显示“分配驱动器空间”的位置时,请选择“手动指定分区(高级)”。

installation manual

Don’t panic just because you see “advanced”; it’s really not that difficult and you’ll be getting some real rewards from the process.  Click forward and you’ll see the partition table.

不要因为看到“高级”而感到恐慌; 其实并没有那么困难,您将从过程中获得真正的回报。 单击前进,您将看到分区表。

new partition

Click on the free space row in the table and then click on “Add…”  If you don’t have free space, click on your Windows partition, hit “Change…” and shrink it to a more palatable size.  This will give you some free space to work with.

单击表中的可用空间行,然后单击“添加...”。如果没有可用空间,请单击Windows分区,单击“更改...”,然后将其缩小为更可口的大小。 这将为您提供一些可用的空间。

Create partition

Here, you can see that I’ve created a Primary partition of about 11.5-odd GB at the beginning of the disk and I’ve specified it to use root as the mount point.  You will have to use a Linux-compatible file system, so I used the default ext4, although you can use ext2, ext3, ReiserFS, or whatever else.  Do some research online and you’ll be able to choose the best, but if you’re in doubt, stick to the default.  You can adjust yours to more space if you have it, but again, you probably won’t ever need more than 20 GB unless you’re installing/compiling a lot of software.  Click “OK” and you’re set to create another partition.

在这里,您可以看到我在磁盘的开头创建了一个大约11.5 GB的主分区,并且将其指定为使用root作为挂载点。 您将必须使用Linux兼容的文件系统,因此尽管使用了ext2,ext3,ReiserFS或其他任何东西,但我还是使用了默认的ext4。 在线进行一些研究,您可以选择最好的,但是如果您有疑问,请坚持使用默认值。 您可以根据需要将其调整为更大的空间,但是同样,除非您要安装/编译大量软件,否则您可能永远不需要超过20 GB的空间。 单击“确定”,您就可以创建另一个分区。

swap

This time, as you can see, I’ve chosen a logical partition (the partitioning program automatically creates an extended partition for this).  Since this machine has a 512 MB of RAM, I’ve approximated 1.5 times that, and designated it as “swap area.”  Also note that I’ve stuck this at the end of the disk, which will help keep disk seeking times at a minimum.  Click “OK,” and let’s create another partition.

如您所见,这次,我选择了一个逻辑分区(分区程序会为此自动创建一个扩展分区)。 由于这台机器具有512 MB的RAM,因此我估计大约是它的1.5倍,并将其指定为“交换区域”。 另请注意,我已将其粘贴在磁盘的末尾,这将有助于使磁盘搜索时间保持最少。 单击“确定”,然后创建另一个分区。

home

I’ve selected all of the rest of the space in the middle to be my /home partition.  The compatible file system I’ve chosen is again ext4.  Now here is the gray area: should it be primary or logical?  I went with primary because I know that I won’t be installing another OS on here, otherwise I would have gone with logical.  If you don’t plan on installing more than three OSs, you can just make it primary for simplicity’s sake.

我已经选择了中间其余所有空间作为/ home分区。 我选择的兼容文件系统还是ext4。 现在是灰色区域:应该是主要区域还是逻辑区域? 我选择了primary,因为我知道我不会在这里安装另一个OS,否则我会顺理成章。 如果您不打算安装三个以上的操作系统,则为简单起见,可以将其设置为主要操作系统。

When you’re all finished, you can resume installation.  Here’s my resulting partition table:

完成后,您可以继续安装。 这是我生成的分区表:

finished!

If you get cold feet, you can quit the installation at this point without fearing any data loss.  Nothing is actually done to your disk until you hit “Install Now,” so you can go back and edit things as you wish.

如果您感觉冷淡,可以在此时退出安装,而不必担心会丢失任何数据。 在您单击“立即安装”之前,实际上对磁盘没有任何操作,因此您可以返回并根据需要编辑内容。



Now that you know what partitions are and how to optimally set up your Linux installation, feel free to continue your search online.  There’s a lot more to learn!  Have any advice or tricks to the process?  Maybe some useful experiences to share?  Be sure to leave a comment!

既然您知道什么是分区以及如何最佳地设置Linux安装,请随时继续在线搜索。 还有很多东西要学习! 对这个过程有什么建议或技巧吗? 也许可以分享一些有用的经验? 请务必发表评论!

翻译自:

linux 分区方案

转载地址:http://lczwd.baihongyu.com/

你可能感兴趣的文章
JS装箱操作和拆箱操作的理解
查看>>
第一次作业
查看>>
Latex常用符号
查看>>
sudo 用户添加
查看>>
Maven deploy Return code is: 400
查看>>
Ant介绍
查看>>
uva11383
查看>>
correlation filters in object tracking
查看>>
[转] SQL Server 数据库性能优化
查看>>
JavaIDL开发CORBA实例演示
查看>>
洛谷3973 TJOI2015线性代数(最小割+思维)
查看>>
poj1185 炮兵阵地【状压DP】
查看>>
python2和python3 print输出不换行
查看>>
python使用progressbar显示进度条
查看>>
卷积神经网络的权值参数个数的量化分析
查看>>
telnet 的使用(ping 与 telnet)
查看>>
推理集 —— 物质与成分及性质的研究
查看>>
服务端事件EventSource揭秘
查看>>
Oracle 物理DG切换
查看>>
iOS本地版本和服务器对比
查看>>