1.先用fdisk分一个新分区
- [root@server8 ~]# fdisk -cu /dev/vdb
- Command (m for help): d
- Selected partition 1
- Command (m for help): w
- The partition table has been altered!
- Calling ioctl() to re-read partition table.
- Syncing disks.
- [root@server8 ~]# cat /proc/partitions 查看分区表
我们创建了/dev/vdb1,先不要格式化
2,
- [root@server8 ~]# cryptsetup luksFormat /dev/vdb1
- WARNING!
- ========
- This will overwrite data on /dev/vdb1 irrevocably.
- Are you sure? (Type uppercase yes): YES 这里一定要用大写
- Enter LUKS passphrase:
- Verify passphrase:
- [root@server8 ~]# cryptsetup luksOpen /dev/vdb1 yanzhao给vdb1做个映射,映射到yanzhao
- Enter passphrase for /dev/vdb1:
- [root@server8 ~]# mkdir /jiami
3.
- [root@server8 ~]# mkfs -t ext4 /dev/mapper/yanzhao 这个和前面映射名字对应的
- mke2fs 1.41.12 (17-May-2010)
- Filesystem label=
- OS type: Linux
- Block size=1024 (log=0)
- Fragment size=1024 (log=0)
- Stride=0 blocks, Stripe width=0 blocks
- 50800 inodes, 202752 blocks
- 10137 blocks (5.00%) reserved for the super user
- First data block=1
- Maximum filesystem blocks=67371008
- 25 block groups
- 8192 blocks per group, 8192 fragments per group
- 2032 inodes per group
- Superblock backups stored on blocks:
- 8193, 24577, 40961, 57345, 73729
- Writing inode tables: done
- Creating journal (4096 blocks): done
- Writing superblocks and filesystem accounting information: done
- This filesystem will be automatically checked every 22 mounts or
- 180 days, whichever comes first. Use tune2fs -c or -i to override.
- [root@server8 ~]# mount /dev/mapper/yanzhao /jiami/将映射挂载到/jiami目录上
- [root@server8 ~]# cd /jiami/
- [root@server8 jiami]# touch yanzhao 建一个文件
- [root@server8 jiami]# ls
- lost+found yanzhao
- [root@server8 jiami]# ls
- lost+found yanzhao
- [root@server8 ~]# umount /dev/mapper/yanzhao 卸载掉
- [root@server8 ~]# cryptsetup luksClose yanzhao关闭映射
- [root@server8 ~]# cd /jiami
- [root@server8 jiami]# ls我的文件不见来
本文转自 369蓝宝 51CTO博客,原文链接:http://blog.51cto.com/3739387/1128342,如需转载请自行联系原作者