一塊1TB的硬盤,用作samba共享,在安裝系統時分區如下:
/boot 2048M swap 512M / 229GB 剩下約 700GB左右未使用空間,在安裝完系統后再使用
以下是詳細操作,就幾個步驟,很簡單
[root@SZMT-SERVER ~]# fdisk -l #<===查看磁盤使用情況
磁盤 /dev/sda:1000.2 GB, 1000204886016 字節,1953525168 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標簽類型:dos
磁盤標識符:0x000c868c
設備 Boot Start End Blocks Id System
/dev/sda1 * 2048 4196351 2097152 83 Linux
/dev/sda2 4196352 485525503 240664576 8e Linux LVM
磁盤 /dev/mapper/centos-root:245.9 GB, 245895266304 字節,480264192 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤 /dev/mapper/centos-swap:536 MB, 536870912 字節,1048576 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
[root@SZMT-SERVER samba]# df -lh
文件系統 容量 已用 可用 已用% 掛載點
/dev/mapper/centos-root 229G 1.7G 228G 1% /
devtmpfs 2.0G 0 2.0G 0% /dev
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 2.0G 8.7M 2.0G 1% /run
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 2.0G 131M 1.9G 7% /boot
tmpfs 394M 0 394M 0% /run/user/0
[root@SZMT-SERVER samba]# fdisk /dev/sda #<===fdisk命令很簡單
歡迎使用 fdisk (util-linux 2.23.2)。
更改將停留在內存中,直到您決定將更改寫入磁盤。
使用寫入命令前請三思。
命令(輸入 m 獲取幫助):m
命令操作
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
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
命令(輸入 m 獲取幫助):p
磁盤 /dev/sda:1000.2 GB, 1000204886016 字節,1953525168 個扇區
Units = 扇區 of 1 * 512 = 512 bytes
扇區大小(邏輯/物理):512 字節 / 512 字節
I/O 大小(最小/最佳):512 字節 / 512 字節
磁盤標簽類型:dos
磁盤標識符:0x000c868c
設備 Boot Start End Blocks Id System
/dev/sda1 * 2048 4196351 2097152 83 Linux
/dev/sda2 4196352 485525503 240664576 8e Linux LVM
命令(輸入 m 獲取幫助):n
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
分區號 (3,4,默認 3):3 #<===以下步驟默認即將所有未使用空間划分給3
起始 扇區 (485525504-1953525167,默認為 485525504):
將使用默認值 485525504
Last 扇區, +扇區 or +size{K,M,G} (485525504-1953525167,默認為 1953525167):
將使用默認值 1953525167
分區 3 已設置為 Linux 類型,大小設為 700 GiB
命令(輸入 m 獲取幫助):w #<===保存退出
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 設備或資源忙.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
正在同步磁盤。
[root@SZMT-SERVER ~]# partprobe #<===關鍵命令,通知內核
[root@SZMT-SERVER ~]# mkfs -t xfs /dev/sda3 #<===格式化
meta-data=/dev/sda3 isize=512 agcount=4, agsize=45874990 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=183499958, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=89599, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@SZMT-SERVER ~]# mkdir /data
[root@SZMT-SERVER ~]# mount /dev/sda3 /data
[root@SZMT-SERVER ~]# df -l
文件系統 1K-塊 已用 可用 已用% 掛載點
/dev/mapper/centos-root 240014844 1687476 238327368 1% /
devtmpfs 2001036 0 2001036 0% /dev
tmpfs 2013560 0 2013560 0% /dev/shm
tmpfs 2013560 8848 2004712 1% /run
tmpfs 2013560 0 2013560 0% /sys/fs/cgroup
/dev/sda1 2086912 133196 1953716 7% /boot
tmpfs 402712 0 402712 0% /run/user/0
/dev/sda3 733641436 32944 733608492 1% /data
[root@SERVER1 ~]# cat /etc/fstab #<==保存至開機自動掛載
#
# /etc/fstab
# Created by anaconda on Wed Feb 15 09:40:26 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=0bdf1908-f065-4045-b6db-4b55e990cd0a / ext3 defaults 1 1
UUID=4a6701cf-4ad5-4011-b7c2-73d40a757a1d swap swap defaults 0 0
/dev/sda3 /data xfs defaults 0 0