新聞中心
隨著計(jì)算機(jī)技術(shù)的不斷發(fā)展,操作系統(tǒng)的種類也越來越多,其中Linux操作系統(tǒng)備受關(guān)注。Linux操作系統(tǒng)作為一種免費(fèi)的、開放源代碼的操作系統(tǒng),具有高度的可定制性和安全性,越來越多的企業(yè)和用戶選擇使用Linux系統(tǒng)。但是,對于初學(xué)者來說,Linux系統(tǒng)中的一些概念仍然比較陌生。本文將為大家解析一個(gè)重要的概念——linux sectors。

雁塔網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián)公司,雁塔網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為雁塔數(shù)千家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\成都外貿(mào)網(wǎng)站建設(shè)公司要多少錢,請找那個(gè)售后服務(wù)好的雁塔做網(wǎng)站的公司定做!
什么是Sector
在計(jì)算機(jī)存儲領(lǐng)域,Sector是指存儲設(shè)備上的最小存儲單元。早期的硬盤驅(qū)動器上,每個(gè)扇區(qū)通常包含512個(gè)字節(jié)(512B),但現(xiàn)代硬盤則通常包含更多的字節(jié)數(shù),并采用了較大的扇區(qū)大小,例如4KB或8KB。扇區(qū)是磁盤上存儲數(shù)據(jù)的基本單位,文件系統(tǒng)中的文件是以一個(gè)或多個(gè)扇區(qū)單元進(jìn)行存儲的。
Linux系統(tǒng)中的Sectors
Linux系統(tǒng)中的Sectors與硬盤上的扇區(qū)是相同的概念。在Linux系統(tǒng)中,Sectors被用來描述文件系統(tǒng)上的扇區(qū)。一個(gè)文件系統(tǒng)通常由許多扇區(qū)組成,這些扇區(qū)則形成了一個(gè)邏輯區(qū)域。在創(chuàng)建新的文件系統(tǒng)或?qū)ΜF(xiàn)有文件系統(tǒng)進(jìn)行管理時(shí),需要使用Sectors來確定數(shù)據(jù)和元數(shù)據(jù)的位置,以確保文件系統(tǒng)的穩(wěn)定性和可靠性。
在Linux系統(tǒng)中,Sectors通常被命名為“sectors”,而相應(yīng)的塊大小則被命名為“blocks”。一個(gè)塊通常包括多個(gè)Sectors,通常有4或8個(gè)Sectors組成一個(gè)塊,因此在Linux系統(tǒng)中,Sectors和塊是密切相關(guān)的概念。
Sectors在Linux系統(tǒng)中的表現(xiàn)形式
Sectors在Linux系統(tǒng)中的表現(xiàn)形式通常是一個(gè)數(shù)字,用來描述文件系統(tǒng)上的扇區(qū)位置。在Linux的文件系統(tǒng)中,扇區(qū)序號從0開始,依次遞增。因此,在一個(gè)典型的Linux文件系統(tǒng)中,扇區(qū)序號可以達(dá)到數(shù)十億個(gè)。
在Linux系統(tǒng)中,可以使用許多不同的工具來查看文件系統(tǒng)中的Sectors。例如,可以使用命令“fdisk”來查看硬盤驅(qū)動器的分區(qū)和扇區(qū),命令“l(fā)s -ls”來查看文件的大小和塊數(shù),還可以使用命令“dumpe2fs”來查看給定文件系統(tǒng)的詳細(xì)信息,包括塊和Sectors的數(shù)量和使用情況。
Sectors在Linux系統(tǒng)中的重要性
Sectors在Linux系統(tǒng)中具有極其重要的作用。在創(chuàng)建和管理文件系統(tǒng)時(shí),必須確保Sectors的數(shù)量和位置正確。否則,文件系統(tǒng)可能會出現(xiàn)嚴(yán)重的問題,例如數(shù)據(jù)損壞、元數(shù)據(jù)丟失等。此外,在進(jìn)行磁盤備份和恢復(fù)時(shí),Sectors的位置也是至關(guān)重要的,因?yàn)閭浞莺突謴?fù)必須恢復(fù)每個(gè)扇區(qū)的精確位置以確保數(shù)據(jù)的完整性。
在Linux系統(tǒng)中,Sectors是文件系統(tǒng)上的扇區(qū),用于描述文件系統(tǒng)上的數(shù)據(jù)和元數(shù)據(jù)的位置。Sectors通常與塊大小相關(guān)聯(lián),并且扇區(qū)和塊一起用于描述文件系統(tǒng)的結(jié)構(gòu)。了解和管理文件系統(tǒng)的Sectors是Linux系統(tǒng)管理的重要組成部分,成功管理Sectors是確保文件系統(tǒng)穩(wěn)定性和可靠性的關(guān)鍵所在。
相關(guān)問題拓展閱讀:
- linux下如何掛載硬盤?
- 如何查看Linux磁盤空間大小
linux下如何掛載硬盤?
1.插入新硬盤,啟動Linux服務(wù)器,使用fdisk -l 查看硬盤
#fdisk -l
Disk /dev/sdb: 1000.2 GB, bytes
2.格式化硬盤
#mkfs -t ext4 /dev/sdb
3.掛載硬盤
#mount 硬盤地址 要掛載的地址
#mount /dev/sdb /media/imgs
4.實(shí)現(xiàn)系統(tǒng)重啟后自動掛載該分區(qū)
#vi /etc/fstab
在最后一行添加
/dev/sdb /media/imgs ext4 defaults 1 2
一、添加磁盤
添加加乎帶悉新硬盤重啟服務(wù)器
添加完之后就可以重啟機(jī)器了,如果你機(jī)器是開啟的,進(jìn)入系統(tǒng)并不能看見你剛添加的那塊磁盤,只有等系統(tǒng)重啟,重新加載之后才會顯示安裝的那塊磁盤
二、進(jìn)入系統(tǒng)
使用root用戶進(jìn)入系統(tǒng)
三、 查看硬盤信息
# fdisk -l //磁盤命令
Disk /dev/sda: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000c4cb5
Device Boot StartEnd Blocks Id System
/dev/sda1 *行運(yùn) 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda 8e Linux LVM
Disk /dev/sdb: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd0f5c869
Device Boot StartEnd Blocks Id System
/dev/sdb+ 83 Linux
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x
可以看到這臺機(jī)器加載了三個(gè)磁盤sda、sdb、sdc
其中sda是初始磁盤,sdb已經(jīng)初始化且經(jīng)過使用,sdc是剛剛加載的,未格式化的新磁盤
四、創(chuàng)建新硬盤分區(qū)
# fdisk /dev/sdc #進(jìn)入磁歲乎盤
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x45a3cadb.
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 #設(shè)定可啟動標(biāo)記
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition#刪除一個(gè)分區(qū)
l list known partition types #各分區(qū)類型所對應(yīng)的ID
m print this menu#菜單
n add a new partition#添加一個(gè)分區(qū)
o create a new empty DOS partition table
p print the partition table #顯示該磁盤下的當(dāng)前分區(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 #保存退出
x extra functionality (experts only)
知道命令之后就可以進(jìn)行分區(qū)了
Command (m for help): p //打印分區(qū)信息,可以看到當(dāng)前并沒有分區(qū)
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45a3cadb
Device Boot StartEnd Blocks Id System
Command (m for help): n //創(chuàng)建一個(gè)新的分區(qū)
Command action
e extended//輸入e為創(chuàng)建擴(kuò)展分區(qū)
p primary partition (1-4) //輸入p為創(chuàng)建邏輯分區(qū)
p
Partition number (1-4): 1//劃分邏輯分區(qū)
First cylinder (1-2610, default 1): //我這里直接回車,是不想把該磁盤分成多個(gè)分區(qū),把整個(gè)磁盤作為1個(gè)分區(qū)
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):
Using default value 2610
Command (m for help): p //再次查看可以看到該磁盤已經(jīng)有1個(gè)分區(qū)了
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x45a3cadb
Device Boot StartEnd Blocks Id System
/dev/sdc+ 83 Linux
Command (m for help): w //保存分區(qū)
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
再次使用”fdisk -l”命令查看磁盤信息
Disk /dev/sdc: 21.5 GB,bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of* 512 =bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x406a4c58
Device Boot StartEnd Blocks Id System
/dev/sdc+ 83 Linux
第三塊磁盤/dev/sdc已經(jīng)分區(qū)好了
五、格式化分區(qū)
# mkfs.ext3 /dev/sdc1
//將/dev/sdc1格式化為ext3類型,好像大部分的磁盤都是格式化為ext3類型,具體為什么沒有深入研究,暫時(shí)不清楚,想了解的朋友可以自己查一下
# mkfs.ext3 /dev/sdc1
mke2fs 1.41.12 (17-May-2023)
文件系統(tǒng)標(biāo)簽=
操作系統(tǒng):Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
inodes,blocks
blocks (5.00%) reserved for the super user
之一個(gè)數(shù)據(jù)塊=0
Maximum filesystem blocks=
160 block groups
32768 blocks per group,fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304,,,,,,,,
正在寫入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
This filesystem will be automatically checked every 31 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
格式化完畢,此時(shí)就可以使用“mount”命令掛載分區(qū)了,然后使用這個(gè)磁盤空間了
六、掛載分區(qū)以及開機(jī)自動掛載
# df -h //此時(shí)只有sda1和sdb1兩個(gè)磁盤掛載
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 18G 15G 1.5G 92% /
tmpfsM 76K 932M 1% /dev/shm
/dev/sdaM 40M 421M 9% /boot
/dev/sdbG 1.2G 18G 7% /disk/diskone
/dev/sr.2G 4.2G% /media/CentOS_6.5_Final
# cd /disk/
# ll
總用量 4
drwxr-xr-x. 4 root root月:04 diskone
# cd diskone/
# ll
總用量 20
drwx——. 2 root root月:12 lost+found
drwxr-xr-x. 2 root root月:09 software
# cd ../
# mkdir disktwo //創(chuàng)建被掛載的路徑
# ll
總用量 8
drwxr-xr-x. 4 root root月:04 diskone
如何查看Linux磁盤空間大小
df -h
du -sh *
如何查看Linux磁盤空間大小
一、df命令;
df是來自于coreutils軟件包,系統(tǒng)安裝時(shí),就自帶的;我們通過這個(gè)命令可以查看磁盤的使用情況以及文件系統(tǒng)被掛載的位置;
舉例:
# df -lh
Filesystem容量已用可用已用%掛載點(diǎn)
/dev/hda8 11G 6.0G 4.4G 58% /
/dev/shm 236M 0 236M 0% /dev/shm
/dev/sda1 56G 22G 35G 39% /mnt/sda1
我們從中可以看到,系統(tǒng)安裝在/dev/hda8;還有一個(gè)56G的磁盤分區(qū)/dev/sda1掛載在/mnt/sda1中;
其它的參數(shù)請參考man df
二、fdsik
fdisk是一款強(qiáng)大的磁盤操作工具,來自util-linux軟件包,我們在這里只說他如何查看磁盤分區(qū)表及分區(qū)結(jié)構(gòu);參數(shù)-l,通過-l參數(shù),能獲得機(jī)器中所有的硬盤的分區(qū)情況;
# fdisk -l
Disk /dev/hda: 80.0 GB,bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of* 512 =bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 7 HPFS/NTFS
/dev/hda86300 c W95 FAT32 (LBA)
/dev/hdaExtended
/dev/hda93118+ 83 Linux
/dev/hdaLinux
/dev/hda7153+ 82 Linux swap / Solaris
/dev/hdaLinux
/dev/hda87523+ 83 Linux
在上面Blocks中,表示的是分區(qū)的大小,Blocks的單位是byte,我們可以換算成M,比如之一個(gè)分區(qū)/dev/hda1的大小如果換算成M,應(yīng)該是/1024=6000M,也就是6G左右,其實(shí)沒有這么麻煩,粗略的看一下把小數(shù)點(diǎn)向前移動三位,就知道大約的體積有多大了;
System表示慶御大的文件系統(tǒng),比如/dev/hda1是NTFS格式的;/dev/hda2表示是fat32格式的文件系統(tǒng);.
在此例中,我們要特別注意的是/dev/hda3分區(qū),這是擴(kuò)展分區(qū);他下面包含著邏輯分區(qū),其實(shí)這個(gè)分區(qū)相當(dāng)于一個(gè)容器;從屬于她的有hda5,hda6,hda7,hda8,hda9;
我們還注意到一點(diǎn),怎么沒有hda4呢?為什么hda4沒有包含在擴(kuò)展分區(qū)?一個(gè)磁盤最多有四個(gè)主分區(qū);hda1-4算都是主分區(qū);hda4不可能包含在擴(kuò)展分區(qū)譽(yù)豎里,另外擴(kuò)展分區(qū)也算主分區(qū);在本例中,沒有hda4這個(gè)分區(qū),當(dāng)然我們可以把其中的一個(gè)分區(qū)設(shè)置為主分區(qū),只是我當(dāng)時(shí)分區(qū)的時(shí)候沒有這么做而已;
再仔細(xì)統(tǒng)計(jì)一下,我們看一看這個(gè)磁盤是不是還有空間?hda1+hda2+hda3=實(shí)際已經(jīng)分區(qū)的體積,所以我們可以這樣算hda1+hda2+hda3=++=(b),換算成M單位,小數(shù)點(diǎn)向前移三位,所以目前已經(jīng)劃分好的分區(qū)大約占用體積是62259.876(M),其實(shí)最精確的計(jì)算/1024=60800.67(M);而這個(gè)磁盤大小是80.0 GB(byte),其實(shí)實(shí)際大小也就是78150.744(M);通過我們一系列的計(jì)算,我們可以得出這個(gè)硬拆純盤目前還有使用的空間;大約還有18G未分區(qū)的空間;
fdisk -l能列出機(jī)器中所有磁盤的個(gè)數(shù),也能列出所有磁盤分區(qū)情況;比如:
# fdisk -l
Disk /dev/hda: 80.0 GB,bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of* 512 =bytes
Device Boot Start End Blocks Id System
/dev/hda1 * 7 HPFS/NTFS
/dev/hda86300 c W95 FAT32 (LBA)
/dev/hdaExtended
/dev/hda93118+ 83 Linux
/dev/hdaLinux
/dev/hda7153+ 82 Linux swap / Solaris
/dev/hdaLinux
/dev/hda87523+ 83 Linux
Disk /dev/sda: 60.0 GB,bytes
64 heads, 32 sectors/track,cylinders
Units = cylinders of 2023 * 512 =bytes
Device Boot Start End Blocks Id System
/dev/sdaLinux
通過上面我們可以知道此機(jī)器有兩塊硬盤,我們也可以指定fdisk -l來查看其中一個(gè)硬盤的分區(qū)情況;
# fdisk -l /dev/sda
Disk /dev/sda: 60.0 GB,bytes
64 heads, 32 sectors/track,cylinders
Units = cylinders of 2023 * 512 =bytes
Device Boot Start End Blocks Id System
/dev/sdaLinux
通過上面情況可以知道,在/dev/sda這個(gè)磁盤中,只有一個(gè)分區(qū);使用量差不多是百分百了;
我們還可以來查看/dev/hda的
# fdisk -l /dev/hda
自己試試看?
三、cfdisk來自于util-linux的軟件包;
cfdisk也是一款不錯(cuò)的分區(qū)工具;在有些發(fā)行版中,此工具已經(jīng)從util-linux包中剔除;cfdisk簡單易用是他的特點(diǎn);和DOS中的fdisk相似;在本標(biāo)題中,我們只來解說如何查看機(jī)器的中的磁盤分區(qū)狀況及所用的文件系統(tǒng)等;
查看磁盤分區(qū)的用法cfdisk -Ps磁盤設(shè)備名;
比如
cfdisk -Ps
cfdisk -Ps /dev/hda
cfdisk -Ps
Partition Table for /dev/hda
First Last
# Type Sector Sector Offset Length Filesystem Type (ID) Flag
1 PrimaryLinux (83) Boot
2 Primary550 Extended (05) None
5 Logical9390 Linux (83) None
6 Logical160 Linux swap (82) None
我們只用的參數(shù)-Ps,就列出了磁盤的分區(qū)情況;目前在Slackware DebianMandrake等主流發(fā)行版中存在cfdisk,而fedora 4.0把這個(gè)小工具剔除了;有點(diǎn)可惜;這是我在Slackware中操作的;
如果您這樣操作,就更直觀了;
cfdisk磁盤設(shè)備名
舉例:
cfdisk /dev/hda
您所看到的是如下的模式:
cfdisk 2.12a
Disk Drive: /dev/hda
Size:bytes, 80.0 GB
Heads: 255 Sectors per Track: 63 Cylinders: 9729
Name Flags Part Type FS Type Size (MB)
hda1 Boot Primary Linux ReiserFS 12023.69
hda5 Logical Linux ReiserFS 67496.65
hda6 Logical Linux swap 526.42
Toggle bootable flag of the current partition
您進(jìn)入了cfdisk的操作界面;用鍵盤移動指針到就可以退出;
四、parted功能不錯(cuò)的分區(qū)工具;在Fedora 4.0中有帶,可以自己安裝上;在此主題中,我們只說如何查看磁盤的分區(qū)情況;
調(diào)用方法簡單,parted默認(rèn)是打開的設(shè)備是/dev/hda,也可以自己指定;比如parted /dev/hda或/dev/sda等;退出的方法是quit
# parted
使用/dev/hda
(parted) p
/dev/hda的磁盤幾何結(jié)構(gòu):0..085兆字節(jié)
磁盤標(biāo)簽類型:msdos
Minor起始點(diǎn)終止點(diǎn)類型文件系統(tǒng)標(biāo)志
1 0..842主分區(qū)ntfs啟動
2 6000..088主分區(qū)fat32 lba
..690擴(kuò)展分區(qū)
..211邏輯分區(qū)reiserfs
..615邏輯分區(qū)reiserfs
..350邏輯分區(qū)linux-swap
..094邏輯分區(qū)ext3
..690邏輯分區(qū)reiserfs
我們在partd的操作面上,用p就可以列出當(dāng)前磁盤的分區(qū)情況,如果想要查看其它磁盤,可以用select功能,比如select /dev/sda;
五、qtparted,與parted相關(guān)的軟件還有qtparted,也能查看到磁盤的結(jié)構(gòu)和所用的文件系統(tǒng),是圖形化的;
# qtparted
圖形化的查看,一目了然;
六、sfdisk也是一個(gè)分區(qū)工具,功能也多多;我們在這里只說他的列磁盤分區(qū)情況的功能;
# sfdisk -l
自己看看吧;
sfdisk有幾個(gè)很有用的功能;有興趣的弟兄不妨看看;
七、partx也簡要的說一說,有些系統(tǒng)自帶了這個(gè)工具,功能也簡單,和fdisk、parted、cfdisk來說不值一提;不用也罷;
用法:partx設(shè)備名
# partx /dev/hda
# 1:(sectors, 6292 MB)
# 2:62324 (sectors,MB)
# 3:19814 (sectors,MB)
# 4:( 0 sectors, 0 MB)
# 5:48624 (sectors, 8389 MB)
# 6:31499 (sectors,MB)
# 7:05869 (sectors, 806 MB)
# 8:44704 (sectors,MB)
# 9:(sectors, 8998 MB)
八、查看目前機(jī)器中的所有磁盤及分區(qū)情況:
$ cat /proc/partitions
major minor #blocks name
hda
hda1
hda2
hda5
hda6
hda7
hda8
hda9
sda
關(guān)于linux sectors的介紹到此就結(jié)束了,不知道你從中找到你需要的信息了嗎 ?如果你還想了解更多這方面的信息,記得收藏關(guān)注本站。
創(chuàng)新互聯(lián)服務(wù)器托管擁有成都T3+級標(biāo)準(zhǔn)機(jī)房資源,具備完善的安防設(shè)施、三線及BGP網(wǎng)絡(luò)接入帶寬達(dá)10T,機(jī)柜接入千兆交換機(jī),能夠有效保證服務(wù)器托管業(yè)務(wù)安全、可靠、穩(wěn)定、高效運(yùn)行;創(chuàng)新互聯(lián)專注于成都服務(wù)器托管租用十余年,得到成都等地區(qū)行業(yè)客戶的一致認(rèn)可。
當(dāng)前名稱:究竟是什么?LinuxSectors解析(linuxsectors)
鏈接URL:http://m.fisionsoft.com.cn/article/cdejgie.html


咨詢
建站咨詢
