ntfs

最後更新: 2015-01-19

 

 


Install

 

# C6

yum install ntfs-3g ntfsprogs

# C7

yum install epel-release

yum install ntfs-3g ntfsprogs

 


Format Disk

 

Opt

-f, --fast       # This will skip both zeroing of the volume and bad sector checking

-L, --label STRING

-c, --cluster-size BYTES      # Default: 4k (a cluster cannot be smaller than a sector)

-s, --sector-size BYTES       # If omitted, it attempts to determine the sector-size (Default: 512 bytes)

-F, --force       # Force mkntfs to run, even if the specified device is not a block special device

i.e.

mkfs.ntfs -f /dev/sdXN

 

 


ntfs-3g

 

Usage:

ntfs-3g [-o option[,...]] <device|image_file> <mount_point>

Options: 

  • ro (read-only mount),
  • remove_hiberfile,
  • uid=,
  • gid=,
  • umask=,
  • fmask=,
  • dmask=

Other

big_writes    # prevents fuse from splitting write buffers into 4K chunks

relatime

inherit         # When creating a new file,

# set its initial protections according to inheritance rules defined in parent directory

Example:

# readonly mount

mount -o ro -t ntfs /dev/xxx /mnt/windows

# readonly 在要 fsck 時很有用, 因為不用 check 它.

ntfs-3g -o ro /dev/loop0 /mnt/winxp

 


ntfsfix

 

這工具只能修改一些很基本的 NTFS 問題, 所以, 可以的話, 還是用 windows 的 chkdsk 為好

ntfsfix /dev/sdb1

Mounting volume... OK
Processing of $MFT and $MFTMirr completed successfully.
NTFS volume version is 3.1.
NTFS partition /dev/sdb1 was processed successfully.

 


ntfsresize

 

ntfsresize [OPTIONS] [--size SIZE[k|M|G]] DEVICE

  • -i, --info
  • -f, --force    <-- 無視  consistency check 的 flag
  • -n, --no-action  <-- 測試
  • -s, --size SIZE[k|M|G]
  • -v, --verbose

ntfsresize -f -i /dev/sdb1

ntfsresize v2.0.0 (libntfs 10:0:0)
Device name        : /dev/sdb1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 8587158016 bytes (8588 MB)
Current device size: 21473787904 bytes (21474 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 2873 MB (33.5%)
Collecting resizing constraints ...
You might resize at 2872438784 bytes or 2873 MB (freeing 5715 MB).
Please make a test run using both the -n and -s options before real resizing!

 * 當沒有任何 -i, -s 參數時, 它會 resize 到最大

ntfsresize -f /dev/sdb1

ntfsresize v2.0.0 (libntfs 10:0:0)
Device name        : /dev/sdb1
NTFS volume version: 3.1
Cluster size       : 4096 bytes
Current volume size: 8587158016 bytes (8588 MB)
Current device size: 21473787904 bytes (21474 MB)
New volume size    : 21473784320 bytes (21474 MB)
Checking filesystem consistency ...
100.00 percent completed
Accounting clusters ...
Space in use       : 2873 MB (33.5%)
Collecting resizing constraints ...
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
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/sdb1'.

 

 


Fix NTFS boot

 

Recovery Console from the Windows installation disk.

Vista or Windows 7

To repair the Master Boot Record of the boot disk:

bootrec /fixmbr

To write a new partition boot sector to the system partition:

bootrec /fixboot

To rebuild the Boot Configuration Data (BCD) store:

    bootrec /rebuildbcd

WinXP

To repair the Master Boot Record of the boot disk:

    fixmbr

To write a new partition boot sector to the system partition:

    fixboot

To rebuild the boot.ini configuration file:

    bootcfg /rebuild

 


Troubleshoot

 

Q1: Unable to display current owner.

A1: Others pointed out that this can be fixed by restarting

this is because this issue is can be caused by applications keeping file handles opened.