From 4d084a2f3144ab58cf65b7f540a5058e97c85d65 Mon Sep 17 00:00:00 2001 From: Chang Liu Date: Tue, 18 Aug 2015 22:36:23 +0800 Subject: [PATCH] [Translated]RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md --- ...to Configure and Encrypt System Storage.md | 271 ------------------ ...to Configure and Encrypt System Storage.md | 269 +++++++++++++++++ 2 files changed, 269 insertions(+), 271 deletions(-) delete mode 100644 sources/tech/RHCSA Series/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md create mode 100644 translated/tech/RHCSA/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md diff --git a/sources/tech/RHCSA Series/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md b/sources/tech/RHCSA Series/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md deleted file mode 100644 index 0e631ce37d..0000000000 --- a/sources/tech/RHCSA Series/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md +++ /dev/null @@ -1,271 +0,0 @@ -FSSlc translating - -RHCSA Series: Using ‘Parted’ and ‘SSM’ to Configure and Encrypt System Storage – Part 6 -================================================================================ -In this article we will discuss how to set up and configure local system storage in Red Hat Enterprise Linux 7 using classic tools and introducing the System Storage Manager (also known as SSM), which greatly simplifies this task. - -![Configure and Encrypt System Storage](http://www.tecmint.com/wp-content/uploads/2015/04/Configure-and-Encrypt-System-Storage.png) - -RHCSA: Configure and Encrypt System Storage – Part 6 - -Please note that we will present this topic in this article but will continue its description and usage on the next one (Part 7) due to vastness of the subject. - -### Creating and Modifying Partitions in RHEL 7 ### - -In RHEL 7, parted is the default utility to work with partitions, and will allow you to: - -- Display the current partition table -- Manipulate (increase or decrease the size of) existing partitions -- Create partitions using free space or additional physical storage devices - -It is recommended that before attempting the creation of a new partition or the modification of an existing one, you should ensure that none of the partitions on the device are in use (`umount /dev/partition`), and if you’re using part of the device as swap you need to disable it (`swapoff -v /dev/partition`) during the process. - -The easiest way to do this is to boot RHEL in rescue mode using an installation media such as a RHEL 7 installation DVD or USB (Troubleshooting → Rescue a Red Hat Enterprise Linux system) and Select Skip when you’re prompted to choose an option to mount the existing Linux installation, and you will be presented with a command prompt where you can start typing the same commands as shown as follows during the creation of an ordinary partition in a physical device that is not being used. - -![RHEL 7 Rescue Mode](http://www.tecmint.com/wp-content/uploads/2015/04/RHEL-7-Rescue-Mode.png) - -RHEL 7 Rescue Mode - -To start parted, simply type. - - # parted /dev/sdb - -Where `/dev/sdb` is the device where you will create the new partition; next, type print to display the current drive’s partition table: - -![Creat New Partition](http://www.tecmint.com/wp-content/uploads/2015/04/Create-New-Partition.png) - -Creat New Partition - -As you can see, in this example we are using a virtual drive of 5 GB. We will now proceed to create a 4 GB primary partition and then format it with the xfs filesystem, which is the default in RHEL 7. - -You can choose from a variety of file systems. You will need to manually create the partition with mkpart and then format it with mkfs.fstype as usual because mkpart does not support many modern filesystems out-of-the-box. - -In the following example we will set a label for the device and then create a primary partition `(p)` on `/dev/sdb`, which starts at the 0% percentage of the device and ends at 4000 MB (4 GB): - -![Set Partition Name in Linux](http://www.tecmint.com/wp-content/uploads/2015/04/Label-Partition.png) - -Label Partition Name - -Next, we will format the partition as xfs and print the partition table again to verify that changes were applied: - - # mkfs.xfs /dev/sdb1 - # parted /dev/sdb print - -![Format Partition in Linux](http://www.tecmint.com/wp-content/uploads/2015/04/Format-Partition-in-Linux.png) - -Format Partition as XFS Filesystem - -For older filesystems, you could use the resize command in parted to resize a partition. Unfortunately, this only applies to ext2, fat16, fat32, hfs, linux-swap, and reiserfs (if libreiserfs is installed). - -Thus, the only way to resize a partition is by deleting it and creating it again (so make sure you have a good backup of your data!). No wonder the default partitioning scheme in RHEL 7 is based on LVM. - -To remove a partition with parted: - - # parted /dev/sdb print - # parted /dev/sdb rm 1 - -![Remove Partition in Linux](http://www.tecmint.com/wp-content/uploads/2015/04/Remove-Partition-in-Linux.png) - -Remove or Delete Partition - -### The Logical Volume Manager (LVM) ### - -Once a disk has been partitioned, it can be difficult or risky to change the partition sizes. For that reason, if we plan on resizing the partitions on our system, we should consider the possibility of using LVM instead of the classic partitioning system, where several physical devices can form a volume group that will host a defined number of logical volumes, which can be expanded or reduced without any hassle. - -In simple terms, you may find the following diagram useful to remember the basic architecture of LVM. - -![Basic Architecture of LVM](http://www.tecmint.com/wp-content/uploads/2015/04/LVM-Diagram.png) - -Basic Architecture of LVM - -#### Creating Physical Volumes, Volume Group and Logical Volumes #### - -Follow these steps in order to set up LVM using classic volume management tools. Since you can expand this topic reading the [LVM series on this site][1], I will only outline the basic steps to set up LVM, and then compare them to implementing the same functionality with SSM. - -**Note**: That we will use the whole disks `/dev/sdb` and `/dev/sdc` as PVs (Physical Volumes) but it’s entirely up to you if you want to do the same. - -**1. Create partitions `/dev/sdb1` and `/dev/sdc1` using 100% of the available disk space in /dev/sdb and /dev/sdc:** - - # parted /dev/sdb print - # parted /dev/sdc print - -![Create New Partitions](http://www.tecmint.com/wp-content/uploads/2015/04/Create-New-Partitions.png) - -Create New Partitions - -**2. Create 2 physical volumes on top of /dev/sdb1 and /dev/sdc1, respectively.** - - # pvcreate /dev/sdb1 - # pvcreate /dev/sdc1 - -![Create Two Physical Volumes](http://www.tecmint.com/wp-content/uploads/2015/04/Create-Physical-Volumes.png) - -Create Two Physical Volumes - -Remember that you can use pvdisplay /dev/sd{b,c}1 to show information about the newly created PVs. - -**3. Create a VG on top of the PV that you created in the previous step:** - - # vgcreate tecmint_vg /dev/sd{b,c}1 - -![Create Volume Group in Linux](http://www.tecmint.com/wp-content/uploads/2015/04/Create-Volume-Group.png) - -Create Volume Group - -Remember that you can use vgdisplay tecmint_vg to show information about the newly created VG. - -**4. Create three logical volumes on top of VG tecmint_vg, as follows:** - - # lvcreate -L 3G -n vol01_docs tecmint_vg [vol01_docs → 3 GB] - # lvcreate -L 1G -n vol02_logs tecmint_vg [vol02_logs → 1 GB] - # lvcreate -l 100%FREE -n vol03_homes tecmint_vg [vol03_homes → 6 GB] - -![Create Logical Volumes in LVM](http://www.tecmint.com/wp-content/uploads/2015/04/Create-Logical-Volumes.png) - -Create Logical Volumes - -Remember that you can use lvdisplay tecmint_vg to show information about the newly created LVs on top of VG tecmint_vg. - -**5. Format each of the logical volumes with xfs (do NOT use xfs if you’re planning on shrinking volumes later!):** - - # mkfs.xfs /dev/tecmint_vg/vol01_docs - # mkfs.xfs /dev/tecmint_vg/vol02_logs - # mkfs.xfs /dev/tecmint_vg/vol03_homes - -**6. Finally, mount them:** - - # mount /dev/tecmint_vg/vol01_docs /mnt/docs - # mount /dev/tecmint_vg/vol02_logs /mnt/logs - # mount /dev/tecmint_vg/vol03_homes /mnt/homes - -#### Removing Logical Volumes, Volume Group and Physical Volumes #### - -**7. Now we will reverse the LVM implementation and remove the LVs, the VG, and the PVs:** - - # lvremove /dev/tecmint_vg/vol01_docs - # lvremove /dev/tecmint_vg/vol02_logs - # lvremove /dev/tecmint_vg/vol03_homes - # vgremove /dev/tecmint_vg - # pvremove /dev/sd{b,c}1 - -**8. Now let’s install SSM and we will see how to perform the above in ONLY 1 STEP!** - - # yum update && yum install system-storage-manager - -We will use the same names and sizes as before: - - # ssm create -s 3G -n vol01_docs -p tecmint_vg --fstype ext4 /mnt/docs /dev/sd{b,c}1 - # ssm create -s 1G -n vol02_logs -p tecmint_vg --fstype ext4 /mnt/logs /dev/sd{b,c}1 - # ssm create -n vol03_homes -p tecmint_vg --fstype ext4 /mnt/homes /dev/sd{b,c}1 - -Yes! SSM will let you: - -- initialize block devices as physical volumes -- create a volume group -- create logical volumes -- format LVs, and -- mount them using only one command - -**9. We can now display the information about PVs, VGs, or LVs, respectively, as follows:** - - # ssm list dev - # ssm list pool - # ssm list vol - -![Check Information of PVs, VGs, or LVs](http://www.tecmint.com/wp-content/uploads/2015/04/Display-LVM-Information.png) - -Check Information of PVs, VGs, or LVs - -**10. As we already know, one of the distinguishing features of LVM is the possibility to resize (expand or decrease) logical volumes without downtime.** - -Say we are running out of space in vol02_logs but have plenty of space in vol03_homes. We will resize vol03_homes to 4 GB and expand vol02_logs to use the remaining space: - - # ssm resize -s 4G /dev/tecmint_vg/vol03_homes - -Run ssm list pool again and take note of the free space in tecmint_vg: - -![Check Volume Size](http://www.tecmint.com/wp-content/uploads/2015/04/Check-LVM-Free-Space.png) - -Check Volume Size - -Then do: - - # ssm resize -s+1.99 /dev/tecmint_vg/vol02_logs - -**Note**: that the plus sign after the -s flag indicates that the specified value should be added to the present value. - -**11. Removing logical volumes and volume groups is much easier with ssm as well. A simple,** - - # ssm remove tecmint_vg - -will return a prompt asking you to confirm the deletion of the VG and the LVs it contains: - -![Remove Logical Volume and Volume Group](http://www.tecmint.com/wp-content/uploads/2015/04/Remove-LV-VG.png) - -Remove Logical Volume and Volume Group - -### Managing Encrypted Volumes ### - -SSM also provides system administrators with the capability of managing encryption for new or existing volumes. You will need the cryptsetup package installed first: - - # yum update && yum install cryptsetup - -Then issue the following command to create an encrypted volume. You will be prompted to enter a passphrase to maximize security: - - # ssm create -s 3G -n vol01_docs -p tecmint_vg --fstype ext4 --encrypt luks /mnt/docs /dev/sd{b,c}1 - # ssm create -s 1G -n vol02_logs -p tecmint_vg --fstype ext4 --encrypt luks /mnt/logs /dev/sd{b,c}1 - # ssm create -n vol03_homes -p tecmint_vg --fstype ext4 --encrypt luks /mnt/homes /dev/sd{b,c}1 - -Our next task consists in adding the corresponding entries in /etc/fstab in order for those logical volumes to be available on boot. Rather than using the device identifier (/dev/something). - -We will use each LV’s UUID (so that our devices will still be uniquely identified should we add other logical volumes or devices), which we can find out with the blkid utility: - - # blkid -o value UUID /dev/tecmint_vg/vol01_docs - # blkid -o value UUID /dev/tecmint_vg/vol02_logs - # blkid -o value UUID /dev/tecmint_vg/vol03_homes - -In our case: - -![Find Logical Volume UUID](http://www.tecmint.com/wp-content/uploads/2015/04/Logical-Volume-UUID.png) - -Find Logical Volume UUID - -Next, create the /etc/crypttab file with the following contents (change the UUIDs for the ones that apply to your setup): - - docs UUID=ba77d113-f849-4ddf-8048-13860399fca8 none - logs UUID=58f89c5a-f694-4443-83d6-2e83878e30e4 none - homes UUID=92245af6-3f38-4e07-8dd8-787f4690d7ac none - -And insert the following entries in /etc/fstab. Note that device_name (/dev/mapper/device_name) is the mapper identifier that appears in the first column of /etc/crypttab. - - # Logical volume vol01_docs: - /dev/mapper/docs /mnt/docs ext4 defaults 0 2 - # Logical volume vol02_logs - /dev/mapper/logs /mnt/logs ext4 defaults 0 2 - # Logical volume vol03_homes - /dev/mapper/homes /mnt/homes ext4 defaults 0 2 - -Now reboot (systemctl reboot) and you will be prompted to enter the passphrase for each LV. Afterwards you can confirm that the mount operation was successful by checking the corresponding mount points: - -![Verify Logical Volume Mount Points](http://www.tecmint.com/wp-content/uploads/2015/04/Verify-LV-Mount-Points.png) - -Verify Logical Volume Mount Points - -### Conclusion ### - -In this tutorial we have started to explore how to set up and configure system storage using classic volume management tools and SSM, which also integrates filesystem and encryption capabilities in one package. This makes SSM an invaluable tool for any sysadmin. - -Let us know if you have any questions or comments – feel free to use the form below to get in touch with us! - --------------------------------------------------------------------------------- - -via: http://www.tecmint.com/rhcsa-exam-create-format-resize-delete-and-encrypt-partitions-in-linux/ - -作者:[Gabriel Cánepa][a] -译者:[译者ID](https://github.com/译者ID) -校对:[校对者ID](https://github.com/校对者ID) - -本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 - -[a]:http://www.tecmint.com/author/gacanepa/ -[1]:http://www.tecmint.com/create-lvm-storage-in-linux/ diff --git a/translated/tech/RHCSA/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md b/translated/tech/RHCSA/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md new file mode 100644 index 0000000000..41890b2280 --- /dev/null +++ b/translated/tech/RHCSA/RHCSA Series--Part 06--Using 'Parted' and 'SSM' to Configure and Encrypt System Storage.md @@ -0,0 +1,269 @@ +RHCSA 系列:使用 'Parted' 和 'SSM' 来配置和加密系统存储 – Part 6 +================================================================================ +在本篇文章中,我们将讨论在 RHEL 7 中如何使用传统的工具来设置和配置本地系统存储,并介绍系统存储管理器(也称为 SSM),它将极大地简化上面的任务。 + +![配置和加密系统存储](http://www.tecmint.com/wp-content/uploads/2015/04/Configure-and-Encrypt-System-Storage.png) + +RHCSA: 配置和加密系统存储 – Part 6 + +请注意,我们将在这篇文章中展开这个话题,但由于该话题的宽泛性,我们将在下一期(Part 7)中继续介绍有关它的描述和使用。 + +### 在 RHEL 7 中创建和修改分区 ### + +在 RHEL 7 中, parted 是默认的用来处理分区的程序,且它允许你: + +- 展示当前的分区表 +- 操纵(增加或减少分区的大小)现有的分区 +- 利用空余的磁盘空间或额外的物理存储设备来创建分区 + +强烈建议你在试图增加一个新的分区或对一个现有分区进行更改前,你应当确保设备上没有任何一个分区正在使用(`umount /dev/partition`),且假如你正使用设备的一部分来作为 swap 分区,在进行上面的操作期间,你需要将它禁用(`swapoff -v /dev/partition`) 。 + +实施上面的操作的最简单的方法是使用一个安装介质例如一个 RHEL 7 安装 DVD 或 USB 以急救模式启动 RHEL(Troubleshooting → Rescue a Red Hat Enterprise Linux system),然后当让你选择一个选项来挂载现有的 Linux 安装时,选择'跳过'这个选项,接着你将看到一个命令行提示符,在其中你可以像下图显示的那样开始键入与在一个未被使用的物理设备上创建一个正常的分区时所用的相同的命令。 + +![RHEL 7 急救模式](http://www.tecmint.com/wp-content/uploads/2015/04/RHEL-7-Rescue-Mode.png) + +RHEL 7 急救模式 + +要启动 parted,只需键入: + + # parted /dev/sdb + +其中 `/dev/sdb` 是你将要创建新分区所在的设备;然后键入 `print` 来显示当前设备的分区表: + +![创建新的分区](http://www.tecmint.com/wp-content/uploads/2015/04/Create-New-Partition.png) + +创建新的分区 + +正如你所看到的那样,在这个例子中,我们正在使用一个 5 GB 的虚拟光驱。现在我们将要创建一个 4 GB 的主分区,然后将它格式化为 xfs 文件系统,它是 RHEL 7 中默认的文件系统。 + +你可以从一系列的文件系统中进行选择。你将需要使用 mkpart 来手动地创建分区,接着和平常一样,用 mkfs.fstype 来对分区进行格式化,因为 mkpart 并不支持许多现代的文件系统以达到即开即用。 + +在下面的例子中,我们将为设备设定一个标记,然后在 `/dev/sdb` 上创建一个主分区 `(p)`,它从设备的 0% 开始,并在 4000MB(4 GB) 处结束。 + +![在 Linux 中设定分区名称](http://www.tecmint.com/wp-content/uploads/2015/04/Label-Partition.png) + +标记分区的名称 + +接下来,我们将把分区格式化为 xfs 文件系统,然后再次打印出分区表,以此来确保更改已被应用。 + + # mkfs.xfs /dev/sdb1 + # parted /dev/sdb print + +![在 Linux 中格式化分区](http://www.tecmint.com/wp-content/uploads/2015/04/Format-Partition-in-Linux.png) + +格式化分区为 XFS 文件系统 + +对于旧一点的文件系统,在 parted 中你应该使用 `resize` 命令来改变分区的大小。不幸的是,这只适用于 ext2, fat16, fat32, hfs, linux-swap, 和 reiserfs (若 libreiserfs 已被安装)。 + +因此,改变分区大小的唯一方式是删除它然后再创建它(所以确保你对你的数据做了完整的备份!)。毫无疑问,在 RHEL 7 中默认的分区方案是基于 LVM 的。 + +使用 parted 来移除一个分区,可以用: + + # parted /dev/sdb print + # parted /dev/sdb rm 1 + +![在 Linux 中移除分区](http://www.tecmint.com/wp-content/uploads/2015/04/Remove-Partition-in-Linux.png) + +移除或删除分区 + +### 逻辑卷管理(LVM) ### + +一旦一个磁盘被分好了分区,再去更改分区的大小就是一件困难或冒险的事了。基于这个原因,假如我们计划在我们的系统上对分区的大小进行更改,我们应当考虑使用 LVM 的可能性,而不是使用传统的分区系统。这样多个物理设备可以组成一个逻辑组,以此来寄宿可自定义数目的逻辑卷,而逻辑卷的增大或减少不会带来任何麻烦。 + +简单来说,你会发现下面的示意图对记住 LVM 的基础架构或许有用。 + +![LVM 的基本架构](http://www.tecmint.com/wp-content/uploads/2015/04/LVM-Diagram.png) + +LVM 的基本架构 + +#### 创建物理卷,卷组和逻辑卷 #### + +遵循下面的步骤是为了使用传统的卷管理工具来设置 LVM。由于你可以通过阅读这个网站上的 LVM 系列来扩展这个话题,我将只是概要的介绍设置 LVM 的基本步骤,然后与使用 SSM 来实现相同功能做个比较。 + +**注**: 我们将使用整个磁盘 `/dev/sdb` 和 `/dev/sdc` 来作为 PVs (物理卷),但是否执行相同的操作完全取决于你。 + +**1. 使用 /dev/sdb 和 /dev/sdc 中 100% 的可用磁盘空间来创建分区 `/dev/sdb1` 和 `/dev/sdc1`:** + + # parted /dev/sdb print + # parted /dev/sdc print + +![创建新分区](http://www.tecmint.com/wp-content/uploads/2015/04/Create-New-Partitions.png) + +创建新分区 + +**2. 分别在 /dev/sdb1 和 /dev/sdc1 上共创建 2 个物理卷。** + + # pvcreate /dev/sdb1 + # pvcreate /dev/sdc1 + +![创建两个物理卷](http://www.tecmint.com/wp-content/uploads/2015/04/Create-Physical-Volumes.png) + +创建两个物理卷 + +记住,你可以使用 pvdisplay /dev/sd{b,c}1 来显示有关新建的 PV 的信息。 + +**3. 在上一步中创建的 PV 之上创建一个 VG:** + + # vgcreate tecmint_vg /dev/sd{b,c}1 + +![在 Linux 中创建卷组](http://www.tecmint.com/wp-content/uploads/2015/04/Create-Volume-Group.png) + +创建卷组 + +记住,你可使用 vgdisplay tecmint_vg 来显示有关新建的 VG 的信息。 + +**4. 像下面那样,在 VG tecmint_vg 之上创建 3 个逻辑卷:** + + # lvcreate -L 3G -n vol01_docs tecmint_vg [vol01_docs → 3 GB] + # lvcreate -L 1G -n vol02_logs tecmint_vg [vol02_logs → 1 GB] + # lvcreate -l 100%FREE -n vol03_homes tecmint_vg [vol03_homes → 6 GB] + +![在 LVM 中创建逻辑卷](http://www.tecmint.com/wp-content/uploads/2015/04/Create-Logical-Volumes.png) + +创建逻辑卷 + +记住,你可以使用 lvdisplay tecmint_vg 来显示有关在 VG tecmint_vg 之上新建的 LV 的信息。 + +**5. 格式化每个逻辑卷为 xfs 文件系统格式(假如你计划在以后将要缩小卷的大小,请别使用 xfs 文件系统格式!):** + + # mkfs.xfs /dev/tecmint_vg/vol01_docs + # mkfs.xfs /dev/tecmint_vg/vol02_logs + # mkfs.xfs /dev/tecmint_vg/vol03_homes + +**6. 最后,挂载它们:** + + # mount /dev/tecmint_vg/vol01_docs /mnt/docs + # mount /dev/tecmint_vg/vol02_logs /mnt/logs + # mount /dev/tecmint_vg/vol03_homes /mnt/homes + +#### 移除逻辑卷,卷组和物理卷 #### + +**7.现在我们将进行与刚才相反的操作并移除 LV,VG 和 PV:** + + # lvremove /dev/tecmint_vg/vol01_docs + # lvremove /dev/tecmint_vg/vol02_logs + # lvremove /dev/tecmint_vg/vol03_homes + # vgremove /dev/tecmint_vg + # pvremove /dev/sd{b,c}1 + +**8. 现在,让我们来安装 SSM,我们将看到如何只用一步就完成上面所有的操作!** + + # yum update && yum install system-storage-manager + +我们将和上面一样,使用相同的名称和大小: + + # ssm create -s 3G -n vol01_docs -p tecmint_vg --fstype ext4 /mnt/docs /dev/sd{b,c}1 + # ssm create -s 1G -n vol02_logs -p tecmint_vg --fstype ext4 /mnt/logs /dev/sd{b,c}1 + # ssm create -n vol03_homes -p tecmint_vg --fstype ext4 /mnt/homes /dev/sd{b,c}1 + +是的! SSM 可以让你: + +- 初始化块设备来作为物理卷 +- 创建一个卷组 +- 创建逻辑卷 +- 格式化 LV 和 +- 只使用一个命令来挂载它们 + +**9. 现在,我们可以使用下面的命令来展示有关 PV,VG 或 LV 的信息:** + + # ssm list dev + # ssm list pool + # ssm list vol + +![检查有关 PV, VG,或 LV 的信息](http://www.tecmint.com/wp-content/uploads/2015/04/Display-LVM-Information.png) + +检查有关 PV, VG,或 LV 的信息 + +**10. 正如我们知道的那样, LVM 的一个显著的特点是可以在不停机的情况下更改(增大或缩小) 逻辑卷的大小:** + +假定在 vol02_logs 上我们用尽了空间,而 vol03_homes 还留有足够的空间。我们将把 vol03_homes 的大小调整为 4 GB,并使用剩余的空间来扩展 vol02_logs: + + # ssm resize -s 4G /dev/tecmint_vg/vol03_homes + +再次运行 `ssm list pool`,并记录 tecmint_vg 中的剩余空间的大小: + +![查看卷的大小](http://www.tecmint.com/wp-content/uploads/2015/04/Check-LVM-Free-Space.png) + +查看卷的大小 + +然后执行: + + # ssm resize -s+1.99 /dev/tecmint_vg/vol02_logs + +**注**: 在 `-s` 后的加号暗示特定值应该被加到当前值上。 + +**11. 使用 ssm 来移除逻辑卷和卷组也更加简单,只需使用:** + + # ssm remove tecmint_vg + +这个命令将返回一个提示,询问你是否确认删除 VG 和它所包含的 LV: + +![移除逻辑卷和卷组](http://www.tecmint.com/wp-content/uploads/2015/04/Remove-LV-VG.png) + +移除逻辑卷和卷组 + +### 管理加密的卷 ### + +SSM 也给系统管理员提供了为新的或现存的卷加密的能力。首先,你将需要安装 cryptsetup 软件包: + + # yum update && yum install cryptsetup + +然后写出下面的命令来创建一个加密卷,你将被要求输入一个密码来增强安全性: + + # ssm create -s 3G -n vol01_docs -p tecmint_vg --fstype ext4 --encrypt luks /mnt/docs /dev/sd{b,c}1 + # ssm create -s 1G -n vol02_logs -p tecmint_vg --fstype ext4 --encrypt luks /mnt/logs /dev/sd{b,c}1 + # ssm create -n vol03_homes -p tecmint_vg --fstype ext4 --encrypt luks /mnt/homes /dev/sd{b,c}1 + +我们的下一个任务是往 /etc/fstab 中添加条目来让这些逻辑卷在启动时可用,而不是使用设备识别编号(/dev/something)。 + +我们将使用每个 LV 的 UUID (使得当我们添加其他的逻辑卷或设备后,我们的设备仍然可以被唯一的标记),而我们可以使用 blkid 应用来找到它们的 UUID: + + # blkid -o value UUID /dev/tecmint_vg/vol01_docs + # blkid -o value UUID /dev/tecmint_vg/vol02_logs + # blkid -o value UUID /dev/tecmint_vg/vol03_homes + +在我们的例子中: + +![找到逻辑卷的 UUID](http://www.tecmint.com/wp-content/uploads/2015/04/Logical-Volume-UUID.png) + +找到逻辑卷的 UUID + +接着,使用下面的内容来创建 /etc/crypttab 文件(请更改 UUID 来适用于你的设置): + + docs UUID=ba77d113-f849-4ddf-8048-13860399fca8 none + logs UUID=58f89c5a-f694-4443-83d6-2e83878e30e4 none + homes UUID=92245af6-3f38-4e07-8dd8-787f4690d7ac none + +然后在 /etc/fstab 中添加如下的条目。请注意到 device_name (/dev/mapper/device_name) 是出现在 /etc/crypttab 中第一列的映射标识: + + # Logical volume vol01_docs: + /dev/mapper/docs /mnt/docs ext4 defaults 0 2 + # Logical volume vol02_logs + /dev/mapper/logs /mnt/logs ext4 defaults 0 2 + # Logical volume vol03_homes + /dev/mapper/homes /mnt/homes ext4 defaults 0 2 + +现在重启(systemctl reboot),则你将被要求为每个 LV 输入密码。随后,你可以通过检查相应的挂载点来确保挂载操作是否成功: + +![确保逻辑卷挂载点](http://www.tecmint.com/wp-content/uploads/2015/04/Verify-LV-Mount-Points.png) + +确保逻辑卷挂载点 + +### 总结 ### + +在这篇教程中,我们开始探索如何使用传统的卷管理工具和 SSM 来设置和配置系统存储,SSM 也在一个软件包中集成了文件系统和加密功能。这使得对于任何系统管理员来说,SSM 是一个非常有价值的工具。 + +假如你有任何的问题或评论,请让我们知晓 – 请随意使用下面的评论框来与我们保存联系! + +-------------------------------------------------------------------------------- + +via: http://www.tecmint.com/rhcsa-exam-create-format-resize-delete-and-encrypt-partitions-in-linux/ + +作者:[Gabriel Cánepa][a] +译者:[FSSlc](https://github.com/FSSlc) +校对:[校对者ID](https://github.com/校对者ID) + +本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创翻译,[Linux中国](https://linux.cn/) 荣誉推出 + +[a]:http://www.tecmint.com/author/gacanepa/ +[1]:http://www.tecmint.com/create-lvm-storage-in-linux/