Merge pull request #3483 from strugglingyouth/master

翻译完成
This commit is contained in:
ictlyh 2015-11-06 14:48:43 +08:00
commit 29e6e96466
2 changed files with 91 additions and 89 deletions

View File

@ -1,89 +0,0 @@
translation by strugglingyouth
How to Create New File Systems/Partitions in the Terminal on Linux
================================================================================
![](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-feature-image.png)
Partition editing or making new file systems on Linux usually means one thing: installing the Gnome Parted partition editor (GParted). For most Linux users, this is the only way to go about it. Still, what if you could edit these partitions and file systems right in the terminal? You can! Heres how!
### Creating a basic Linux partition layout with CFdisk ###
Heres how to make a basic Linux partition scheme right from the command line. The first thing to do is open your terminal. Once youre there, youll need to identify what hard drive youre looking to change. This can easily be figured out with one simple command.
lsblk
![cfdisk-lsblk](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-lsblk.png)
Once youve run `lsblk`, you should get a detailed list of each hard drive currently on your system. Look through this generated list, and figure out the denotation to the drive you want to change. In this article Ill be using `sdb` for the sake of example.
In your terminal enter this command. It will launch a powerful terminal-based partition editing program.
sudo cfdisk /dev/sdb
![cfdisk-empty-layout](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-empty-layout.png)
**Note**: replace `sdb` with whatever `lsblk` told you your hard drive was.
When this command is entered, youll be inside the partition editor and will have total access to the hard drive you wish to modify.
Since hard drive partitions are different, depending on a users needs, this part of the guide will go over **how to set up a split Linux home/root system layout**.
To start, a root partition will need to be created. This will require a bit of math as the gigabytes on the hard drive need to be divided up. My test drive is 32 GB.
In CFdisk using the arrow keys on your keyboard, select some free space. Once youve found some, use the arrow key to select [ NEW ] and press the Enter key.
![cfdisk-create-root-partition](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-create-root-partition.png)
The program will ask you to input the partition size. Once youve specified the size, press the Enter key. This will be known as the root partition (or /dev/sdb1).
Next its time to create the home partition (/dev/sdb2). Once again, youll need to select some free space in CFdisk. Use the arrow key to select the [ NEW ] option, and press the Enter key. Input the size of your home partition, and press the Enter key to create it.
![cfdisk-create-home-partition](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-create-home-partition.png)
Finally, the swap partition needs to be created. Like the two times before, find some free space, and use the arrow key to select the [ NEW ] option. After that calculate exactly how big your Linux swap partition needs to be.
**Note**: a swap partition is usually about as big as a computers physical RAM.
![cfdisk-specify-partition-type-swap](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-specify-partition-type-swap.png)
Now that the swap partition has been created, its time to specify its type. Highlight it with the up and down arrow keys. After that use the left and right arrow keys to select [ TYPE ]. Find Linux swap in the menu, and press Enter.
![cfdisk-write-partition-table](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-write-partition-table.jpg)
All of the partition creation is out of the way. All thats left is to write it to the disk. Using the right arrow key, select the [ WRITE ] option, and press the Enter key. This will write your newly created layout directly to the hard drive.
### Creating file systems with mkfs ###
Sometimes you dont need to make an entire partition layout. Sometimes you just need to make a file system. This can easily be accomplished directly in the terminal with the `mkfs` command.
![cfdisk-mkfs-list-partitions-lsblk](https://www.maketecheasier.com/assets/uploads/2015/10/cfdisk-mkfs-list-partitions-lsblk.png)
To start, figure out what youre looking to modify. Enter `lsblk` in your terminal to find out. Itll print out a list, and after that just find the partition or drive you want to make a file system on.
In this example, Ill point it towards the first partition of the secondary drive `/dev/sdb1`. Its also possible to just point mkfs to `/dev/sdb` (to make use of the entire drive).
![cfdisk-mkfs-make-file-system-ext4](https://www.maketecheasier.com/assets/uploads/2015/10/cfdisk-mkfs-make-file-system-ext4.png)
To create the new file system on a specific partition, just enter
sudo mkfs.ext4 /dev/sdb1
into the terminal. It should be noted that `mkfs.ext4` can be changed to whatever file system you want to use.
### Conclusion ###
Though editing file systems and partitions is easier using a graphical tool, the terminal is arguably more efficient. Its much more faster to just load up a terminal, tap a few buttons and be done. With GParted and tools like it, its a whole ordeal. I hope that with the help of this tutorial you, too, understand how efficient editing file systems in the terminal can be.
Do you prefer to use terminal-based programs to edit partitions on Linux? Why or why not? Tell us below!
--------------------------------------------------------------------------------
via: https://www.maketecheasier.com/create-file-systems-partitions-terminal-linux/
作者:[Derrik Diener][a]
译者:[译者ID](https://github.com/译者ID)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.maketecheasier.com/author/derrikdiener/

View File

@ -0,0 +1,91 @@
如何在 Linux 终端下创建新的文件系统/分区
================================================================================
![](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-feature-image.png)
在 Linux 中创建分区或新的文件系统通常意味着一件事:安装 Gnome Parted 分区编辑器GParted。对于大多数 Linux 用户而言,这是唯一的办法。不过,你是否考虑过在终端创建这些分区和文件系统?当然可以!以下就是方法!
### 使用 CFdisk 创建一个基本的 Linux 分区 ###
以下是如何在命令行中创建一个基本的 Linux 分区的正确方案。要做的第一件事就是先打开你的终端。若你已打开,你需要找到你想要创建分区的磁盘。这可以使用一个简单的命令来找到。
lsblk
![cfdisk-lsblk](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-lsblk.png)
一旦你运行了 `lsblk`,你应该会看到当前系统上每个磁盘的详细列表。看看这个列表,然后找出你想要使用的磁盘。在本文中,我将使用 `sdb` 来进行演示。
在终端输入这个命令。它会显示一个功能强大的基于终端的分区编辑程序。
sudo cfdisk /dev/sdb
![cfdisk-empty-layout](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-empty-layout.png)
**注意**: 使用在 `lsblk` 命令输出的你想要使用的磁盘来替换 `sdb`
当输入此命令后,你将进入分区编辑器中,然后访问你想改变的磁盘。
Since hard drive partitions are different, depending on a users needs, this part of the guide will go over **how to set up a split Linux home/root system layout**.
由于磁盘分区的不同,这取决于用户的需求,这部分的指南将在 **如何建立一个分布的 Linux home/root 文件分区**
首先,需要创建根分区。这需要根据磁盘的字节数来进行分割。我测试的磁盘是 32 GB。
在 CFdisk 中使用键盘上的方向键选择需要分配的空间。你找到后,请使用箭头键选择 [ NEW ],然后按 Enter 键。
![cfdisk-create-root-partition](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-create-root-partition.png)
该程序会要求你输入分区大小。一旦你指定好大小后,按 Enter 键。这将被称为根分区(或 /dev/sdb1
接下来该创建用户分区(/dev/sdb2了。你需要在 CFdisk 中再选择一些空闲分区。使用箭头选择 [ NEW ] 选项,然后按 Enter 键。输入你用户分区的大小,然后按 Enter 键来创建它。
![cfdisk-create-home-partition](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-create-home-partition.png)
最后,需要创建交换分区。像前两次一样,先找一些空闲分区,并使用箭头选择 [ NEW ] 选项。之后,算下你 Linux 想使用多大的交换分区。
**注意**: 交换分区通常和计算机的内存差不多大。
![cfdisk-specify-partition-type-swap](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-specify-partition-type-swap.png)
现在,交换分区被创建了,该指定其类型。使用上下箭头来选择它。之后,使用左右箭头选择 [ TYPE ] 。找到 Linux swap 选项,然后按 Enter 键。
![cfdisk-write-partition-table](https://www.maketecheasier.com/assets/uploads/2015/03/cfdisk-write-partition-table.jpg)
所有分区创建后。然后就是将其写入到磁盘。使用右箭头键,选择 [ WRITE ] 选项,然后按 Enter 键。这将直接将新创建的分布写入到磁盘中。
### 使用 mkfs 创建文件系统 ###
有时候,你并不需要一个完整的分区,你只想要创建一个文件系统而已。你可以在终端直接使用 `mkfs` 命令来实现。
![cfdisk-mkfs-list-partitions-lsblk](https://www.maketecheasier.com/assets/uploads/2015/10/cfdisk-mkfs-list-partitions-lsblk.png)
首先,找出你要使用的磁盘。在终端输入 `lsblk` 找出来。它会打印出列表,之后只要找到你想制作文件系统的分区或盘符。
在这个例子中,我将使用 `/dev/sdb1` 的第一个分区。只对 `/dev/sdb` 使用 mkfs将会使用整个分区
![cfdisk-mkfs-make-file-system-ext4](https://www.maketecheasier.com/assets/uploads/2015/10/cfdisk-mkfs-make-file-system-ext4.png)
要在一个特定的分区上创建新文件系统,只需输入
sudo mkfs.ext4 /dev/sdb1
在终端。应当指出的是,`mkfs.ext4` 可以将你指定的任何文件系统改变。
### 结论 ###
虽然使用图形工具编辑文件系统和分区更容易但终端可以说是更有效的。终端的加载速度更快点击几个按钮即可。GParted 和其它工具一样,它也是一个完整的工具。我希望在本教程的帮助下,你会明白如何在终端中高效的编辑文件系统。
你是否更喜欢使用基于终端的方法在 Linux 上编辑分区?为什么或为什么不?在下面告诉我们!
--------------------------------------------------------------------------------
via: https://www.maketecheasier.com/create-file-systems-partitions-terminal-linux/
作者:[Derrik Diener][a]
译者:[strugglingyouth](https://github.com/strugglingyouth)
校对:[校对者ID](https://github.com/校对者ID)
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
[a]:https://www.maketecheasier.com/author/derrikdiener/