[root@oldboyedu ~]# parted /dev/sdb #交互式開始分區(qū)
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) help
(parted) mklabel gpt? #修改分區(qū)格式為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? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
(parted) p? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt? #修改結(jié)果
(parted) mkpart primary 0 480? #創(chuàng)建第一個(gè)主分區(qū)480M。
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? Ignore #忽略提示。? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
(parted) mkpart primary 481 580 #創(chuàng)建第二個(gè)主分區(qū)100M赞厕。
Warning: You requested a partition from 481MB to 580MB (sectors 939453..1132812).
The closest location we can manage is 481MB to 481MB (sectors 940031..940031).
Is this still acceptable to you?
Yes/No? Y? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Warning: The resulting partition is not properly aligned for best performance.
Ignore/Cancel? I #忽略提示。? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
(parted) mkpart logic 581 600 #創(chuàng)建一個(gè)20M邏輯分區(qū)式镐。
(parted) p? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdb: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:
Number? Start? End? ? Size? ? File system? Name? ? Flags
1? ? ? 17.4kB? 480MB? 480MB? ? ? ? ? ? ? ? primary
3? ? ? 481MB? 481MB? 512B? ? ? ? ? ? ? ? primary
2? ? ? 481MB? 580MB? 98.6MB? ? ? ? ? ? ? primary
4? ? ? 581MB? 600MB? 18.9MB? ? ? ? ? ? ? logic
(parted) rm 4? #刪除? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
(parted) p? ? ? ? ? ? ? ? ? ? ? ?
問題需求:剛買的服務(wù)器? 4塊2T剛買的,要做raid5,裝系統(tǒng)怎么搞定?
方法1辽社、raid里可以支持raid5后,6T衡奥,允許你把6T分成虛擬磁盤爹袁。
? ? 200G分成第一個(gè)虛擬磁盤剩下不分留著裝系統(tǒng)后(parted)。
方法2矮固、裝系統(tǒng)過程中有這個(gè)功能,系統(tǒng)鏡像支持GPT格式分區(qū),很隱蔽档址。
方法3盹兢、 引導(dǎo)工具,進(jìn)入然后用partwd分區(qū)
生產(chǎn)場景中分區(qū)方案:
4種守伸。
分區(qū)知識:(1)什么是分區(qū)绎秒,為什么要分區(qū)?
(2)磁盤和分區(qū)在Linux里的命名尼摹。
(3)磁盤分區(qū)類型和特點(diǎn):
(4)磁盤分區(qū)工作原理:
(5)磁盤分區(qū)實(shí)戰(zhàn)
(6)生產(chǎn)場景分區(qū)方案:4種见芹。參考前面課程
獲得使用的磁盤過程====買房入住生活的過程
磁盤===房子
raid=====多套房子打通
分區(qū)=========隔斷/幾居室、臥室蠢涝、衛(wèi)生間玄呛、廚房
===============================
文件系統(tǒng)====裝修風(fēng)格
格式化過程====== 裝修過程
掛載========開門,開窗住人
磁盤管理======生活收拾屋子和二,打掃衛(wèi)生
[root@oldboyedu ~]# 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.
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):
First sector (2048-2097151, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +100M
Partition 1 of type Linux and of size 100 MiB is set
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000006b6
? Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System
/dev/sdb1? ? ? ? ? ? 2048? ? ? 206847? ? ? 102400? 83? Linux
Command (m for help): n
Partition type:
? p? primary (1 primary, 0 extended, 3 free)
? e? extended
Select (default p): p
Partition number (2-4, default 2):
First sector (206848-2097151, default 206848):
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-2097151, default 2097151): +100M
Partition 2 of type Linux and of size 100 MiB is set
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000006b6
? Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System
/dev/sdb1? ? ? ? ? ? 2048? ? ? 206847? ? ? 102400? 83? Linux
/dev/sdb2? ? ? ? ? 206848? ? ? 411647? ? ? 102400? 83? Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@oldboyedu ~]# ls -l /dev/sdb*
brw-rw---- 1 root disk 8, 16 Mar 29 11:31 /dev/sdb
brw-rw---- 1 root disk 8, 17 Mar 29 11:31 /dev/sdb1
brw-rw---- 1 root disk 8, 18 Mar 29 11:31 /dev/sdb2
[root@oldboyedu ~]# mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
Stride=0 blocks, Stripe width=0 blocks
25688 inodes, 102400 blocks
5120 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=33685504
13 block groups
8192 blocks per group, 8192 fragments per group
1976 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Allocating group tables: done? ? ? ? ? ? ? ? ? ? ? ? ? ?
Writing inode tables: done? ? ? ? ? ? ? ? ? ? ? ? ? ?
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@oldboyedu ~]# mount -t ext4 /dev/sdb1 /mnt #掛載到/mnt
[root@oldboyedu ~]# df -h #查看掛載結(jié)果
Filesystem? ? ? Size? Used Avail Use% Mounted on
/dev/sda3? ? ? ? 19G? 1.9G? 18G? 10% /
devtmpfs? ? ? ? 980M? 5.0M? 975M? 1% /dev
tmpfs? ? ? ? ? 991M? ? 0? 991M? 0% /dev/shm
tmpfs? ? ? ? ? 991M? 18M? 973M? 2% /run
tmpfs? ? ? ? ? 991M? ? 0? 991M? 0% /sys/fs/cgroup
/dev/sda1? ? ? 253M? 136M? 118M? 54% /boot
tmpfs? ? ? ? ? 199M? ? 0? 199M? 0% /run/user/0
tmpfs? ? ? ? ? 199M? ? 0? 199M? 0% /run/user/1000
/dev/sdb1? ? ? ? 93M? 1.6M? 85M? 2% /mnt #<====已掛載徘铝。
[root@oldboyedu ~]# cat /proc/mounts? #查看掛載結(jié)果
rootfs / rootfs rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
configfs /sys/kernel/config configfs rw,relatime 0 0
/dev/sda3 / xfs rw,relatime,attr2,inode64,noquota 0 0
systemd-1 /proc/sys/fs/binfmt_misc autofs rw,relatime,fd=32,pgrp=1,timeout=0,minproto=5,maxproto=5,direct,pipe_ino=19277 0 0
hugetlbfs /dev/hugepages hugetlbfs rw,relatime 0 0
debugfs /sys/kernel/debug debugfs rw,relatime 0 0
mqueue /dev/mqueue mqueue rw,relatime 0 0
/dev/sda1 /boot xfs rw,relatime,attr2,inode64,noquota 0 0
tmpfs /run/user/0 tmpfs rw,nosuid,nodev,relatime,size=202812k,mode=700 0 0
tmpfs /run/user/1000 tmpfs rw,nosuid,nodev,relatime,size=202812k,mode=700,uid=1000,gid=1000 0 0
/dev/sdb1 /mnt ext4 rw,relatime,data=ordered 0 0 #<====已掛載。
[root@oldboyedu ~]# touch /mnt/oldboy
[root@oldboyedu ~]# ls /mnt
lost+found? oldboy
1.文件系統(tǒng):
什么是文件系統(tǒng)惯吕?
是計(jì)算機(jī)存儲和組織數(shù)據(jù)的方法或者機(jī)制惕它。
2.為什么需要文件系統(tǒng)?
? 磁盤废登,物質(zhì)介質(zhì)淹魄,磁粒子物理元素。硬件需要軟件驅(qū)動(dòng)使用堡距,磁盤需要文件系統(tǒng)驅(qū)動(dòng)甲锡。
? 文件系統(tǒng)實(shí)現(xiàn)通過磁盤管理規(guī)劃,存取數(shù)據(jù)吏颖。
? 3.文件系統(tǒng)都有那些類型搔体?
? ? windows NTFS/ fat32, msdos
Linux? ? 最早期的是ext(2.3.4) 版本升級關(guān)系? ? | Xfs(c7)
4.創(chuàng)建文件系統(tǒng)實(shí)際:
4.文件系統(tǒng)原理(ext文件系統(tǒng))
5.企業(yè)中如何選擇文件系統(tǒng).
6.如何優(yōu)化文件系統(tǒng)半醉?