2012年9月13日 星期四

[Ubuntu][把新硬碟設定成 NTFS 格式&改既有 NTFS partition 的 label]

標題有點怪,我知道 XD

最近新加了顆硬碟作為資料碟,因為電腦中還有 Win7,
希望能用 Windows 也能讀取的格式,所以想把資料碟用成 NTFS。

首先就是要把它格式改成 NTFS。

=================================================================

sudo fdisk /dev/sde
(sde 是新硬碟在我電腦裡的代號,請自行察看新硬碟在自己電腦中的代號)
=================================================================

在 fdisk 中建立 partition,因為我是想用整顆作為一個 partition,所以
就下指令 n 之後選 primary 後 default default 就建好了,情況像是下面:

=================================================================
Command (m for help): n        <---------------這個是我輸入的
Command action
   e   extended
   p   primary partition (1-4)
p                                              <---------------這個是我輸入的
Partition number (1-4): 1        <---------------這個是我輸入的
First cylinder (1-30401, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-30401, default 30401):
Using default value 30401
=================================================================

然後就順利的把 partition 切好了,可以輸入 p 看看狀況。

=================================================================
Command (m for help): p        <---------------這個是我輸入的

Disk /dev/sde: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 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: 0xee202071

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1       30401   244196001   83  Linux
=================================================================

因為 System 預設是 Linux,所以現在我要把它改成 NTFS,就輸入 t,
然後 Hex code 輸入 7,當然也可以用 L 看有什麼樣的格式可以選,
因為列出來很難排版,所以有興趣的人再自己去看。然後再輸入 p 列出資訊,
已經把 System 改成 NTFS 了。

=================================================================
Command (m for help): t        <---------------這個是我輸入的
Selected partition 1
Hex code (type L to list codes): 7    <------這個是我輸入的
Changed system type of partition 1 to 7 (HPFS/NTFS)

Command (m for help): p        <---------------這個是我輸入的

Disk /dev/sde: 250.1 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 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: 0xee202071

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1       30401   244196001    7  HPFS/NTFS
=================================================================

然後完成了嗎?還沒。還沒把資訊寫進去,所以要用 w 把資訊寫入,
才是真正的把硬碟改成 NTFS 的。

=================================================================
Command (m for help): w        <---------------這個是我輸入的
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
=================================================================

然後就是要格式化它啦,這時可以設定 label 給那 partition,像是我用 Data。
格式化的時間有點長,因為要把 zero 寫入整個 partition 中。
這邊也可以設定 Cluster size,有興趣的自己 man。

=================================================================
sudo mkfs.ntfs -L Data /dev/sde1
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes:   3%
=================================================================

等到跑到 100% 了,新硬碟就可以用囉,至於 fstab 那些就自己設定吧。
或者像我用 Ubuntu 的 GUI,可以直接在系統列選 Places,中文翻位置吧,
裡面找到新硬碟,點下去就自動 mount 起來了。

另外要改 label 的話,先把那 partition umount,以我這邊的狀況是。

=================================================================
 sudo umount /media/Data
=================================================================

然後用 ntfslabel 改 label,像是改成 Fun。

=================================================================
sudo ntfslabel /dev/sde1 Fun
=================================================================

這樣就把 label 改掉了,然後再重新 mount 起來硬碟又可以用了。