ntfsresize

購入したばかりのノートパソコンのパーティションを切る時に使ったりなど。今はグラフィカルなIFでも出来るんだろうか??まぁともあれ基本はこんな具合で。以下の作業は全てknoppixから行っている

現在の領域情報

# fdisk -l -u /dev/sda

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders, total 488397168 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x1cc942d7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   488375999   244187968+   7  HPFS/NTFS

特に隠しパーティションがあるわけでもなく素直な感じだ。この/dev/sda1のNTFSパーティションを縮める

ntfsresize -i

# ntfsresize -i /dev/sda1
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name        : /dev/sda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 250048479744 bytes (250049 MB)
Current device size: 250048479744 bytes (250049 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 10560 MB (4.2%)
Collecting resizing constraints ...
You might resize at 10559328256 bytes or 10560 MB (freeing 239489 MB).
Please make a test run using both the -n and -s options before real resizing!

You might resize at 10559328256 bytes or 10560 MB (freeing 239489 MB).に注目したい。これは10560M(つまり10G)まで縮められるよといっている。

テストと実行

ここで100Gまで縮める事にする。Gがサポートされているのかどうかわからないけど後々面倒なことになりそうなので102400MBという事にする。

-nはdry runである。まずこれでテストすべき

# ntfsresize -n -s 102400M /dev/sda1
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name        : /dev/sda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 250048479744 bytes (250049 MB)
Current device size: 250048479744 bytes (250049 MB)
New volume size    : 102399996416 bytes (102400 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 10560 MB (4.2%)
Collecting resizing constraints ...
Needed relocations : 0 (0 MB)
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
The read-only test run ended successfully.

テストが通過したら-nを外す。(テストが通過しない場合(たとえばフラグメンテーションが酷かったり正常にブートしていない状態でのジャーナルがある状態の場合はかならずwindowsを起動して処理を済ませておく事))

# ntfsresize -s 102400M /dev/sda1
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name        : /dev/sda1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 250048479744 bytes (250049 MB)
Current device size: 250048479744 bytes (250049 MB)
New volume size    : 102399996416 bytes (102400 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 10560 MB (4.2%)
Collecting resizing constraints ...
Needed relocations : 0 (0 MB)
WARNING: Every sanity check passed and only the dangerous operations left.
Make sure that important data has been backed up! Power outage or computer
crash may result major data loss!
Are you sure you want to proceed (y/[n])?

yを入力したらもう戻れない

Are you sure you want to proceed (y/[n])? y
Schedule chkdsk for NTFS consistency check at Windows boot time ...
Resetting $LogFile ... (this might take a while)
Updating $BadClust file ...
Updating $Bitmap file ...
Updating Boot record ...
Syncing device ...
Successfully resized NTFS on device '/dev/sda1'.
You can go on to shrink the device for example with Linux fdisk.
IMPORTANT: When recreating the partition, make sure that you
  1)  create it at the same disk sector (use sector as the unit!)
  2)  create it with the same partition type (usually 7, HPFS/NTFS)
  3)  do not make it smaller than the new NTFS filesystem size
  4)  set the bootable flag for the partition if it existed before
Otherwise you won't be able to access NTFS or can't boot from the disk!
If you make a mistake and don't have a partition table backup then you
can recover the partition table by TestDisk or Parted's rescue mode.

この後のプロセスが重要である。この1,2,3,4を順に実行する。

パーティショニング

fdiskを起動し、pを押す

# fdisk /dev/sda

The number of cylinders for this disk is set to 30401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that 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)

Command (m for help): p

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1cc942d7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       30400   244187968+   7  HPFS/NTFS

Command (m for help):

ここで/dev/sda1のパーティションを削除してしまう(怖っ)。これはdで行う。消すべきものが1つしかない場合は勝手に選択される。pで表示してみる

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1cc942d7

   Device Boot      Start         End      Blocks   Id  System

このように綺麗になっているのでここで再度パーティションを切り直す

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 or +size or +sizeM or +sizeK (1-30401, default 30401): +102400M

Command (m for help): p

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1cc942d7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       12450   100004593+  83  Linux

これが一連の流れ。ここでパーティションIDガLinux(83)になっているのでNTFSの07に変更

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 07
Changed system type of partition 1 to 7 (HPFS/NTFS)

Command (m for help): p

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1cc942d7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       12450   100004593+   7  HPFS/NTFS

ここまででntfsresizeが吐いてきた1、2、3の作業は終了。残す4はbootフラグを立てるという作業になる。

Command (m for help): a
Partition number (1-4): 1

Command (m for help): p

Disk /dev/sda: 250.0 GB, 250059350016 bytes
255 heads, 63 sectors/track, 30401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x1cc942d7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1       12450   100004593+   7  HPFS/NTFS

これで全ておk。あとはwを押す

Command (m for help): w
The partition table has been altered!

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

これでwindows側でbootするとディスクチェックがかかって最終的に3回くらい再起動を要求される。ディスクの管理で上手く縮んでいればOK

# ntfsresize -i /dev/sda2
ntfsresize v2.0.0 (libntfs 10:0:0)
Device name        : /dev/sda2
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 154799768064 bytes (154800 MB)
Current device size: 154799769600 bytes (154800 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 6280 MB (4.1%)
Collecting resizing constraints ...
You might resize at 6279024640 bytes or 6280 MB (freeing 148520 MB).
Please make a test run using both the -n and -s options before real resizing!
# ntfsresize -n -s 102400M /dev/sda2
# ntfsresize -s 102400M /dev/sda2
# fdisk /dev/sda
Command (m for help): p

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x11a8ba38

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         637     5116671   12  Compaq diagnostics
/dev/sda2   *         638       19457   151171650    7  HPFS/NTFS

Command (m for help):

Command (m for help): d
Partition number (1-4): 2

Command (m for help): p

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x11a8ba38

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         637     5116671   12  Compaq diagnostics

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (638-19457, default 638):
Using default value 638
Last cylinder or +size or +sizeM or +sizeK (638-19457, default 19457): +102400M

Command (m for help): p

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x11a8ba38

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         637     5116671   12  Compaq diagnostics
/dev/sda2             638       13087   100004625   83  Linux

Command (m for help): a
Partition number (1-4): 2

Command (m for help): t
Partition number (1-4): 2
Hex code (type L to list codes): 7
Changed system type of partition 2 to 7 (HPFS/NTFS)

Command (m for help): p

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x11a8ba38

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1         637     5116671   12  Compaq diagnostics
/dev/sda2   *         638       13087   100004625    7  HPFS/NTFS

Command (m for help): w
The partition table has been altered!
ntfsresize.txt · 最終更新: 2012/04/07 10:32 (外部編集)
www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0