硬碟切割
1.環境
vmware
CentOs 7
SCSI 硬碟兩個2.查看第二顆硬碟
# dmesg | grep sdb [ 1.900292] sd 0:0:2:0: [sdb] 41943040 512-byte logical blocks: (21.4 GB/20.0 GiB) [ 1.900318] sd 0:0:2:0: [sdb] Write Protect is off [ 1.900320] sd 0:0:2:0: [sdb] Mode Sense: 61 00 00 00 [ 1.900365] sd 0:0:2:0: [sdb] Cache data unavailable [ 1.900367] sd 0:0:2:0: [sdb] Assuming drive cache: write through [ 1.900869] sdb: unknown partition table [ 1.901051] sd 0:0:2:0: [sdb] Attached SCSI disk
3.使用 FDISK 初始化新的硬碟
# fdisk /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. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0x6e7f6545. 命令 (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 以獲得說明):n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p 分割區編號 (1-4, default 1): 起初 sector (2048-41943039, 預設 2048): 使用預設值 2048 最後 sector, +sectors 或 +大小{K,M,G} (2048-41943039, 預設 41943039):+3G Partition 1 of type Linux and of size 3 GiB is set 命令 (m 以獲得說明):n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p 分割區編號 (2-4, default 2): 起初 sector (6293504-41943039, 預設 6293504): 使用預設值 6293504 最後 sector, +sectors 或 +大小{K,M,G} (6293504-41943039, 預設 41943039):+10G Partition 2 of type Linux and of size 10 GiB is set 命令 (m 以獲得說明):n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): e 分割區編號 (3,4, default 3): 起初 sector (27265024-41943039, 預設 27265024): 使用預設值 27265024 最後 sector, +sectors 或 +大小{K,M,G} (27265024-41943039, 預設 41943039): 使用預設值 41943039 Partition 3 of type Extended and of size 7 GiB is set 命令 (m 以獲得說明):p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O 大小 (最小/最佳化):512 位元組 / 512 位元組 Disk label type: dos 磁碟識別碼:0x6e7f6545 所用裝置 開機 開始 結束 區塊 識別號 系統 /dev/sdb1 2048 6293503 3145728 83 Linux /dev/sdb2 6293504 27265023 10485760 83 Linux /dev/sdb3 27265024 41943039 7339008 5 Extended 命令 (m 以獲得說明):t 分割區編號 (1-3, default 3): 2 Hex code (type L to list all codes): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris' 命令 (m 以獲得說明):p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O 大小 (最小/最佳化):512 位元組 / 512 位元組 Disk label type: dos 磁碟識別碼:0x6e7f6545 所用裝置 開機 開始 結束 區塊 識別號 系統 /dev/sdb1 2048 6293503 3145728 83 Linux /dev/sdb2 6293504 27265023 10485760 82 Linux swap / Solaris /dev/sdb3 27265024 41943039 7339008 5 Extended 命令 (m 以獲得說明):d 分割區編號 (1-3, default 3): 3 Partition 3 is deleted 命令 (m 以獲得說明):p Disk /dev/sdb: 21.5 GB, 21474836480 bytes, 41943040 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O 大小 (最小/最佳化):512 位元組 / 512 位元組 Disk label type: dos 磁碟識別碼:0x6e7f6545 所用裝置 開機 開始 結束 區塊 識別號 系統 /dev/sdb1 2048 6293503 3145728 83 Linux /dev/sdb2 6293504 27265023 10485760 82 Linux swap / Solaris 命令 (m 以獲得說明):w 分割表已變更! 呼叫 ioctl() 以重新讀取分割表。 同步磁碟。
4.分割完需格式化才能被使用
# mkfs.ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
196608 inodes, 786432 blocks
39321 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=805306368
24 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912
Allocating group tables: done
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
5.掛載
# mkdir -p /home/sdb #掛載的目的地
# df -T #sdb1尚未被掛載
檔案系統 類型 1K-區段 已用 可用 已用% 掛載點
/dev/mapper/centos-root xfs 18307072 1103332 17203740 7% /
devtmpfs devtmpfs 490712 0 490712 0% /dev
tmpfs tmpfs 500668 0 500668 0% /dev/shm
tmpfs tmpfs 500668 6824 493844 2% /run
tmpfs tmpfs 500668 0 500668 0% /sys/fs/cgroup
/dev/sda1 xfs 508588 125088 383500 25% /boot
tmpfs tmpfs 100136 0 100136 0% /run/user/0
# mount /dev/sdb1 /home/sdb/
# df -T
檔案系統 類型 1K-區段 已用 可用 已用% 掛載點
/dev/mapper/centos-root xfs 18307072 1103332 17203740 7% /
devtmpfs devtmpfs 490712 0 490712 0% /dev
tmpfs tmpfs 500668 0 500668 0% /dev/shm
tmpfs tmpfs 500668 6824 493844 2% /run
tmpfs tmpfs 500668 0 500668 0% /sys/fs/cgroup
/dev/sda1 xfs 508588 125088 383500 25% /boot
tmpfs tmpfs 100136 0 100136 0% /run/user/0
/dev/sdb1 ext4 3030800 9216 2847916 1% /home/sdb
5.開機掛載
# vim /etc/fstab /dev/sdb1 /home/sdb1/ ext4 defaults 0 0 #自行新增
留言
張貼留言