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規則詳解