您好,登錄后才能下訂單哦!
這篇文章主要講解了“Linux系統(tǒng)磁盤的知識點(diǎn)有哪些”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Linux系統(tǒng)磁盤的知識點(diǎn)有哪些”吧!
目前市場上的磁盤分類有:IDE磁盤(多用于PC機(jī))、SATA磁盤、SAS磁盤、SSD磁盤等這么幾種分類,企業(yè)中服務(wù)器大多為后面的兩種,SATA磁盤多用于企業(yè)內(nèi)部的一些業(yè)務(wù)、SAS磁盤多用于對外的業(yè)務(wù)(一些業(yè)務(wù)平臺)。
SATA磁盤目前容量最大為4T、SAS磁盤一般都在300G–600G居多,企業(yè)生產(chǎn)環(huán)境中使用也最多的是這種容量的,實(shí)際生產(chǎn)中磁盤的使用主要是看性能需求,也就是磁盤的讀寫速度。
企業(yè)級服務(wù)器多塊磁盤的情況
磁盤的結(jié)構(gòu)一般包括磁道、盤面、扇區(qū)、碰頭等
一個磁道的大小=512 字節(jié)*扇區(qū)數(shù)
一個盤面的大小=磁道的大小*磁道數(shù)
一個磁盤的大小=盤面大小*磁頭數(shù)
因此,一個磁盤的容量=512 字節(jié)扇區(qū)數(shù)磁道數(shù)*磁頭數(shù)
所有磁盤的分區(qū)信息都是存儲在分區(qū)表中,Linux系統(tǒng)僅支持4個分區(qū)表信息(主分區(qū)+擴(kuò)展分區(qū)),一個分區(qū)表的大小在64bytes
Linux一般分為三個分區(qū)分別是:boot分區(qū)、swap分區(qū)、/根分區(qū)
Linux的分區(qū)編號:主分區(qū)1-4,邏輯分區(qū)從5開始計算
實(shí)際生產(chǎn)環(huán)境分區(qū)要求
1、 最少要有/和swap兩個分區(qū)
2、 swap(虛擬內(nèi)存)=1.5*物理內(nèi)存大小,一般大小于或等于16G的物理內(nèi)存的服務(wù)器,swap分區(qū)一般都直接設(shè)置為16G大小
3、 建議設(shè)置/boot分區(qū),Linux引導(dǎo)分區(qū),如內(nèi)核文件等,一般所有文件一共才幾十M的大小,因此這個分區(qū)就設(shè)置為100-200M即可
fdisk是針對磁盤容量小于2T
[root@cairui ~]# fdisk --helpfdisk: invalid option -- '-'fdisk: Usage: fdisk [options] change partition table fdisk [options] -l list partition table(s) fdisk -s give partition size(s) in blocks Options: -b sector size (512, 1024, 2048 or 4096) -c switch off DOS-compatible mode -h print help-u give sizes in sectors instead of cylinders -v print version -C specify the number of cylinders -H specify the number of heads -S specify the number of sectors per track : Success
[root@localhost ~]# fdisk /dev/sda1 #對/dev/sda1進(jìn)行分區(qū)操作Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel with disk identifier 0x02fadd9c. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u'). Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition #刪除一個分區(qū)l list known partition types m print this menu n add a new partition #新建一個分區(qū)o create a new empty DOS partition table p print the partition table #打印出分區(qū)表信息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 #將分區(qū)信息寫入分區(qū)表并退出程序 x extra functionality (experts only) Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-2610, default 1): 設(shè)置起始柱面 Using default value 1 Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610): 設(shè)置大小或柱面 Using default value 2610 Command (m for help): m Command action a toggle a bootable flag b edit bsd disklabel c toggle the dos compatibility flag d delete a partition 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 exitx extra functionality (experts only) Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. Command (m for help): p 打印分區(qū)表信息 Disk /dev/sdb: 21.5 GB, 21474836480 bytes 255 heads, 63 sectors/track, 2610 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes 121 / 753 I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xb712cc55 Device Boot Start End Blocks Id System /dev/sdb1 1 2610 20964793+ 83 Linux 分區(qū)完成后執(zhí)行 partprobe 通知系統(tǒng)分區(qū)表發(fā)生改變 接下來進(jìn)行格式化分區(qū) [root@Centos ~]# mkfs.ext3 /dev/sdb1mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1310720 inodes, 5241198 blocks 262059 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=4294967296 160 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Writing inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 24 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@Centos ~]# tune2fs -c -1 /dev/sdb1tune2fs 1.41.12 (17-May-2010) Setting maximal mount count to -1 [root@Centos ~]# mount /dev/sdb1 /mnt 掛載分區(qū)至/mnt 下[root@Centos ~]# df -hFilesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 50G 3.5G 44G 8% / tmpfs 932M 0 932M 0% /dev/shm /dev/sda1 485M 39M 421M 9% /boot 122 / 753 /dev/mapper/VolGroup-lv_home 26G 215M 24G 1% /home /dev/sdb1 20G 172M 19G 1% /mnt
由于環(huán)境限制無法有2T或者以上大小的磁盤,只能模擬環(huán)境來使用parted分區(qū)工具來進(jìn)行分區(qū)
[root@Centos ~]# parted /dev/sdb mklabel gpt將磁盤轉(zhuǎn)換成 gpt 的格式 [root@Centos ~]# parted /dev/sdb mkpart primary 0 200(200M)Warning: The resulting partition is not properly aligned for best performance. Ignore/Cancel? Ignore [root@Centos ~]# parted /dev/sdb p 打印分區(qū)表信息Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 200MB 200MB primary [root@Centos ~]# parted /dev/sdb mkpart primary 201 1073分區(qū)并設(shè)置大小 Information: You may need to update /etc/fstab. [root@Centos ~]# parted /dev/sdb p 打印分區(qū)表信息Model: VMware, VMware Virtual S (scsi) Disk /dev/sdb: 1074MB Sector size (logical/physical): 512B/512B Partition Table: gpt Number Start End Size File system Name Flags 1 17.4kB 200MB 200MB primary 2 201MB 1073MB 871MB primary [root@Centos ~]# mkfs.ext4 /dev/sdb1mke2fs 1.41.12 (17-May-2010) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 123 / 753 Stride=0 blocks, Stripe width=0 blocks 48960 inodes, 195296 blocks 9764 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 24 block groups 8192 blocks per group, 8192 fragments per group 2040 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729 Writing inode tables: doneCreating journal (4096 blocks): doneWriting superblocks and filesystem accounting information: doneThis filesystem will be automatically checked every 36 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@Centos ~]# tune2fs -c -1 /dev/sdb1tune2fs 1.41.12 (17-May-2010) Setting maximal mount count to -1 [root@Centos ~]# mount /dev/sdb1 /mnt[root@Centos ~]# df -hFilesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 50G 3.5G 44G 8% / tmpfs 932M 0 932M 0% /dev/shm /dev/sda1 485M 39M 421M 9% /boot /dev/mapper/VolGroup-lv_home 26G 215M 24G 1% /home /dev/sdb1 185M 5.6M 170M 4% /mnt [root@cairui ~]# parted --helpUsage: parted [OPTION]... [DEVICE [COMMAND [PARAMETERS]...]...] Apply COMMANDs with PARAMETERS to DEVICE. If no COMMAND(s) are given, run ininteractive mode. OPTIONs: -h, --help displays this help message -l, --list lists partition layout on all block devices -m, --machine displays machine parseable output -s, --script never prompts for user intervention -v, --version displays the version -a, --align=[none|cyl|min|opt] alignment for new partitions COMMANDs: align-check TYPE N check partition N for TYPE(min|opt) alignment check NUMBER do a simple check on the file system cp [FROM-DEVICE] FROM-NUMBER TO-NUMBER copy file system to another partitionhelp [COMMAND] print general help, or help on COMMAND mklabel,mktable LABEL-TYPE create a new disklabel (partition table) mkfs NUMBER FS-TYPE make a FS-TYPE file system on partition NUMBER mkpart PART-TYPE [FS-TYPE] START END make a partition mkpartfs PART-TYPE FS-TYPE START END make a partition with a file system move NUMBER START END move partition NUMBER name NUMBER NAME name partition NUMBER as NAMEprint [devices|free|list,all|NUMBER] display the partition table, available devices, free space, all found partitions, or a particular partition quit exit program rescue START END rescue a lost partition near START and END resize NUMBER START END resize partition NUMBER and its file system rm NUMBER delete partition NUMBER select DEVICE choose the device to editset NUMBER FLAG STATE change the FLAG on partition NUMBER toggle [NUMBER [FLAG]] toggle the state of FLAG on partition NUMBER unit UNIT set the default unit to UNIT version display the version number and copyright information of GNU Parted
感謝各位的閱讀,以上就是“Linux系統(tǒng)磁盤的知識點(diǎn)有哪些”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Linux系統(tǒng)磁盤的知識點(diǎn)有哪些這一問題有了更深刻的體會,具體使用情況還需要大家實(shí)踐驗(yàn)證。這里是億速云,小編將為大家推送更多相關(guān)知識點(diǎn)的文章,歡迎關(guān)注!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。