- 資訊首頁(yè) > 互聯(lián)網(wǎng) > 經(jīng)驗分享 >
- Linux VPS主機、服務(wù)器添加硬盤(pán)分區掛載教程
遇到磁盤(pán)空間不足的情況,常見(jiàn)的處理方案就是。 1. 進(jìn)行磁盤(pán)垃圾清理,無(wú)用的歷史數據進(jìn)行清除,騰出空閑的磁盤(pán)空間,2.就是添加新磁盤(pán),把不常用的數據移動(dòng)到新的磁盤(pán)中。
基本步驟:分區——格式化——掛載——寫(xiě)入文件
1、首先用fdisk -l命令查看添加的硬盤(pán)名稱(chēng),可以看到sdb為新增的硬盤(pán)
[root@oracle ~]# fdisk -l
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
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sda: 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
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0006b59c
Device Boot Start End Blocks Id System
/dev/sda1 * 1 39 307200 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 39 2358 18631680 83 Linux
/dev/sda3 2358 2611 2031616 82 Linux swap / Solaris
2、進(jìn)行分區,輸入m查看提示
[root@oracle ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x09f38795.
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
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 exit
x extra functionality (experts only)
分析:主要參數的解析
1. 輸入 m 顯示所有命令列示。
2. 輸入 p 顯示硬盤(pán)分割情形,打印分區表。
3. 輸入 a 設定硬盤(pán)啟動(dòng)區。
4. 輸入 n 創(chuàng )建新的硬盤(pán)分割區。
4.1. 輸入 e 硬盤(pán)為[延伸]分割區(extend)。
4.2. 輸入 p 硬盤(pán)為[主要]分割區(primary)。
5. 輸入 t 改變硬盤(pán)分割區屬性。
t:分區系統id號
L:82: swap
83:linux
86:NTFS window分區
6. 輸入 d 刪除硬盤(pán)分割區屬性。
7. 輸入 q 結束不存入硬盤(pán)分割區屬性。
8. 輸入 w 結束并寫(xiě)入硬盤(pán)分割區屬性
3、輸入n創(chuàng )建新的硬盤(pán)分區——輸入p創(chuàng )建主分區——輸入1設置一個(gè)分區——回車(chē)——回車(chē)(默認全部空間)
Command (m for help): n
Command action
e extended ···擴展分區
p primary partition (1-4) ···主分區
p
Partition number (1-4): 1
First cylinder (1-2610, default 1):
Using default value 1
Last cylinder, cylinders or size{K,M,G} (1-2610, default 2610):
Using default value 2610
4、輸入p查看分區情況——輸入w保存退出(一定要w保存不然無(wú)效)
Command (m for help): p
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
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x09f38795
Device Boot Start End Blocks Id System
/dev/sdb1 1 2610 20964793 83 Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
5、mkfs命令格式化磁盤(pán)
[root@oracle ~]# mkfs.ext4 /dev/sdb1
mkfs.ext4: invalid fragment size - /dev/sdb1
6、mount命令掛載分區
[root@oracle ~]# mount /dev/sdb1 /oracle/
You have new mail in /var/spool/mail/root
[root@oracle ~]# df -TH
Filesystem Type Size Used Avail Use% Mounted on
/dev/sda2 ext4 19G 11G 7.3G 60% /
tmpfs tmpfs 2.1G 74k 2.1G 1% /dev/shm
/dev/sda1 ext4 297M 29M 253M 11% /boot
/dev/sdb1 ext4 22G 47M 20G 1% /oracle
7、添加到/etc/fstab文件下保存退出否則重啟后硬盤(pán)消失
/dev/sdb1 /oracle ext4 defaults,noatime 0 0
來(lái)源鏈接:https://www.zyhot.com/article/623.html
本站聲明:網(wǎng)站內容來(lái)源于網(wǎng)絡(luò ),如有侵權,請聯(lián)系我們,我們將及時(shí)處理。
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系我們QQ:712375056,同時(shí)歡迎投稿傳遞力量。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站