mount查看linux分区大小,Linux磁盘管理----分区格式化挂载fdisk、mkfs、mount
1,磁盤分區(qū)命令fdisk
[root@localhost ~]# fdisk -l #查看磁盤分區(qū)情況
Disk /dev/sda: 10.8 GB, 10837518250 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
(這個(gè)硬盤的大小是10.8GB,有255個(gè)磁面,63個(gè)扇區(qū),1305磁柱(cylinders)
每個(gè)cylinder(磁柱)的容量是8225280 bytes=8225.280K(約為)=8.225280M(約))
Device Boot????? Start ? ? ? End ? ? ?Blocks ? ?Id? System
/dev/sda1??* ? ? ? 1 ? ? ? ? 13 ? ? ?104391 ? ?83? Linux
/dev/sda2 ? ? ? ? ?14 ? ? ? ?1305 ? ? 10377990 ? 8e? Linux LVM
(ID和System表示的是分區(qū)類型,id看起來(lái)不太直觀,我們要在fdisk創(chuàng)建一個(gè)分區(qū)時(shí),可以指定id來(lái)確認(rèn)分區(qū)類型;比如7表示的就NTFS分區(qū);這個(gè)在fdisk中要通過(guò)參數(shù)“t”來(lái)指定。)
硬盤分區(qū)的表示:在Linux是通過(guò)hd*x或sd*x表示的:
其中*表示的是a、b、c ... ...
另外x表示的數(shù)字1、2、3 ... ...
hd大多是IDE硬盤;sd大多是SCSI或移動(dòng)存儲(chǔ);引導(dǎo)(Boot):表示引導(dǎo)分區(qū),在上面的例子中sda1是引導(dǎo)分區(qū);
Start(開(kāi)始):表示的一個(gè)分區(qū)從Xcylinder(磁柱)開(kāi)始;
End(結(jié)束):表示一個(gè)分區(qū)到?Ycylinder(磁柱)結(jié)束;
Disk /dev/sdb: 21.4 GB,21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Disk /dev/sdb doesn't contain a validpartition table
[root@localhost ~]#?fdisk /dev/sda #對(duì)磁盤sda進(jìn)行分區(qū)
Thenumber of cylinders for this disk is set to 1305.
There isnothing wrong with that, but this is larger than 1024,
and couldin certain setups cause problems with:
1) softwarethat runs at boot time (e.g., old versions of LILO)
2)booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
(輸入m可以得到幫助信息)
Command(m for help): m???? ?????????????---輸出幫助信息
Commandaction
a??toggle a bootable flag? ???????????? ---設(shè)置啟動(dòng)分區(qū)
b??edit bsd disklabel????? ????????? ?---編輯分區(qū)標(biāo)簽
c??toggle the dos compatibility flag???????? ---切換dos兼容模式
d??delete a partition????????????????--刪除一個(gè)分區(qū)
l??list known partition types????????????--列出分區(qū)類型
m??print this menu????????????????? --幫助
n??add a new partition?????????????? ?--建立一個(gè)新的分區(qū)
o??create a new empty DOS partition table??????--創(chuàng)建一個(gè)新的空白DOS分區(qū)表
p??print the partition table ? ? ? ? ? ? ? ? ---打印分區(qū)表
q??quit without saving changes ? ? ? ? ? ? ? ?---退出不保存設(shè)置
s ? createa new empty Sun disklabel ? ? ? ? ? ? ---創(chuàng)建新的sun磁盤標(biāo)簽
t ? changea partition's system id ? ? ? ? ? ? ?---改變分區(qū)的ID
u ? changedisplay/entry units ? ? ? ? ? ? ? ? ---改變顯示的單位
v ? verifythe partition table ? ? ? ? ? ? ? ? ---檢查驗(yàn)證分區(qū)表
w??write table to disk and exit ? ? ? ? ? ? ? ---保存分區(qū)表
x??extra functionality (experts only)????????---擴(kuò)展功能
Command (m for help): n?(創(chuàng)建一個(gè)新分區(qū))
Command action
e?? extended
p?? primary partition (1-4)????? ---指定分區(qū)類型? e為擴(kuò)展分區(qū) ?p為主分區(qū)
p (輸入p選擇創(chuàng)建主分區(qū))
Partition number (1-4):1 (創(chuàng)建第一個(gè)主分區(qū),也即是后來(lái)的sda1) ---主分區(qū)最多只能有四個(gè)
First cylinder (1-2610, default 1): 1?? ---設(shè)定起始分區(qū)的位置
Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610):2610
Using default value 2610 ? ? ? ? ? ?---設(shè)定結(jié)束分區(qū)的位置
Command (m for help):w? ? ? ? ? ?---保存剛才的配置信息。
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
刪除分區(qū)
[root@localhost ~]# fdisk /dev/sdb
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
and could in certain setups cause problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): d ? ?(---d 是代表刪除,并且會(huì)列出當(dāng)前磁盤的分區(qū)數(shù))
Selected partition 1???? (1 是要?jiǎng)h除的分區(qū)編號(hào))
Command (m for help): p ? ?(---p 是代表刪除后,顯示磁盤還有幾個(gè)剩余的分區(qū))
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot ? ? Start ? ? End ? ?Blocks??Id? System ? 已經(jīng)沒(méi)有分區(qū)了
Command (m for help): w ? ?(---w 保存剛才的操作并且生效)
The partition table has been altered!
Calling ioctl() to re-read partition table.
通過(guò)fdisk?命令來(lái)創(chuàng)建一指定大小的分區(qū)并增加一個(gè)分區(qū)
[root@localhost ~]# fdisk /dev/sdb
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
and could in certain setups cause problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help):n??????????? ---創(chuàng)建分區(qū)
Command action
e?? extended
p?? primary partition (1-4)
p????????????????輸入p --指定分區(qū)類型為主分區(qū)
Partition number (1-4):1?????????? --指定其實(shí)分區(qū)號(hào)
First cylinder (1-2610, default 1): 1 ? ? ?--指定起始柱面號(hào)
Last cylinder or +size or +sizeM or +sizeK(1-2610, default 2610):1024 ---指定終止柱面號(hào)
Command (m for help):w??????????? ---保存分區(qū)配置信息
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the nextreboot.
Syncing disks.
增加分區(qū)
[root@localhost ~]# fdisk /dev/sdb????? -----增加分區(qū)
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
and could in certain setups cause problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n?????? ---分區(qū)類型
Command action
e?? extended
p?? primary partition (1-4)??? ---還是指定主分區(qū)
p
Partition number (1-4): 1??????????---分區(qū)號(hào),我指定1。
Partition 1is already defined.??Delete it beforere-adding it.
–提示分區(qū)號(hào)1已經(jīng)存在,刪除后操作
Command (m for help): n????????? --我們重新創(chuàng)建分區(qū)
Command action
e?? extended
p?? primary partition (1-4)???? --指定分區(qū)類型
p
Partition number (1-4): 2 ? ? ? ? ---因?yàn)榉謪^(qū)1已經(jīng)存在,所以我們指定分區(qū)2,可通過(guò)。
First cylinder (1025-2610, default 1025): ? ?---指定起始礠柱號(hào),默認(rèn)是上一分區(qū)后一號(hào)。
Using default value 1025
Last cylinder or +size or +sizeM or +sizeK(1025-2610, default 2610): 2000 指定終止柱號(hào)。
Command (m for help): w?????????????????? ---保存分區(qū)配置
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the nextreboot.
Syncing disks.
[root@localhost ~]#
通過(guò)fdisk命令來(lái)修改現(xiàn)有分區(qū)類型
fdisk?通過(guò)t參數(shù)來(lái)指定
查看分區(qū)類型
[root@localhost ~]# fdisk -l /dev/sdb???查看分區(qū)信息,類型是Linux,id是83
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot????? Start ? ? ? ?End????? Blocks??Id??System
/dev/sdb1 ? ? ? ? ?1??????? 1024????8225248+??83??Linux
/dev/sdb2 ? ? ? ? 1025 ? ? ? ? 2000 ? ? ? 7839720 ? 83??Linux
修改分區(qū)類型
[root@localhost ~]# fdisk /dev/sdb
The number of cylinders for this disk isset to 2610.
There is nothing wrong with that, but thisis larger than 1024,
and could in certain setups cause problemswith:
1) software that runs at boot time (e.g.,old versions of LILO)
2) booting and partitioning software fromother OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): t ? ? ? ? ? ? ? ? ? ? ? ---進(jìn)入修改分區(qū)類型
Partition number (1-4): 1 ? ? ? ? ? ? ? ? ? ? ---指定需要修改的分區(qū)號(hào)
Hex code (type L tolist codes): 6 ? ? ? ? ? ? ? ---指定分區(qū)號(hào)為6,也就是FAT16
注意:查看分區(qū)類型的代碼,在這里可以輸入L查看就可以了
Changed system type of partition 1 to 6(FAT16)
Command (m for help): w ? ? ? ? ? ? ? ? ? ? ? ? ? ---保存
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition tablefailed with error 16: Device or resource busy.
The kernel still uses the old table.
The new table will be used at the nextreboot.
WARNING: If you have created or modifiedany DOS 6.x
partitions, please see the fdisk manualpage for additional
information.
Syncing disks.
[root@localhost ~]# fdisk -l /dev/sdb??????? ---我們看到已經(jīng)FAT16,并且ID也改成6了。
Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot????? Start???????? End????? Blocks??Id? System
/dev/sdb1 ? ? ? ? ?1 ? ? ? ? ? ? 1024????8225248+??6? FAT16
/dev/sdb2 ? ? ? ? 1025 ? ? ? ? ? ? 2000????7839720?? 83? Linux
[root@localhost ~]#
mkfs對(duì)分區(qū)進(jìn)行格式化:
對(duì)分區(qū)進(jìn)行格式化的命令如下,mkfs后面所接的代表的是將要格式化成的文件系統(tǒng)類型:
mkfs.bfs
mkfs.ext3
mkfs.ext4
mkfs.jfs
mkfs.msdos
mkfs.vfat
mkfs.cramfs
mkfs.minix
mkfs.reiserfs
mkfs.xfs
格式化分區(qū):
[root@localhost ~]#mkfs.ext4 /dev/sdb1????????? ---格式化分區(qū)類型為ext4
mke4fs 1.41.5(23-Apr-2009)
Filesystem label= ? ? ? ? ? ? ? ? ? ? ? ? ? ?---我們沒(méi)有指定卷標(biāo),就沒(méi)有
OS type: Linux ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?---操作系統(tǒng)類型
Block size=4096 (log=2) ? ? ? ? ? ? ? ? ? ? ? ?--單個(gè)塊的大小
Fragment size=4096 (log=2) ? ? ? ? ? ? ? ? ? ? ?--片大小
1310720 inodes, 5241198blocks
262059 blocks (5.00%)reserved for the super user
First data block=0
Maximum filesystem blocks=0
160 block groups
32768 blocks per group, 32768fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912,819200, 884736, 1605632, 2654208,
4096000
Writing inode tables:done
Creating journal (32768blocks): done
Writing superblocks andfilesystem accounting information: done
This filesystem will beautomatically checked every 27 mounts or
180 days, whichever comesfirst.? Use tune4fs -c or -i to override.
mount掛載磁盤:(臨時(shí)掛載)
[root@localhost ~]# mkdir/data???????????? --創(chuàng)建掛載目錄點(diǎn)
[root@localhost ~]# mount? /dev/sdb1 /data? --將/dev/sdb1掛載到/data
驗(yàn)證是否成功掛載
[root@localhost ~]# df -h
Filesystem??????????? Size? Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
7.7G? 3.1G?4.2G? 43% /
/dev/sda1 ? ? ? ?99M?? 12M??82M ? ?13% ?/boot
tmpfs ? ? ? ? ? 506M ? 0 ? ?506M?? 0% ?dev/shm
/dev/sdb1 ? ? ? ? 20G?? 16K??20G?? 1% ?/data???? --已經(jīng)成功掛載了。
[root@localhost ~]#
修改fstab表掛載磁盤(永久掛載)
通過(guò)vim編輯器編輯/etc/fstab文件,內(nèi)容如下,(紅色部分是剛添加上去的):
掛載路徑 ? ?掛載的分區(qū) ? ?文件系統(tǒng)??掛載參數(shù) ? ?是否要備份???自檢順序
/dev/VolGroup00/LogVol00/ ? ? ? ?ext3??? defaults??????? 1 1
LABEL=/boot ? ? /boo ? ? ? ? ?ext3??? defaults??????? 1 2
tmpfs ? ? ? ? /dev/shm ? ? ? tmpfs ? ?defaults ? ? ? ? ? 0 0
devpts ? ? ? ?/dev/pts ? ? ? devpts? gid=5,mode=620 ? ? ? ?0 0
sysfs ? ? ? ? /sys ? ? ? ? ?sysfs?? defaults ? ? ? ? ? 0 0
proc ? ? ? ? /proc ? ? ? ? ?proc??? defaults??????? 0 0
/dev/VolGroup00/LogVol01swap ? ? ?swap??? defaults??????? 0 0
/data ? ? ? ?/dev/sdb1 ? ? ? ext4 ? ? defaults ? ? ? ? ? 0 0
保存后執(zhí)行命令 mount -a 加載最新配置
第四列掛載參數(shù):通過(guò)mount來(lái)查看
第五列是否要備份:(0為不備份,1為要備份,一般情況下不用做備份)
第六列自檢程序??(0為不自檢,1或2為要自檢,如果是根分區(qū)要設(shè)置1,其它分區(qū)只能是2)
《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
以上是生活随笔為你收集整理的mount查看linux分区大小,Linux磁盘管理----分区格式化挂载fdisk、mkfs、mount的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 电竞人可评高级技师职称 以后电竞再也不是
- 下一篇: linux 其他常用命令