linux---系统分区管理,划分分区,GPT分区方式,swap分区挂载,磁盘加密,磁盘阵列,设备管理

系统分区管理

df <= blkid < cat /proc/partitions < fdisk -l
df ##查看系统正在使用的设备
blkid ##查看系统里面可以使用的设备
cat /proc/partitions ##查看系统识别的设备
fdisk -l ##查看硬盘
df -h ##2的n次方,1024
df -H ##10的n次方 1000 -h比-H统计出来的数小,但是精确


在真机里做以下实验:

硬盘的挂载卸载

先插入U盘,用df查看有/dev/sdb1 –>u盘

[root@foundation68 ~]# umount /dev/sdb1/    ##卸载u盘
[root@foundation68 ~]# mount /dev/sdb1 /mnt/    ##将u盘挂载到/mnt下
[root@foundation68 ~]# cd /mnt

再打开一个shell

[root@foundation68 ~]# umount /dev/sdb1/    ##卸载u盘
[root@foundation68 ~]# mount /dev/sdb1 /mnt/    ##将u盘挂载到/mnt下
[root@foundation68 ~]# cd /mnt
另开一个shell
[root@foundation68 ~]# umount /dev/sdb1/
umount: /mnt: target is busy.                   ##u盘正在运行,卸载不掉
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
[root@foundation28 ~]# fuser -kvm /dev/sdb1/    ##杀死后台运行
                     USER        PID ACCESS COMMAND
/dev/sdb1:           root     kernel mount /mnt
                     root       9277 ..c.. bash
[root@foundation68 ~]# umount /dev/sdb1   ##现在就可以卸载了

切换到第一个shell
[root@foundation68 mnt]# Killed ##进程已经被杀死

[root@foundation68 ~]# fuser -vm /dev/sdb1/  ##查看
                     USER        PID ACCESS COMMAND
/dev/sdb1:           root     kernel mount /run/media/kiosk/00A4-2CBF

指定设备激活或更改

[root@foundation68 ~]# mount -o ro /dev/sdb1 /mnt/ ##mount -o添加参数
[root@foundation68 ~]# touch /mnt/file1
touch: cannot touch ‘/mnt/file1’: Read-only file system

用mount查看为ro不能建立文件只读

[root@foundation68 ~]# umount /dev/sdb1
[root@foundation68 ~]# mount -o rw /dev/sdb1 /mnt/

用mount查看为rw可以建立文件为可写


划分分区

以下实验步骤需在虚拟机server里完成:

[root@localhost ~]# fdisk /dev/vdb    ####打开划分分区界面
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x55916b15.

Command (m for help): m     ####获得帮助
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition    ##删除分区
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition    ##新建分区
   o   create a new empty DOS partition table
   p   print the partition table   ##显示分区表信息
   q   quit without saving changes   ##退出
   s   create a new empty Sun disklabel
   t   change a partition's system id    ##修改分区id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit   ##将当前操作写入硬盘分区表
   x   extra functionality (experts only)
Command (m for help): n     ##创建分区
Partition type:            ##创建分区类型
   p   primary (0 primary, 0 extended, 4 free)    ##主分区
   e   extended      ##扩展分区
Select (default p): p   
Partition number (1-4, default 1): 1     ##确定主分区id
First sector (2048-20971519, default 2048):  ##分区起始块的位置,默认
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519): +100M    ##分区结束位置,用+大小的方式指定
Partition 1 of type Linux and of size 100 MiB is set

重复以上步骤

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值