這篇文章給大家介紹linux系統(tǒng)分區(qū)格式化和掛載數(shù)據(jù)盤的示例分析,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
這篇文章給大家介紹linux系統(tǒng)分區(qū)格式化和掛載數(shù)據(jù)盤的示例分析,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對(duì)大家能有所幫助。
創(chuàng)新互聯(lián)成立于2013年,先為興安等服務(wù)建站,興安等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為興安企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。
使用【管理終端】,或遠(yuǎn)程連接工具,輸入用戶名 root 和密碼登錄到linux系統(tǒng)。
1、運(yùn)行fdisk -l命令查看數(shù)據(jù)盤。在沒有分區(qū)和格式化數(shù)據(jù)盤之前,使用 “df –h”命令,是無法看到數(shù)據(jù)盤的,可以使用“fdisk -l”命令查看。
執(zhí)行命令后,如果不存在 /dev/vdb,表示沒有數(shù)據(jù)盤。確認(rèn)數(shù)據(jù)盤是否已掛載。
2、依次執(zhí)行以下命令以創(chuàng)建一個(gè)單分區(qū)數(shù)據(jù)盤:
(1)運(yùn)行fdisk -u /dev/vdb:分區(qū)數(shù)據(jù)盤。
(2)輸入p:查看數(shù)據(jù)盤的分區(qū)情況。本示例中,數(shù)據(jù)盤沒有分區(qū)。
(3)輸入n:創(chuàng)建一個(gè)新分區(qū)。
(4)輸入p:選擇分區(qū)類型為主分區(qū)。
說明 本示例中創(chuàng)建一個(gè)單分區(qū)數(shù)據(jù)盤,所以只需要?jiǎng)?chuàng)建主分區(qū)。如果要?jiǎng)?chuàng)建四個(gè)以上分區(qū),您應(yīng)該創(chuàng)建至少一個(gè)擴(kuò)展分區(qū),即選擇 e(extended)。
(5)輸入分區(qū)編號(hào)并按回車鍵。本示例中,僅創(chuàng)建一個(gè)分區(qū),輸入1。
(6)輸入第一個(gè)可用的扇區(qū)編號(hào):按回車鍵采用默認(rèn)值2048。
(7)輸入最后一個(gè)扇區(qū)編號(hào):本示例僅創(chuàng)建一個(gè)分區(qū),按回車鍵采用默認(rèn)值。
(8)輸入p:查看該數(shù)據(jù)盤的規(guī)劃分區(qū)情況。
(9)輸入w:開始分區(qū),并在分區(qū)后退出。[root@ecshost~ ]# fdisk -u /dev/vdbWelcome 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 tableBuilding a new DOS disklabel with disk identifier 0x3e60020e. Command (m for help): pDisk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x3e60020eDevice Boot Start End Blocks Id System Command (m for help): nPartition type:p primary (0 primary, 0 extended, 4 free)e extendedSelect (default p): pPartition number (1-4, default 1): 1First sector (2048-41943039, default 2048):Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039):Using default value 41943039Partition 1 of type Linux and of size 20 GiB is set Command (m for help): p Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x3e60020eDevice Boot Start End Blocks Id System/dev/vdb1 2048 41943039 20970496 83 Linux Command (m for help): wThe partition table has been altered! Calling ioctl() to re-read partition table.Syncing disks.
3、運(yùn)行命令fdisk -lu /dev/vdb 查看新分區(qū)。
如果出現(xiàn)以下信息,表示新分區(qū)/dev/vdb1創(chuàng)建成功。[root@ecshost~ ]# fdisk -lu /dev/vdb Disk /dev/vdb: 21.5 GB, 21474836480 bytes, 41943040 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x3e60020e Device Boot Start End Blocks Id System/dev/vdb1 2048 41943039 20970496 83 Linux
4、運(yùn)行命令mkfs.ext4 /dev/vdb1在新分區(qū)上創(chuàng)建一個(gè)文件系統(tǒng)。
本示例中,創(chuàng)建一個(gè)ext4文件系統(tǒng)。您也可以根據(jù)自己的需要,選擇創(chuàng)建其他文件系統(tǒng),例如:如果您需要在 Linux、Windows和Mac系統(tǒng)之間共享文件,可以使用mkfs.vfat創(chuàng)建VFAT文件系統(tǒng)。
說明 創(chuàng)建文件系統(tǒng)所需時(shí)間取決于數(shù)據(jù)盤大小。[root@ecshost~ ]# mkfs.ext4 /dev/vdb1 mke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks1310720 inodes, 5242624 blocks262131 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=2153775104160 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000 Allocating group tables: doneWriting inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done
5、(建議)運(yùn)行命令cp /etc/fstab /etc/fstab.bak備份etc/fstab文件。
6、運(yùn)行命令echo /dev/vdb1 /data0 ext4 defaults 0 0 >> /etc/fstab向/etc/fstab寫入新分區(qū)信息。
說明 Ubuntu 12.04系統(tǒng)不支持barrier,您需要運(yùn)行命令 echo '/dev/vdb1 /data0 ext4 barrier=0 0 0' >> /etc/fstab。
如要把數(shù)據(jù)盤單獨(dú)掛載到某個(gè)文件夾,例如單獨(dú)用來存放網(wǎng)頁,則將命令中/data0替換成所需的掛載點(diǎn)路徑。
7、運(yùn)行命令cat /etc/fstab查看/etc/fstab中的新分區(qū)信息。[root@ecshost~ ]# cat /etc/fstab## /etc/fstab# Created by anaconda on Wed Dec 12 07:53:08 2018## Accessible filesystems, by reference, are maintained under '/dev/disk'# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info#UUID=d67c3b17-255b-4687-be04-f29190d37396 / ext4 defaults 1 1/dev/vdb1 /mnt ext4 defaults 0 0
8、運(yùn)行命令mount /dev/vdb1 /data0掛載文件系統(tǒng)。
9、運(yùn)行命令df -h 查看目前磁盤空間和使用情況。
出現(xiàn)新建文件系統(tǒng)的信息,表示掛載成功。<div><br class="Apple-interchange-newline">[root@ecshost~ ]# df -hFilesystem Size Used Avail Use% Mounted on/dev/vda1 40G 1.6G 36G 5% /devtmpfs 234M 0 234M 0% /devtmpfs 244M 0 244M 0% /dev/shmtmpfs 244M 484K 244M 1% /runtmpfs 244M 0 244M 0% /sys/fs/cgrouptmpfs 49M 0 49M 0% /run/user/0/dev/vdb1 20G 45M 19G 1% /mnt</div>12345678910 [root@ecshost~ ]# df -h Filesystem Size Used Avail Use% Mounted on/dev/vda1 40G 1.6G 36G 5% /devtmpfs 234M 0 234M 0% /devtmpfs 244M 0 244M 0% /dev/shmtmpfs 244M 484K 244M 1% /runtmpfs 244M 0 244M 0% /sys/fs/cgrouptmpfs 49M 0 49M 0% /run/user/0/dev/vdb1 20G 45M 19G 1% /mnt
10、最后 reboot,重啟。
新聞名稱:linux系統(tǒng)分區(qū)格式化和掛載數(shù)據(jù)盤的示例分析
分享路徑:http://www.rwnh.cn/article10/idcddo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、全網(wǎng)營銷推廣、品牌網(wǎng)站制作、網(wǎng)站內(nèi)鏈、網(wǎng)站排名、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)