CentOS Linux下的3款分区工具详解
[root@TianRandai ~]#fdisk /dev/sdb
#对/dev/sdb进行操作 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.
Command (m for help): n #建立一个分区
Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p #分区类型为主分区,p是主分区,e是扩展分区
Partition number (1-4, default 1): 1 #指定分区号 First sector (2048-41943039, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +2G Partition 1 of type Linux and of size 2 GiB is set
Command (m for help): t #指定分区标记类型
Selected partition 1 Hex code (type L to list all codes): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris' Command (m for help): w #保存操作
The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.
[root@TianRandai ~]#parted /dev/sdb mklabel gpt #指定磁盘模式为GPT
Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? yes
Information: You may need to update /etc/fstab.
[root@TianRandai ~]#parted /dev/sdb mkpart primary 0 2G #创建分区,分区类型为主分区,大小为2G
Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? i Information: You may need to update /etc/fstab.
[root@TianRandai ~]#parted /dev/sdb print #查看磁盘信息
Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags 1 17.4kB 2000MB 2000MB primary
[root@TianRandai ~]#parted /dev/sdb rm 1 #删除分区1
Information: You may need to update /etc/fstab.
[root@TianRandai ~]#parted /dev/sdb print #再次查看磁盘信息
Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 21.5GB Sector size (logical/physical): 512B/512B Partition Table: gpt Disk Flags: Number Start End Size File system Name Flags
[root@TianRandai ~]#mkfs #文件系统的各个类型 mkfs
mkfs.cramfs mkfs.ext3 mkfs.fat mkfs.msdos mkfs.xfs mkfs.btrfs mkfs.ext2 mkfs.ext4 mkfs.minix mkfs.vfat [root@TianRandai ~]#mkfs.ext4 /dev/sdb1 #将/dev/sdb1格式化为ext4
[root@TianRandai ~]#mkdir /mnt/disk1 #在/mnt/下建一个disk1目录
[root@TianRandai ~]#mount /dev/sdb1 /mnt/disk1 #将格式化号的分区挂载到/mnt/disk1撒花姑娘
[root@TianRandai ~]#df -h #查看挂载及使用情况 Filesystem
Size Used Avail Use% Mounted on /dev/sda2
10G 4.5G 5.5G 45% / devtmpfs 898M 0
898M 0% /dev tmpfs
912M 88K 912M 1% /dev/shm tmpfs
912M 9.0M 903M 1% /run tmpfs
912M 0 912M 0% /sys/fs/cgroup /dev/sda1
1014M 169M 846M 17% /boot tmpfs
183M 20K 183M 1% /run/user/0 /dev/sdb1
1.9G 5.7M 1.7G 1% /mnt/disk1
新文章:
- CentOS7下图形配置网络的方法
- CentOS 7如何添加删除用户
- 如何解决centos7双系统后丢失windows启动项
- CentOS单网卡如何批量添加不同IP段
- CentOS下iconv命令的介绍
- Centos7 SSH密钥登陆及密码密钥双重验证详解
- CentOS 7.1添加删除用户的方法
- CentOS查找/扫描局域网打印机IP讲解
- CentOS7使用hostapd实现无AP模式的详解
- su命令不能切换root的解决方法
- 解决VMware下CentOS7网络重启出错
- 解决Centos7双系统后丢失windows启动项
- CentOS下如何避免文件覆盖
- CentOS7和CentOS6系统有什么不同呢
- Centos 6.6默认iptable规则详解