Disk /dev/sdb: 2147 MB, 2147483648 bytes
2.fdisk /dev/sdb
3. n 添加分區
Command (m for help):
Command action
a toggle a bootable flag //切換啓動標識
b edit bsd disklabel //編輯BSD標識
c toggle the dos compatibility flag //切換DOS兼容標識
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 //創建一個空的DOS分區
p print the partition table //打印分區表
q quit without saving changes //退出不保存
s create a new empty Sun disklabel //創建一個空的磁碟標籤
t change a partition's system id //改變分區系統ID
u change display/entry units //改變顯示/輸入單位
v verify the partition table //驗證分區表
w write table to disk and exit //寫入磁盤退出
x extra functionality (experts only) //額外功能
4. p 主分區
Command action
e extended /擴展分區
p primary partition (1-4) /主分區
5.選擇分區號,選擇 1,起始磁盤數默認1,磁盤大小選擇(K,M,G),默認全部大小回車
Partition number (1-4):1
First cylinder (1-261, default 1): 1
Last cylinder, +cylinders or +size{K,M,G} (1-261, default 261):
6.w寫入磁盤,完成退出。7. mkfs -t ext4 -c /dev/sdb1 格式化ext4,等待完成退出。
mke2fs 1.41.12 (17-May-2010)
文件系統標籤=
操作系統:Linux
塊大小=4096 (log=2)
分塊大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
131072 inodes, 524112 blocks
26205 blocks (5.00%) reserved for the super user
第一個數據塊=0
8.掛載硬盤目錄mount 磁盤目錄 目標目錄
例:mount /dev/sdb1 /mnt
完成掛載
mount -l 查看是否掛載完成。
要讓機器重啓能自動掛載,寫入配置文件。
vim /etc/fstab
/dev/sdb1 /mnt ext4 defaults 0 0
mount -a 確認自動掛載是否出錯
可能填寫設備名,在後期添加中會出錯誤,可以添加UUID(硬盤唯一標識碼)來預防。
UUID確認方法:
dumpe2s -h /dev/sdb1
defaults 後數字的含義:
dump,此處爲1的話,表示要將整個裏的內容備份;爲0的話,表示不備份。現在很少用到dump這個工具,在這裏一般選0。
pass,這裏用來指定如何使用fsck來檢查硬盤。
如果這裏填0,則不檢查;掛載點爲 / 的(即根分區),必須在這裏填寫1,其他的都不能填寫1。如果有分區填寫大於1的話,則在檢查完根分區後,接着按填寫的數字從小到大依次檢查下去。同數字 的同時檢查。比如第一和第二個分區填寫2,第三和第四個分區填寫3,則系統在檢查完根分區後,接着同時檢查第一和第二個分區,然後再同時檢查第三和第四個分區。