Welcome 微信登录

首页 / 操作系统 / Linux / RHEL6 cryptsetup 磁盘分区加密实验

LUKS是为Linux硬盘加密标准。通过提供一个标准的磁盘上的格式,它不仅方便之间分布的兼容性,而且还提供了多个用户密码的安全管理。必须首先对加密的卷进行解密,才能挂载其中的文件系统。系统加密:【工具:cryptsetup;常用参数:luksFormat、luksOpen、luksClose、luksAddKey】【涉及文件:/etc/crypttab;自己创建密码文件】注意:上述参数大小写不能乱用好了,来试试这个强大的工具吧~一、划出一个分区进行测试(fdisk)--->这里以我的机子为例,因为我把空间全做成lvm了,所以分区就不一样啦,我们取300M做实验吧。[root@www.linuxidc.com Desktop]# vgdisplay   --- Volume group ---  VG Name               vol0  System ID               Format                lvm2  Metadata Areas        2  Metadata Sequence No  27  VG Access             read/write  VG Status             resizable  MAX LV                0  Cur LV                4  Open LV               3  Max PV                0  Cur PV                2  Act PV                2  VG Size               55.22 GiB  PE Size               32.00 MiB  Total PE              1767  Alloc PE / Size       928 / 29.00 GiB  Free  PE / Size       839 / 26.22 GiB (还26G,够了吧,我只需要300M做实验)  VG UUID               ZAGsPK-tIBO-08bd-RoMp-fPeC-Ei5l-x3asx6 [root@www.linuxidc.com Desktop]# lvcreate -L 300M -n testlv /dev/vol0   Rounding up size to full physical extent 320.00 MiB  Logical volume "testlv" created
--->ok,生成testlv分区,320M(跟PE有关)
 
二、分区加密(cryptsetup luksFormat,注意分区先不要格式化!)
[root@www.linuxidc.com Desktop]# cryptsetup luksFormat /dev/vol0/testlv  WARNING!========This will overwrite data on /dev/vol0/testlv irrevocably. Are you sure? (Type uppercase yes): YES (注意,只能是大写字母)Enter LUKS passphrase:  (输入密码)Verify passphrase:  (确认密码)
三、好了,密码创建好了,我们解密了把它格式化一下吧,格式化了才能挂载呀。(不解密的话是不能对它进行操作的)
1、[root@www.linuxidc.com Desktop]# cryptsetup luksOpen /dev/vol0/testlv testlvEnter passphrase for /dev/vol0/testlv:  (输入密码进行验证!)--->注意,命令最后写了一个映射的设备名“testlv”,来看看吧
[root@www.linuxidc.com Desktop]# ll /dev/mapper/testlv  /dev/vol0/testlv lrwxrwxrwx. 1 root root 7 Aug  4 15:17 /dev/mapper/testlv -> ../dm-7lrwxrwxrwx. 1 root root 7 Aug  4 15:17 /dev/vol0/testlv -> ../dm-6--->两个其实是同一个的。命令中必须得加上映射的名称,可以自己man一下cryptsetup
2、[root@www.linuxidc.com Desktop]# mkfs.ext4 /dev/mapper/testlv mke2fs 1.41.12 (17-May-2010)Filesystem label=OS type: LinuxBlock size=1024 (log=0)Fragment size=1024 (log=0)Stride=0 blocks, Stripe width=0 blocks81600 inodes, 325632 blocks16281 blocks (5.00%) reserved for the super userFirst data block=1Maximum filesystem blocks=6763315240 block groups8192 blocks per group, 8192 fragments per group2040 inodes per groupSuperblock backups stored on blocks:  8193, 24577, 40961, 57345, 73729, 204801, 221185 Writing inode tables: done                            Creating journal (8192 blocks): doneWriting superblocks and filesystem accounting information: done This filesystem will be automatically checked every 37 mounts or180 days, whichever comes first.  Use tune2fs -c or -i to override.--->ok,很快就格式化好了,那就新建一个目录挂载吧!
3、[root@www.linuxidc.com Desktop]# mkdir /testlv[root@www.linuxidc.com Desktop]# mount /dev/mapper/testlv /testlv/[root@www.linuxidc.com Desktop]# df -h /testlv/Filesystem            Size  Used Avail Use% Mounted on/dev/mapper/testlv    308M   11M  283M   4% /testlv--->想要开机自动挂载?写道fstable里吧[root@www.linuxidc.com Desktop]# vim /etc/fstab  (加上这一行)/dev/mapper/testlv      /testlv                 ext4    defaults        0 0【就这样重启是不会挂载上的,为什么? 没有写入配置文件告诉系统我有加密分区。好,再继续测试】
  • 1
  • 2
  • 下一页
RHEL6 snapshot 快照原理及实验CentOS 6.0安装RPMforge源相关资讯      RHEL6 
  • 在 RHEL6 上安装 Java  (02/05/2015 13:44:10)
  • RHEL6文字界面安装Gnome桌面  (11/30/2013 08:54:03)
  • RHCE认证之RHEL6进程管理、Cron任  (10/22/2013 11:45:06)
  • Red Hat Enterprise Linux 6.6 正  (10/15/2014 08:05:33)
  • RedHat Enterprise Linux 6.X系统  (10/25/2013 08:42:03)
  • Red Hat Enterprise Linux 6最新测  (10/15/2013 15:53:30)
本文评论 查看全部评论 (0)
表情: 姓名: 字数